Skip to content

Commit

Permalink
[cleanup][test] Remove and prevent junit (apache#20611)
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
  • Loading branch information
nodece authored Jul 7, 2023
1 parent cedc513 commit c1f52f8
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion buildtools/src/main/resources/pulsar/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ page at http://checkstyle.sourceforge.net/config.html -->

<module name="IllegalImport">
<property name="illegalPkgs"
value="autovalue.shaded, avro.shaded, bk-shade, com.google.api.client.repackaged, com.google.appengine.repackaged, org.apache.curator.shaded, org.testcontainers.shaded" />
value="autovalue.shaded, avro.shaded, bk-shade, com.google.api.client.repackaged, com.google.appengine.repackaged, org.apache.curator.shaded, org.testcontainers.shaded, org.junit" />
</module>

<module name="RedundantModifier">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.Builder;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.TenantInfo;
import org.apache.pulsar.metadata.bookkeeper.BKCluster;
import org.junit.platform.commons.util.StringUtils;


public class EmbeddedPulsarCluster implements AutoCloseable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.pulsar.broker.admin;

import static org.junit.Assert.assertFalse;
import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThrows;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertThrows;
import static org.testng.AssertJUnit.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import static org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitState.Owned;
import static org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitState.Releasing;
import static org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitState.Splitting;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
*/
package org.apache.pulsar.broker.loadbalance.extensions.data;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.apache.pulsar.broker.loadbalance.extensions.ExtensibleLoadManagerImpl;
import org.apache.pulsar.broker.lookup.LookupResult;
import org.apache.pulsar.policies.data.loadbalancer.AdvertisedListener;
import org.junit.Assert;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Test(groups = "broker")
public class BrokerLookupDataTest {
Expand All @@ -44,21 +45,21 @@ public void testConstructors() {
webServiceUrl, webServiceUrlTls, pulsarServiceUrl,
pulsarServiceUrlTls, advertisedListeners, protocols, true, true,
ExtensibleLoadManagerImpl.class.getName(), System.currentTimeMillis(),"3.0");
Assert.assertEquals(webServiceUrl, lookupData.webServiceUrl());
Assert.assertEquals(webServiceUrlTls, lookupData.webServiceUrlTls());
Assert.assertEquals(pulsarServiceUrl, lookupData.pulsarServiceUrl());
Assert.assertEquals(pulsarServiceUrlTls, lookupData.pulsarServiceUrlTls());
Assert.assertEquals(Optional.of("9092"), lookupData.getProtocol("kafka"));
Assert.assertEquals(Optional.empty(), lookupData.getProtocol("echo"));
Assert.assertTrue(lookupData.persistentTopicsEnabled());
Assert.assertTrue(lookupData.nonPersistentTopicsEnabled());
Assert.assertEquals("3.0", lookupData.brokerVersion());
assertEquals(webServiceUrl, lookupData.webServiceUrl());
assertEquals(webServiceUrlTls, lookupData.webServiceUrlTls());
assertEquals(pulsarServiceUrl, lookupData.pulsarServiceUrl());
assertEquals(pulsarServiceUrlTls, lookupData.pulsarServiceUrlTls());
assertEquals(Optional.of("9092"), lookupData.getProtocol("kafka"));
assertEquals(Optional.empty(), lookupData.getProtocol("echo"));
assertTrue(lookupData.persistentTopicsEnabled());
assertTrue(lookupData.nonPersistentTopicsEnabled());
assertEquals("3.0", lookupData.brokerVersion());


LookupResult lookupResult = lookupData.toLookupResult();
Assert.assertEquals(webServiceUrl, lookupResult.getLookupData().getHttpUrl());
Assert.assertEquals(webServiceUrlTls, lookupResult.getLookupData().getHttpUrlTls());
Assert.assertEquals(pulsarServiceUrl, lookupResult.getLookupData().getBrokerUrl());
Assert.assertEquals(pulsarServiceUrlTls, lookupResult.getLookupData().getBrokerUrlTls());
assertEquals(webServiceUrl, lookupResult.getLookupData().getHttpUrl());
assertEquals(webServiceUrlTls, lookupResult.getLookupData().getHttpUrlTls());
assertEquals(pulsarServiceUrl, lookupResult.getLookupData().getBrokerUrl());
assertEquals(pulsarServiceUrlTls, lookupResult.getLookupData().getBrokerUrlTls());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
package org.apache.pulsar.broker.service;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.concurrent.TimeUnit;
import org.apache.pulsar.broker.BrokerTestUtil;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.MessageId;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.common.policies.data.TopicStats;
import org.junit.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void testReplicatorProducerStatInTopic() throws Exception {

// Verify there has one item in the attribute "publishers" or "replications"
TopicStats topicStats2 = admin2.topics().getStats(topicName);
Assert.assertTrue(topicStats2.getPublishers().size() + topicStats2.getReplication().size() > 0);
assertTrue(topicStats2.getPublishers().size() + topicStats2.getReplication().size() > 0);

// cleanup.
consumer2.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.pulsar.common.policies.data.TopicStats;
import org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap;
import org.awaitility.Awaitility;
import org.junit.Assert;
import org.mockito.Mockito;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -126,7 +125,7 @@ public void testCreateNonExistentPartitions() throws PulsarAdminException, Pulsa
} catch (PulsarClientException.TopicDoesNotExistException ignored) {

}
Assert.assertEquals(admin.topics().getPartitionedTopicMetadata(topicName).partitions, 4);
assertEquals(admin.topics().getPartitionedTopicMetadata(topicName).partitions, 4);
}


Expand Down Expand Up @@ -212,41 +211,41 @@ public void testSubscriptionsOnNonPersistentTopic() throws Exception {
.subscribe();

ConcurrentOpenHashMap<String, NonPersistentSubscription> subscriptionMap = mockTopic.getSubscriptions();
Assert.assertEquals(subscriptionMap.size(), 4);
assertEquals(subscriptionMap.size(), 4);

// Check exclusive subscription
NonPersistentSubscription exclusiveSub = subscriptionMap.get(exclusiveSubName);
Assert.assertNotNull(exclusiveSub);
assertNotNull(exclusiveSub);
exclusiveConsumer.close();
Awaitility.waitAtMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS)
.until(() -> subscriptionMap.get(exclusiveSubName) == null);

// Check failover subscription
NonPersistentSubscription failoverSub = subscriptionMap.get(failoverSubName);
Assert.assertNotNull(failoverSub);
assertNotNull(failoverSub);
failoverConsumer1.close();
failoverSub = subscriptionMap.get(failoverSubName);
Assert.assertNotNull(failoverSub);
assertNotNull(failoverSub);
failoverConsumer2.close();
Awaitility.waitAtMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS)
.until(() -> subscriptionMap.get(failoverSubName) == null);

