Skip to content

Commit

Permalink
Standardize the unit tests to use TestNG methods only (apache#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
sijie authored and merlimat committed Jan 7, 2018
1 parent 4d94413 commit 5263e64
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 24 deletions.
11 changes: 11 additions & 0 deletions managed-ledger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@
<scope>test</scope>
</dependency>

<!--
junit is a runtime dependency of zookeeper tests, so only
add this dependency here.
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ flexible messaging model and an intuitive client API.</description>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.5</version>
<version>6.13.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import org.apache.zookeeper.data.Stat;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.nio.charset.StandardCharsets;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class AdvertisedAddressTest {

Expand All @@ -42,7 +42,7 @@ public class AdvertisedAddressTest {

private final String advertisedAddress = "pulsar-usc.example.com";

@Before
@BeforeMethod
public void setup() throws Exception {
bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 5001);
bkEnsemble.start();
Expand All @@ -58,7 +58,7 @@ public void setup() throws Exception {
pulsar.start();
}

@After
@AfterMethod
public void shutdown() throws Exception {
pulsar.close();
bkEnsemble.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
import org.apache.pulsar.broker.stats.metrics.ManagedLedgerMetrics;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.common.stats.Metrics;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import junit.framework.Assert;

/**
*/
public class ManagedLedgerMetricsTest extends BrokerTestBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
import org.apache.pulsar.client.impl.auth.AuthenticationTls;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.PropertyAdmin;
import org.junit.Assert;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 @@ -21,9 +21,9 @@
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;

public class TlsProducerConsumerTest extends TlsProducerConsumerBase {
Expand Down Expand Up @@ -64,7 +64,7 @@ public void testTlsLargeSizeMessage() throws Exception {
msg = consumer.receive(5, TimeUnit.SECONDS);
byte[] expected = new byte[MESSAGE_SIZE];
Arrays.fill(expected, (byte) i);
Assert.assertArrayEquals(expected, msg.getData());
Assert.assertEquals(expected, msg.getData());
}
// Acknowledge the consumption of all messages at once
consumer.acknowledgeCumulative(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
******************************************************************************/
package com.scurrilous.circe.impl;

import static org.junit.Assert.*;

import java.nio.ByteBuffer;

import mockit.Expectations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,25 @@
*/
package org.apache.pulsar.client.impl;

import static org.junit.Assert.assertEquals;

import static org.testng.Assert.assertEquals;

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;
import org.junit.Test;
import org.testng.annotations.Test;

/**
* Unit test of {@link MessageBuilderImpl}.
*/
public class MessageBuilderTest {

@Test(expected = IllegalArgumentException.class)
@Test(expectedExceptions = IllegalArgumentException.class)
public void testSetEventTimeNegative() {
MessageBuilder builder = MessageBuilder.create();
builder.setEventTime(-1L);
}

@Test(expected = IllegalArgumentException.class)
@Test(expectedExceptions = IllegalArgumentException.class)
public void testSetEventTimeZero() {
MessageBuilder builder = MessageBuilder.create();
builder.setEventTime(0L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
package org.apache.pulsar.common.api;

import org.apache.pulsar.common.api.proto.PulsarApi;
import org.junit.Test;
import org.testng.Assert;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.testng.annotations.Test;

public class CommandUtilsTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/
package org.apache.pulsar.common.naming;

import junit.framework.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.testng.Assert;
import org.testng.annotations.Test;

public class MetadataTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -52,8 +53,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import junit.framework.Assert;

public class ProxyAuthenticatedProducerConsumerTest extends ProducerConsumerBase {
private static final Logger log = LoggerFactory.getLogger(ProxyAuthenticatedProducerConsumerTest.class);

Expand Down

0 comments on commit 5263e64

Please sign in to comment.