// Check shared subscription
NonPersistentSubscription sharedSub = subscriptionMap.get(sharedSubName);
Assert.assertNotNull(sharedSub);
assertNotNull(sharedSub);
sharedConsumer1.close();
sharedSub = subscriptionMap.get(sharedSubName);
Assert.assertNotNull(sharedSub);
assertNotNull(sharedSub);
sharedConsumer2.close();
Awaitility.waitAtMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS)
.until(() -> subscriptionMap.get(sharedSubName) == null);

// Check KeyShared subscription
NonPersistentSubscription keySharedSub = subscriptionMap.get(keySharedSubName);
Assert.assertNotNull(keySharedSub);
assertNotNull(keySharedSub);
keySharedConsumer1.close();
keySharedSub = subscriptionMap.get(keySharedSubName);
Assert.assertNotNull(keySharedSub);
assertNotNull(keySharedSub);
keySharedConsumer2.close();
Awaitility.waitAtMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS)
.until(() -> subscriptionMap.get(keySharedSubName) == null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
import org.apache.pulsar.common.policies.data.TenantInfo;
import org.apache.pulsar.common.policies.data.TopicStats;
import org.awaitility.Awaitility;
import org.junit.Assert;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.pulsar.broker.transaction;

import static org.junit.Assert.assertEquals;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -152,7 +152,7 @@ private void waitTaskExecuteCompletely(AbortedTxnProcessor processor) throws Exc
.getDeclaredField("taskQueue");
taskQueueField.setAccessible(true);
Queue queue = (Queue) taskQueueField.get(persistentWorker);
Awaitility.await().untilAsserted(() -> Assert.assertEquals(queue.size(), 0));
Awaitility.await().untilAsserted(() -> assertEquals(queue.size(), 0));
}

private void verifyAbortedTxnIDAndSegmentIndex(AbortedTxnProcessor processor, int begin, int txnIdSize)
Expand All @@ -170,8 +170,8 @@ private void verifyAbortedTxnIDAndSegmentIndex(AbortedTxnProcessor processor, in
indexField.setAccessible(true);
LinkedList<TxnID> unsealedSegment = (LinkedList<TxnID>) unsealedSegmentField.get(processor);
LinkedMap<PositionImpl, TxnID> indexes = (LinkedMap<PositionImpl, TxnID>) indexField.get(processor);
Assert.assertEquals(unsealedSegment.size(), txnIdSize % SEGMENT_SIZE);
Assert.assertEquals(indexes.size(), txnIdSize / SEGMENT_SIZE);
assertEquals(unsealedSegment.size(), txnIdSize % SEGMENT_SIZE);
assertEquals(indexes.size(), txnIdSize / SEGMENT_SIZE);
}

// Verify the update index future can be completed when the queue has other tasks.
Expand Down Expand Up @@ -269,7 +269,7 @@ private void verifySnapshotSegmentsSize(String topic, int size) throws Exception
segmentCount++;
}
}
Assert.assertEquals(segmentCount, size);
assertEquals(segmentCount, size);
}

private void verifySnapshotSegmentsIndexSize(String topic, int size) throws Exception {
Expand All @@ -286,7 +286,7 @@ private void verifySnapshotSegmentsIndexSize(String topic, int size) throws Exce
}
System.out.printf("message.getValue().getTopicName() :" + message.getValue().getTopicName());
}
Assert.assertEquals(indexCount, size);
assertEquals(indexCount, size);
}

private void doCompaction(TopicName topic) throws Exception {
Expand Down

0 comments on commit c1f52f8

Please sign in to comment.