CURATOR-582: Migrate to jUnit 5.6 (#372)
diff --git a/curator-client/pom.xml b/curator-client/pom.xml
index 87bf810..acdeec6 100644
--- a/curator-client/pom.xml
+++ b/curator-client/pom.xml
@@ -72,8 +72,8 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
@@ -119,4 +119,3 @@
</plugins>
</build>
</project>
-
diff --git a/curator-client/src/test/java/org/apache/curator/BasicTests.java b/curator-client/src/test/java/org/apache/curator/BasicTests.java
index afb1c73..c90d4a1 100644
--- a/curator-client/src/test/java/org/apache/curator/BasicTests.java
+++ b/curator-client/src/test/java/org/apache/curator/BasicTests.java
@@ -18,6 +18,12 @@
*/
package org.apache.curator;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.curator.ensemble.fixed.FixedEnsembleProvider;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
@@ -29,9 +35,8 @@
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -52,7 +57,7 @@
};
CuratorZookeeperClient client = new CuratorZookeeperClient(zookeeperFactory, new FixedEnsembleProvider(server.getConnectString()), 10000, 10000, null, new RetryOneTime(1), false);
client.start();
- Assert.assertEquals(client.getZooKeeper(), mockZookeeper);
+ assertEquals(client.getZooKeeper(), mockZookeeper);
}
@Test
@@ -101,11 +106,11 @@
client.getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
ZooKeeper zooKeeper = client.getZooKeeper();
client.blockUntilConnectedOrTimedOut();
- Assert.assertNotNull(zooKeeper.exists("/foo", false));
+ assertNotNull(zooKeeper.exists("/foo", false));
return null;
}
}
@@ -133,9 +138,9 @@
Thread.sleep(1000);
server.restart();
- Assert.assertTrue(client.blockUntilConnectedOrTimedOut());
+ assertTrue(client.blockUntilConnectedOrTimedOut());
byte[] readData = client.getZooKeeper().getData("/test", false, null);
- Assert.assertEquals(readData, writtenData);
+ assertArrayEquals(readData, writtenData);
}
finally
{
@@ -152,7 +157,7 @@
{
client.blockUntilConnectedOrTimedOut();
String path = client.getZooKeeper().create("/test", new byte[]{1,2,3}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
- Assert.assertEquals(path, "/test");
+ assertEquals(path, "/test");
}
finally
{
@@ -168,7 +173,7 @@
CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(), 10000, CONNECTION_TIMEOUT_MS, null, new RetryOneTime(1));
try
{
- Assert.assertFalse(client.isConnected());
+ assertFalse(client.isConnected());
client.start();
outer: do
@@ -183,7 +188,7 @@
Thread.sleep(CONNECTION_TIMEOUT_MS);
}
- Assert.fail();
+ fail();
} while ( false );
}
finally
diff --git a/curator-client/src/test/java/org/apache/curator/TestEnsurePath.java b/curator-client/src/test/java/org/apache/curator/TestEnsurePath.java
index 5164bac..21d65c9 100644
--- a/curator-client/src/test/java/org/apache/curator/TestEnsurePath.java
+++ b/curator-client/src/test/java/org/apache/curator/TestEnsurePath.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -36,11 +37,10 @@
import org.apache.curator.utils.EnsurePath;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.testng.Assert;
-import org.testng.annotations.Test;
public class TestEnsurePath
{
@@ -117,9 +117,9 @@
);
}
- Assert.assertTrue(startedLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(startedLatch.await(10, TimeUnit.SECONDS));
semaphore.release(3);
- Assert.assertTrue(finishedLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(finishedLatch.await(10, TimeUnit.SECONDS));
verify(client, times(3)).exists(Mockito.<String>any(), anyBoolean());
ensurePath.ensure(curator);
diff --git a/curator-client/src/test/java/org/apache/curator/TestIs36.java b/curator-client/src/test/java/org/apache/curator/TestIs36.java
index 6480b6d..e7489a3 100644
--- a/curator-client/src/test/java/org/apache/curator/TestIs36.java
+++ b/curator-client/src/test/java/org/apache/curator/TestIs36.java
@@ -18,19 +18,22 @@
*/
package org.apache.curator;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.Compatibility;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
public class TestIs36 extends CuratorTestBase
{
- @Test(groups = zk36Group)
+ @Test
+ @Tag(zk36Group)
public void testIsZk36()
{
- Assert.assertTrue(Compatibility.hasGetReachableOrOneMethod());
- Assert.assertTrue(Compatibility.hasAddrField());
- Assert.assertTrue(Compatibility.hasPersistentWatchers());
+ assertTrue(Compatibility.hasGetReachableOrOneMethod());
+ assertTrue(Compatibility.hasAddrField());
+ assertTrue(Compatibility.hasPersistentWatchers());
}
@Override
diff --git a/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java b/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java
index 0922dff..0471a75 100644
--- a/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java
+++ b/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.retry.RetryForever;
import org.apache.curator.retry.RetryOneTime;
@@ -26,9 +29,8 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
@@ -44,7 +46,7 @@
@Override
public void sleepFor(long time, TimeUnit unit) throws InterruptedException
{
- Assert.assertTrue(unit.toMillis(time) <= 100);
+ assertTrue(unit.toMillis(time) <= 100);
}
};
ExponentialBackoffRetry retry = new ExponentialBackoffRetry(1, Integer.MAX_VALUE, 100);
@@ -89,7 +91,7 @@
default:
{
- Assert.fail();
+ fail();
break outer;
}
}
@@ -106,7 +108,7 @@
}
}
- Assert.assertTrue(loopCount >= 2);
+ assertTrue(loopCount >= 2);
}
finally
{
@@ -127,7 +129,7 @@
{
if ( ++loopCount > 2 )
{
- Assert.fail();
+ fail();
break;
}
@@ -142,7 +144,7 @@
}
}
- Assert.assertTrue(loopCount > 0);
+ assertTrue(loopCount > 0);
}
finally
{
@@ -160,7 +162,7 @@
for (int i = 0; i < 10; i++)
{
boolean allowed = retryForever.allowRetry(i, 0, sleeper);
- Assert.assertTrue(allowed);
+ assertTrue(allowed);
Mockito.verify(sleeper, times(i + 1)).sleepFor(retryIntervalMs, TimeUnit.MILLISECONDS);
}
}
@@ -196,14 +198,14 @@
}
}
- Assert.fail("Should failed with SessionExpiredException.");
+ fail("Should failed with SessionExpiredException.");
}
catch ( Exception e )
{
if ( e instanceof KeeperException )
{
int rc = ((KeeperException) e).code().intValue();
- Assert.assertEquals(rc, KeeperException.Code.SESSIONEXPIRED.intValue());
+ assertEquals(rc, KeeperException.Code.SESSIONEXPIRED.intValue());
}
else
{
diff --git a/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java b/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java
index 46657e5..049ee88 100644
--- a/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java
+++ b/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java
@@ -18,12 +18,16 @@
*/
package org.apache.curator;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.test.Timing;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -55,13 +59,13 @@
{
if ( firstTime.compareAndSet(true, false) )
{
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
client.getZooKeeper().getTestable().injectSessionExpiration();
client.getZooKeeper();
client.blockUntilConnectedOrTimedOut();
}
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
return null;
}
}
@@ -75,8 +79,8 @@
@Override
public Void call() throws Exception
{
- Assert.assertFalse(firstTime.get());
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertFalse(firstTime.get());
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
secondWasDone.set(true);
return null;
}
@@ -89,7 +93,7 @@
}
}
- Assert.assertTrue(secondWasDone.get());
+ assertTrue(secondWasDone.get());
}
finally
{
@@ -129,13 +133,13 @@
{
if ( firstTime.compareAndSet(true, false) )
{
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
client.getZooKeeper().getTestable().injectSessionExpiration();
client.getZooKeeper();
client.blockUntilConnectedOrTimedOut();
}
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
return null;
}
}
@@ -149,8 +153,8 @@
@Override
public Void call() throws Exception
{
- Assert.assertFalse(firstTime.get());
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertFalse(firstTime.get());
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
secondWasDone.set(true);
return null;
}
@@ -161,7 +165,7 @@
}
);
- Assert.assertTrue(secondWasDone.get());
+ assertTrue(secondWasDone.get());
}
finally
{
@@ -194,14 +198,14 @@
@Override
public Void call() throws Exception
{
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
client.getZooKeeper().getTestable().injectSessionExpiration();
timing.sleepABit();
client.getZooKeeper();
client.blockUntilConnectedOrTimedOut();
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
return null;
}
}
@@ -213,7 +217,7 @@
}
}
- Assert.fail();
+ fail();
}
catch ( SessionFailRetryLoop.SessionFailedException dummy )
{
@@ -256,12 +260,12 @@
@Override
public Void call() throws Exception
{
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
client.getZooKeeper().getTestable().injectSessionExpiration();
client.getZooKeeper();
client.blockUntilConnectedOrTimedOut();
- Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
+ assertNull(client.getZooKeeper().exists("/foo/bar", false));
return null;
}
}
diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestCloseableExecutorService.java b/curator-client/src/test/java/org/apache/curator/utils/TestCloseableExecutorService.java
index c083655..497e467 100644
--- a/curator-client/src/test/java/org/apache/curator/utils/TestCloseableExecutorService.java
+++ b/curator-client/src/test/java/org/apache/curator/utils/TestCloseableExecutorService.java
@@ -19,11 +19,13 @@
package org.apache.curator.utils;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -38,13 +40,13 @@
private volatile ExecutorService executorService;
- @BeforeMethod
+ @BeforeEach
public void setup()
{
executorService = Executors.newFixedThreadPool(QTY * 2);
}
- @AfterMethod
+ @AfterEach
public void tearDown()
{
executorService.shutdownNow();
@@ -63,9 +65,9 @@
submitRunnable(service, startLatch, latch);
}
- Assert.assertTrue(startLatch.await(3, TimeUnit.SECONDS));
+ assertTrue(startLatch.await(3, TimeUnit.SECONDS));
service.close();
- Assert.assertTrue(latch.await(3, TimeUnit.SECONDS));
+ assertTrue(latch.await(3, TimeUnit.SECONDS));
}
catch ( AssertionError e )
{
@@ -111,9 +113,9 @@
);
}
- Assert.assertTrue(startLatch.await(3, TimeUnit.SECONDS));
+ assertTrue(startLatch.await(3, TimeUnit.SECONDS));
service.close();
- Assert.assertTrue(latch.await(3, TimeUnit.SECONDS));
+ assertTrue(latch.await(3, TimeUnit.SECONDS));
}
@Test
@@ -146,14 +148,14 @@
futures.add(future);
}
- Assert.assertTrue(startLatch.await(3, TimeUnit.SECONDS));
+ assertTrue(startLatch.await(3, TimeUnit.SECONDS));
for ( Future<?> future : futures )
{
future.cancel(true);
}
- Assert.assertEquals(service.size(), 0);
+ assertEquals(service.size(), 0);
}
@Test
@@ -187,13 +189,13 @@
futures.add(future);
}
- Assert.assertTrue(startLatch.await(3, TimeUnit.SECONDS));
+ assertTrue(startLatch.await(3, TimeUnit.SECONDS));
for ( Future<?> future : futures )
{
future.cancel(true);
}
- Assert.assertEquals(service.size(), 0);
+ assertEquals(service.size(), 0);
}
@Test
@@ -236,10 +238,10 @@
Thread.sleep(100);
}
- Assert.assertTrue(startLatch.await(3, TimeUnit.SECONDS));
+ assertTrue(startLatch.await(3, TimeUnit.SECONDS));
service.close();
- Assert.assertTrue(latch.await(3, TimeUnit.SECONDS));
- Assert.assertEquals(outsideLatch.getCount(), 1);
+ assertTrue(latch.await(3, TimeUnit.SECONDS));
+ assertEquals(outsideLatch.getCount(), 1);
}
private void submitRunnable(CloseableExecutorService service, final CountDownLatch startLatch, final CountDownLatch latch)
diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestCloseableScheduledExecutorService.java b/curator-client/src/test/java/org/apache/curator/utils/TestCloseableScheduledExecutorService.java
index c2510ed..85be3e3 100644
--- a/curator-client/src/test/java/org/apache/curator/utils/TestCloseableScheduledExecutorService.java
+++ b/curator-client/src/test/java/org/apache/curator/utils/TestCloseableScheduledExecutorService.java
@@ -18,17 +18,18 @@
*/
package org.apache.curator.utils;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
public class TestCloseableScheduledExecutorService
{
private static final int QTY = 10;
@@ -36,13 +37,13 @@
private volatile ScheduledExecutorService executorService;
- @BeforeMethod
+ @BeforeEach
public void setup()
{
executorService = Executors.newScheduledThreadPool(QTY * 2);
}
- @AfterMethod
+ @AfterEach
public void tearDown()
{
executorService.shutdownNow();
@@ -68,7 +69,7 @@
TimeUnit.MILLISECONDS
);
- Assert.assertTrue(latch.await((QTY * 2) * DELAY_MS, TimeUnit.MILLISECONDS));
+ assertTrue(latch.await((QTY * 2) * DELAY_MS, TimeUnit.MILLISECONDS));
}
@Test
@@ -103,18 +104,18 @@
Thread.sleep(DELAY_MS * 2);
int innerValue = innerCounter.get();
- Assert.assertTrue(innerValue > 0);
+ assertTrue(innerValue > 0);
int value = outerCounter.get();
Thread.sleep(DELAY_MS * 2);
int newValue = outerCounter.get();
- Assert.assertTrue(newValue > value);
- Assert.assertEquals(innerValue, innerCounter.get());
+ assertTrue(newValue > value);
+ assertEquals(innerValue, innerCounter.get());
value = newValue;
Thread.sleep(DELAY_MS * 2);
newValue = outerCounter.get();
- Assert.assertTrue(newValue > value);
- Assert.assertEquals(innerValue, innerCounter.get());
+ assertTrue(newValue > value);
+ assertEquals(innerValue, innerCounter.get());
}
}
diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java
index ef05d34..5cfaf7b 100644
--- a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java
+++ b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java
@@ -19,8 +19,8 @@
package org.apache.curator.utils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
@@ -30,58 +30,58 @@
@Test
public void testMakePath()
{
- Assert.assertEquals(ZKPaths.makePath(null, "/"), "/");
- Assert.assertEquals(ZKPaths.makePath("", null), "/");
- Assert.assertEquals(ZKPaths.makePath("/", null), "/");
- Assert.assertEquals(ZKPaths.makePath(null, null), "/");
+ assertEquals(ZKPaths.makePath(null, "/"), "/");
+ assertEquals(ZKPaths.makePath("", null), "/");
+ assertEquals(ZKPaths.makePath("/", null), "/");
+ assertEquals(ZKPaths.makePath(null, null), "/");
- Assert.assertEquals(ZKPaths.makePath("/", "/"), "/");
- Assert.assertEquals(ZKPaths.makePath("", "/"), "/");
- Assert.assertEquals(ZKPaths.makePath("/", ""), "/");
- Assert.assertEquals(ZKPaths.makePath("", ""), "/");
+ assertEquals(ZKPaths.makePath("/", "/"), "/");
+ assertEquals(ZKPaths.makePath("", "/"), "/");
+ assertEquals(ZKPaths.makePath("/", ""), "/");
+ assertEquals(ZKPaths.makePath("", ""), "/");
- Assert.assertEquals(ZKPaths.makePath("foo", ""), "/foo");
- Assert.assertEquals(ZKPaths.makePath("foo", "/"), "/foo");
- Assert.assertEquals(ZKPaths.makePath("/foo", ""), "/foo");
- Assert.assertEquals(ZKPaths.makePath("/foo", "/"), "/foo");
+ assertEquals(ZKPaths.makePath("foo", ""), "/foo");
+ assertEquals(ZKPaths.makePath("foo", "/"), "/foo");
+ assertEquals(ZKPaths.makePath("/foo", ""), "/foo");
+ assertEquals(ZKPaths.makePath("/foo", "/"), "/foo");
- Assert.assertEquals(ZKPaths.makePath("foo", null), "/foo");
- Assert.assertEquals(ZKPaths.makePath("foo", null), "/foo");
- Assert.assertEquals(ZKPaths.makePath("/foo", null), "/foo");
- Assert.assertEquals(ZKPaths.makePath("/foo", null), "/foo");
+ assertEquals(ZKPaths.makePath("foo", null), "/foo");
+ assertEquals(ZKPaths.makePath("foo", null), "/foo");
+ assertEquals(ZKPaths.makePath("/foo", null), "/foo");
+ assertEquals(ZKPaths.makePath("/foo", null), "/foo");
- Assert.assertEquals(ZKPaths.makePath("", "bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath("/", "bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath("", "/bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath("/", "/bar"), "/bar");
+ assertEquals(ZKPaths.makePath("", "bar"), "/bar");
+ assertEquals(ZKPaths.makePath("/", "bar"), "/bar");
+ assertEquals(ZKPaths.makePath("", "/bar"), "/bar");
+ assertEquals(ZKPaths.makePath("/", "/bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath(null, "bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath(null, "bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath(null, "/bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath(null, "/bar"), "/bar");
+ assertEquals(ZKPaths.makePath(null, "bar"), "/bar");
+ assertEquals(ZKPaths.makePath(null, "bar"), "/bar");
+ assertEquals(ZKPaths.makePath(null, "/bar"), "/bar");
+ assertEquals(ZKPaths.makePath(null, "/bar"), "/bar");
- Assert.assertEquals(ZKPaths.makePath("foo", "bar"), "/foo/bar");
- Assert.assertEquals(ZKPaths.makePath("/foo", "bar"), "/foo/bar");
- Assert.assertEquals(ZKPaths.makePath("foo", "/bar"), "/foo/bar");
- Assert.assertEquals(ZKPaths.makePath("/foo", "/bar"), "/foo/bar");
- Assert.assertEquals(ZKPaths.makePath("/foo", "bar/"), "/foo/bar");
- Assert.assertEquals(ZKPaths.makePath("/foo/", "/bar/"), "/foo/bar");
+ assertEquals(ZKPaths.makePath("foo", "bar"), "/foo/bar");
+ assertEquals(ZKPaths.makePath("/foo", "bar"), "/foo/bar");
+ assertEquals(ZKPaths.makePath("foo", "/bar"), "/foo/bar");
+ assertEquals(ZKPaths.makePath("/foo", "/bar"), "/foo/bar");
+ assertEquals(ZKPaths.makePath("/foo", "bar/"), "/foo/bar");
+ assertEquals(ZKPaths.makePath("/foo/", "/bar/"), "/foo/bar");
- Assert.assertEquals(ZKPaths.makePath("foo", "bar", "baz"), "/foo/bar/baz");
- Assert.assertEquals(ZKPaths.makePath("foo", "bar", "baz", "qux"), "/foo/bar/baz/qux");
- Assert.assertEquals(ZKPaths.makePath("/foo", "/bar", "/baz"), "/foo/bar/baz");
- Assert.assertEquals(ZKPaths.makePath("/foo/", "/bar/", "/baz/"), "/foo/bar/baz");
- Assert.assertEquals(ZKPaths.makePath("foo", null, null), "/foo");
- Assert.assertEquals(ZKPaths.makePath("foo", "bar", null), "/foo/bar");
- Assert.assertEquals(ZKPaths.makePath("foo", null, "baz"), "/foo/baz");
+ assertEquals(ZKPaths.makePath("foo", "bar", "baz"), "/foo/bar/baz");
+ assertEquals(ZKPaths.makePath("foo", "bar", "baz", "qux"), "/foo/bar/baz/qux");
+ assertEquals(ZKPaths.makePath("/foo", "/bar", "/baz"), "/foo/bar/baz");
+ assertEquals(ZKPaths.makePath("/foo/", "/bar/", "/baz/"), "/foo/bar/baz");
+ assertEquals(ZKPaths.makePath("foo", null, null), "/foo");
+ assertEquals(ZKPaths.makePath("foo", "bar", null), "/foo/bar");
+ assertEquals(ZKPaths.makePath("foo", null, "baz"), "/foo/baz");
}
@Test
public void testSplit()
{
- Assert.assertEquals(ZKPaths.split("/"), Collections.emptyList());
- Assert.assertEquals(ZKPaths.split("/test"), Collections.singletonList("test"));
- Assert.assertEquals(ZKPaths.split("/test/one"), Arrays.asList("test", "one"));
- Assert.assertEquals(ZKPaths.split("/test/one/two"), Arrays.asList("test", "one", "two"));
+ assertEquals(ZKPaths.split("/"), Collections.emptyList());
+ assertEquals(ZKPaths.split("/test"), Collections.singletonList("test"));
+ assertEquals(ZKPaths.split("/test/one"), Arrays.asList("test", "one"));
+ assertEquals(ZKPaths.split("/test/one/two"), Arrays.asList("test", "one", "two"));
}
}
diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml
index e88a9c8..b44dcde 100644
--- a/curator-framework/pom.xml
+++ b/curator-framework/pom.xml
@@ -76,8 +76,8 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/ensemble/TestEnsembleProvider.java b/curator-framework/src/test/java/org/apache/curator/framework/ensemble/TestEnsembleProvider.java
index 19d65a4..4891714 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/ensemble/TestEnsembleProvider.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/ensemble/TestEnsembleProvider.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.ensemble;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.ensemble.EnsembleProvider;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -28,11 +30,10 @@
import org.apache.curator.test.TestingServer;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
public class TestEnsembleProvider extends BaseClassForTests
{
@@ -46,7 +47,7 @@
try
{
client.start();
- Assert.assertTrue(timing.acquireSemaphore(counter));
+ assertTrue(timing.acquireSemaphore(counter));
}
finally
{
@@ -87,20 +88,20 @@
client.getConnectionStateListenable().addListener(listener);
client.start();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
server.stop();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
counter.drainPermits();
for ( int i = 0; i < 5; ++i )
{
// the ensemble provider should still be called periodically when the connection is lost
- Assert.assertTrue(timing.acquireSemaphore(counter), "Failed when i is: " + i);
+ assertTrue(timing.acquireSemaphore(counter), "Failed when i is: " + i);
}
server = new TestingServer(); // this changes the CountingEnsembleProvider's value for getConnectionString() - connection should notice this and recover
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestBlockUntilConnected.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestBlockUntilConnected.java
index 01646fc..7c5091b 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestBlockUntilConnected.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestBlockUntilConnected.java
@@ -19,6 +19,10 @@
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.state.ConnectionState;
@@ -28,8 +32,8 @@
import org.apache.curator.test.TestingServer;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CountDownLatch;
@@ -66,12 +70,12 @@
client.start();
- Assert.assertTrue(timing.awaitLatch(connectedLatch), "Timed out awaiting latch");
- Assert.assertTrue(client.blockUntilConnected(1, TimeUnit.SECONDS), "Not connected");
+ assertTrue(timing.awaitLatch(connectedLatch), "Timed out awaiting latch");
+ assertTrue(client.blockUntilConnected(1, TimeUnit.SECONDS), "Not connected");
}
catch ( InterruptedException e )
{
- Assert.fail("Unexpected interruption");
+ fail("Unexpected interruption");
}
finally
{
@@ -93,11 +97,11 @@
try
{
client.start();
- Assert.assertTrue(client.blockUntilConnected(5, TimeUnit.SECONDS), "Not connected");
+ assertTrue(client.blockUntilConnected(5, TimeUnit.SECONDS), "Not connected");
}
catch ( InterruptedException e )
{
- Assert.fail("Unexpected interruption");
+ fail("Unexpected interruption");
}
finally
{
@@ -137,21 +141,21 @@
client.start();
//Block until we're connected
- Assert.assertTrue(client.blockUntilConnected(5, TimeUnit.SECONDS), "Failed to connect");
+ assertTrue(client.blockUntilConnected(5, TimeUnit.SECONDS), "Failed to connect");
//Kill the server
CloseableUtils.closeQuietly(server);
//Wait until we hit the lost state
- Assert.assertTrue(timing.awaitLatch(lostLatch), "Failed to reach LOST state");
+ assertTrue(timing.awaitLatch(lostLatch), "Failed to reach LOST state");
server = new TestingServer(server.getPort(), server.getTempDirectory());
- Assert.assertTrue(client.blockUntilConnected(5, TimeUnit.SECONDS), "Not connected");
+ assertTrue(client.blockUntilConnected(5, TimeUnit.SECONDS), "Not connected");
}
catch ( Exception e )
{
- Assert.fail("Unexpected exception " + e);
+ fail("Unexpected exception " + e);
}
finally
{
@@ -177,11 +181,11 @@
try
{
client.start();
- Assert.assertFalse(client.blockUntilConnected(5, TimeUnit.SECONDS), "Connected");
+ assertFalse(client.blockUntilConnected(5, TimeUnit.SECONDS), "Connected");
}
catch ( InterruptedException e )
{
- Assert.fail("Unexpected interruption");
+ fail("Unexpected interruption");
}
finally
{
@@ -222,7 +226,7 @@
}, 3000);
client.blockUntilConnected(5, TimeUnit.SECONDS);
- Assert.fail("Expected interruption did not occur");
+ fail("Expected interruption did not occur");
}
catch ( InterruptedException e )
{
@@ -249,7 +253,7 @@
client.start();
client.blockUntilConnected();
- Assert.assertTrue(client.getZookeeperClient().isConnected(), "Not connected after blocking for connection #" + i);
+ assertTrue(client.getZookeeperClient().isConnected(), "Not connected after blocking for connection #" + i);
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompression.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompression.java
index 520d0b6..613ba9d 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompression.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompression.java
@@ -18,14 +18,18 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.CompressionProvider;
import org.apache.curator.retry.RetryOneTime;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.atomic.AtomicInteger;
public class TestCompression extends BaseClassForTests
@@ -72,16 +76,16 @@
client.create().compressed().creatingParentsIfNeeded().forPath("/a/b/c", data);
- Assert.assertNotEquals(data, client.getData().forPath("/a/b/c"));
- Assert.assertEquals(data.length, client.getData().decompressed().forPath("/a/b/c").length);
+ assertNotEquals(data, client.getData().forPath("/a/b/c"));
+ assertEquals(data.length, client.getData().decompressed().forPath("/a/b/c").length);
}
finally
{
CloseableUtils.closeQuietly(client);
}
- Assert.assertEquals(compressCounter.get(), 1);
- Assert.assertEquals(decompressCounter.get(), 1);
+ assertEquals(compressCounter.get(), 1);
+ assertEquals(decompressCounter.get(), 1);
}
@Test
@@ -95,10 +99,10 @@
client.start();
client.create().creatingParentsIfNeeded().forPath("/a/b/c", data);
- Assert.assertEquals(data, client.getData().forPath("/a/b/c"));
+ assertArrayEquals(data, client.getData().forPath("/a/b/c"));
client.setData().compressed().forPath("/a/b/c", data);
- Assert.assertEquals(data.length, client.getData().decompressed().forPath("/a/b/c").length);
+ assertEquals(data.length, client.getData().decompressed().forPath("/a/b/c").length);
}
finally
{
@@ -118,8 +122,8 @@
client.create().compressed().creatingParentsIfNeeded().forPath("/a/b/c", data);
- Assert.assertNotEquals(data, client.getData().forPath("/a/b/c"));
- Assert.assertEquals(data.length, client.getData().decompressed().forPath("/a/b/c").length);
+ assertNotEquals(data, client.getData().forPath("/a/b/c"));
+ assertEquals(data.length, client.getData().decompressed().forPath("/a/b/c").length);
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionNew.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionNew.java
index d302119..7fe2823 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionNew.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionNew.java
@@ -18,14 +18,16 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.transaction.CuratorOp;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class TestCompressionInTransactionNew extends BaseClassForTests
{
@@ -43,12 +45,12 @@
//Create uncompressed data in a transaction
CuratorOp op = client.transactionOp().create().forPath(path, data);
client.transaction().forOperations(op);
- Assert.assertEquals(data, client.getData().forPath(path));
+ assertArrayEquals(data, client.getData().forPath(path));
//Create compressed data in transaction
op = client.transactionOp().setData().compressed().forPath(path, data);
client.transaction().forOperations(op);
- Assert.assertEquals(data, client.getData().decompressed().forPath(path));
+ assertArrayEquals(data, client.getData().decompressed().forPath(path));
}
finally
{
@@ -76,18 +78,18 @@
client.transaction().forOperations(op1, op2);
//Check they exist
- Assert.assertNotNull(client.checkExists().forPath(path1));
- Assert.assertNotNull(client.checkExists().forPath(path2));
+ assertNotNull(client.checkExists().forPath(path1));
+ assertNotNull(client.checkExists().forPath(path2));
//Set the nodes, path1 compressed, path2 uncompressed.
op1 = client.transactionOp().setData().compressed().forPath(path1, data1);
op2 = client.transactionOp().setData().forPath(path2, data2);
client.transaction().forOperations(op1, op2);
- Assert.assertNotEquals(data1, client.getData().forPath(path1));
- Assert.assertEquals(data1, client.getData().decompressed().forPath(path1));
+ assertNotEquals(data1, client.getData().forPath(path1));
+ assertArrayEquals(data1, client.getData().decompressed().forPath(path1));
- Assert.assertEquals(data2, client.getData().forPath(path2));
+ assertArrayEquals(data2, client.getData().forPath(path2));
}
finally
{
@@ -114,11 +116,11 @@
client.transaction().forOperations(op1, op2);
- Assert.assertNotEquals(data1, client.getData().forPath(path1));
- Assert.assertEquals(data1, client.getData().decompressed().forPath(path1));
+ assertNotEquals(data1, client.getData().forPath(path1));
+ assertArrayEquals(data1, client.getData().decompressed().forPath(path1));
- Assert.assertNotEquals(data2, client.getData().forPath(path2));
- Assert.assertEquals(data2, client.getData().decompressed().forPath(path2));
+ assertNotEquals(data2, client.getData().forPath(path2));
+ assertArrayEquals(data2, client.getData().decompressed().forPath(path2));
}
finally
{
@@ -149,10 +151,10 @@
CuratorOp op2 = client.transactionOp().create().forPath(path2, data2);
client.transaction().forOperations(op1, op2);
- Assert.assertNotEquals(data1, client.getData().forPath(path1));
- Assert.assertEquals(data1, client.getData().decompressed().forPath(path1));
+ assertNotEquals(data1, client.getData().forPath(path1));
+ assertArrayEquals(data1, client.getData().decompressed().forPath(path1));
- Assert.assertEquals(data2, client.getData().forPath(path2));
+ assertArrayEquals(data2, client.getData().forPath(path2));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionOld.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionOld.java
index ebf591b..9de1afb 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionOld.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCompressionInTransactionOld.java
@@ -18,16 +18,16 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.api.CompressionProvider;
import org.apache.curator.retry.RetryOneTime;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("deprecation")
public class TestCompressionInTransactionOld extends BaseClassForTests
@@ -45,11 +45,11 @@
//Create uncompressed data in a transaction
client.inTransaction().create().forPath(path, data).and().commit();
- Assert.assertEquals(data, client.getData().forPath(path));
+ assertArrayEquals(data, client.getData().forPath(path));
//Create compressed data in transaction
client.inTransaction().setData().compressed().forPath(path, data).and().commit();
- Assert.assertEquals(data, client.getData().decompressed().forPath(path));
+ assertArrayEquals(data, client.getData().decompressed().forPath(path));
}
finally
{
@@ -76,17 +76,17 @@
create().forPath(path2).and().commit();
//Check they exist
- Assert.assertNotNull(client.checkExists().forPath(path1));
- Assert.assertNotNull(client.checkExists().forPath(path2));
+ assertNotNull(client.checkExists().forPath(path1));
+ assertNotNull(client.checkExists().forPath(path2));
//Set the nodes, path1 compressed, path2 uncompressed.
client.inTransaction().setData().compressed().forPath(path1, data1).and().
setData().forPath(path2, data2).and().commit();
- Assert.assertNotEquals(data1, client.getData().forPath(path1));
- Assert.assertEquals(data1, client.getData().decompressed().forPath(path1));
+ assertNotEquals(data1, client.getData().forPath(path1));
+ assertArrayEquals(data1, client.getData().decompressed().forPath(path1));
- Assert.assertEquals(data2, client.getData().forPath(path2));
+ assertArrayEquals(data2, client.getData().forPath(path2));
}
finally
{
@@ -111,11 +111,11 @@
client.inTransaction().create().compressed().forPath(path1, data1).and().
create().compressed().forPath(path2, data2).and().commit();
- Assert.assertNotEquals(data1, client.getData().forPath(path1));
- Assert.assertEquals(data1, client.getData().decompressed().forPath(path1));
+ assertNotEquals(data1, client.getData().forPath(path1));
+ assertArrayEquals(data1, client.getData().decompressed().forPath(path1));
- Assert.assertNotEquals(data2, client.getData().forPath(path2));
- Assert.assertEquals(data2, client.getData().decompressed().forPath(path2));
+ assertNotEquals(data2, client.getData().forPath(path2));
+ assertArrayEquals(data2, client.getData().decompressed().forPath(path2));
}
finally
{
@@ -145,10 +145,10 @@
client.inTransaction().create().compressed().forPath(path1, data1).and().
create().forPath(path2, data2).and().commit();
- Assert.assertNotEquals(data1, client.getData().forPath(path1));
- Assert.assertEquals(data1, client.getData().decompressed().forPath(path1));
+ assertNotEquals(data1, client.getData().forPath(path1));
+ assertArrayEquals(data1, client.getData().decompressed().forPath(path1));
- Assert.assertEquals(data2, client.getData().forPath(path2));
+ assertArrayEquals(data2, client.getData().forPath(path2));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreate.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreate.java
index 3236574..b8068a6 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreate.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreate.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.framework.imps;
+import static org.apache.zookeeper.ZooDefs.Ids.ANYONE_ID_UNSAFE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.ACLProvider;
@@ -30,16 +35,14 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import static org.apache.zookeeper.ZooDefs.Ids.ANYONE_ID_UNSAFE;
-
public class TestCreate extends BaseClassForTests
{
private static final List<ACL> READ_CREATE = Collections.singletonList(new ACL(ZooDefs.Perms.CREATE | ZooDefs.Perms.READ, ANYONE_ID_UNSAFE));
@@ -91,9 +94,9 @@
List<ACL> acl = Collections.singletonList(new ACL(ZooDefs.Perms.CREATE | ZooDefs.Perms.READ, ANYONE_ID_UNSAFE));
client.create().creatingParentsIfNeeded().withACL(acl).forPath(path);
List<ACL> actual_bar_foo = client.getACL().forPath(path);
- Assert.assertEquals(actual_bar_foo, acl);
+ assertEquals(actual_bar_foo, acl);
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, ZooDefs.Ids.OPEN_ACL_UNSAFE);
+ assertEquals(actual_bar, ZooDefs.Ids.OPEN_ACL_UNSAFE);
}
finally
{
@@ -113,9 +116,9 @@
List<ACL> acl = Collections.singletonList(new ACL(ZooDefs.Perms.CREATE | ZooDefs.Perms.READ, ANYONE_ID_UNSAFE));
client.create().creatingParentsIfNeeded().withACL(acl, true).forPath(path);
List<ACL> actual_bar_foo = client.getACL().forPath(path);
- Assert.assertEquals(actual_bar_foo, acl);
+ assertEquals(actual_bar_foo, acl);
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, acl);
+ assertEquals(actual_bar, acl);
}
finally
{
@@ -145,11 +148,11 @@
}
};
client.create().creatingParentsIfNeeded().withACL(acl).inBackground(callback).forPath(path);
- Assert.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
+ assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
List<ACL> actual_bar_foo = client.getACL().forPath(path);
- Assert.assertEquals(actual_bar_foo, acl);
+ assertEquals(actual_bar_foo, acl);
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, ZooDefs.Ids.OPEN_ACL_UNSAFE);
+ assertEquals(actual_bar, ZooDefs.Ids.OPEN_ACL_UNSAFE);
}
finally
{
@@ -176,11 +179,11 @@
}
};
client.create().creatingParentsIfNeeded().withACL(acl, true).inBackground(callback).forPath(path);
- Assert.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
+ assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
List<ACL> actual_bar_foo = client.getACL().forPath(path);
- Assert.assertEquals(actual_bar_foo, acl);
+ assertEquals(actual_bar_foo, acl);
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, acl);
+ assertEquals(actual_bar, acl);
}
finally
{
@@ -202,11 +205,11 @@
String path = "/bar/foo/boo";
client.create().creatingParentsIfNeeded().forPath(path);
List<ACL> actual_bar_foo_boo = client.getACL().forPath("/bar/foo/boo");
- Assert.assertEquals(actual_bar_foo_boo, ZooDefs.Ids.OPEN_ACL_UNSAFE);
+ assertEquals(actual_bar_foo_boo, ZooDefs.Ids.OPEN_ACL_UNSAFE);
List<ACL> actual_bar_foo = client.getACL().forPath("/bar/foo");
- Assert.assertEquals(actual_bar_foo, READ_CREATE_WRITE);
+ assertEquals(actual_bar_foo, READ_CREATE_WRITE);
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, READ_CREATE);
+ assertEquals(actual_bar, READ_CREATE);
}
finally
{
@@ -237,13 +240,13 @@
final String path = "/bar/foo/boo";
client.create().creatingParentsIfNeeded().inBackground(callback).forPath(path);
- Assert.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
+ assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
List<ACL> actual_bar_foo_boo = client.getACL().forPath(path);
- Assert.assertEquals(actual_bar_foo_boo, ZooDefs.Ids.OPEN_ACL_UNSAFE);
+ assertEquals(actual_bar_foo_boo, ZooDefs.Ids.OPEN_ACL_UNSAFE);
List<ACL> actual_bar_foo = client.getACL().forPath("/bar/foo");
- Assert.assertEquals(actual_bar_foo, READ_CREATE_WRITE);
+ assertEquals(actual_bar_foo, READ_CREATE_WRITE);
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, READ_CREATE);
+ assertEquals(actual_bar, READ_CREATE);
}
finally
{
@@ -262,18 +265,18 @@
client.start();
client.blockUntilConnected();
client.create().forPath("/parent");
- Assert.assertEquals(client.getChildren().forPath("/parent").size(), 0);
+ assertEquals(client.getChildren().forPath("/parent").size(), 0);
client.create().withProtection().withMode(CreateMode.EPHEMERAL).forPath("/parent/test");
final List<String> children = client.getChildren().forPath("/parent");
- Assert.assertEquals(1, children.size());
+ assertEquals(1, children.size());
final String testZNodeName = children.get(0);
- Assert.assertEquals(testZNodeName.length(), ProtectedUtils.PROTECTED_PREFIX_WITH_UUID_LENGTH + "test".length());
- Assert.assertTrue(testZNodeName.startsWith(ProtectedUtils.PROTECTED_PREFIX));
- Assert.assertEquals(testZNodeName.charAt(ProtectedUtils.PROTECTED_PREFIX_WITH_UUID_LENGTH - 1), ProtectedUtils.PROTECTED_SEPARATOR);
- Assert.assertTrue(ProtectedUtils.isProtectedZNode(testZNodeName));
- Assert.assertEquals(ProtectedUtils.normalize(testZNodeName), "test");
- Assert.assertFalse(ProtectedUtils.isProtectedZNode("parent"));
- Assert.assertEquals(ProtectedUtils.normalize("parent"), "parent");
+ assertEquals(testZNodeName.length(), ProtectedUtils.PROTECTED_PREFIX_WITH_UUID_LENGTH + "test".length());
+ assertTrue(testZNodeName.startsWith(ProtectedUtils.PROTECTED_PREFIX));
+ assertEquals(testZNodeName.charAt(ProtectedUtils.PROTECTED_PREFIX_WITH_UUID_LENGTH - 1), ProtectedUtils.PROTECTED_SEPARATOR);
+ assertTrue(ProtectedUtils.isProtectedZNode(testZNodeName));
+ assertEquals(ProtectedUtils.normalize(testZNodeName), "test");
+ assertFalse(ProtectedUtils.isProtectedZNode("parent"));
+ assertEquals(ProtectedUtils.normalize("parent"), "parent");
}
}
@@ -281,28 +284,28 @@
public void testProtectedUtils() throws Exception
{
String name = "_c_53345f98-9423-4e0c-a7b5-9f819e3ec2e1-yo";
- Assert.assertTrue(ProtectedUtils.isProtectedZNode(name));
- Assert.assertEquals(ProtectedUtils.normalize(name), "yo");
- Assert.assertEquals(ProtectedUtils.extractProtectedId(name).get(), "53345f98-9423-4e0c-a7b5-9f819e3ec2e1");
+ assertTrue(ProtectedUtils.isProtectedZNode(name));
+ assertEquals(ProtectedUtils.normalize(name), "yo");
+ assertEquals(ProtectedUtils.extractProtectedId(name).get(), "53345f98-9423-4e0c-a7b5-9f819e3ec2e1");
name = "c_53345f98-9423-4e0c-a7b5-9f819e3ec2e1-yo";
- Assert.assertFalse(ProtectedUtils.isProtectedZNode(name));
- Assert.assertEquals(ProtectedUtils.normalize(name), name);
- Assert.assertEquals(ProtectedUtils.extractProtectedId(name), Optional.<String>empty());
+ assertFalse(ProtectedUtils.isProtectedZNode(name));
+ assertEquals(ProtectedUtils.normalize(name), name);
+ assertEquals(ProtectedUtils.extractProtectedId(name), Optional.<String>empty());
name = "_c_53345f98-hola-4e0c-a7b5-9f819e3ec2e1-yo";
- Assert.assertFalse(ProtectedUtils.isProtectedZNode(name));
- Assert.assertEquals(ProtectedUtils.normalize(name), name);
- Assert.assertEquals(ProtectedUtils.extractProtectedId(name), Optional.<String>empty());
+ assertFalse(ProtectedUtils.isProtectedZNode(name));
+ assertEquals(ProtectedUtils.normalize(name), name);
+ assertEquals(ProtectedUtils.extractProtectedId(name), Optional.<String>empty());
name = "_c_53345f98-hola-4e0c-a7b5-9f819e3ec2e1+yo";
- Assert.assertFalse(ProtectedUtils.isProtectedZNode(name));
- Assert.assertEquals(ProtectedUtils.normalize(name), name);
- Assert.assertEquals(ProtectedUtils.extractProtectedId(name), Optional.<String>empty());
+ assertFalse(ProtectedUtils.isProtectedZNode(name));
+ assertEquals(ProtectedUtils.normalize(name), name);
+ assertEquals(ProtectedUtils.extractProtectedId(name), Optional.<String>empty());
name = "_c_53345f98-9423-4e0c-a7b5-9f819e3ec2e1-yo";
- Assert.assertEquals(name, ProtectedUtils.toProtectedZNode("yo", "53345f98-9423-4e0c-a7b5-9f819e3ec2e1"));
- Assert.assertEquals("yo", ProtectedUtils.toProtectedZNode("yo", null));
+ assertEquals(name, ProtectedUtils.toProtectedZNode("yo", "53345f98-9423-4e0c-a7b5-9f819e3ec2e1"));
+ assertEquals("yo", ProtectedUtils.toProtectedZNode("yo", null));
String path = ZKPaths.makePath("hola", "yo");
- Assert.assertEquals(ProtectedUtils.toProtectedZNodePath(path, "53345f98-9423-4e0c-a7b5-9f819e3ec2e1"), ZKPaths.makePath("hola", name));
- Assert.assertEquals(ProtectedUtils.toProtectedZNodePath(path, null), path);
+ assertEquals(ProtectedUtils.toProtectedZNodePath(path, "53345f98-9423-4e0c-a7b5-9f819e3ec2e1"), ZKPaths.makePath("hola", name));
+ assertEquals(ProtectedUtils.toProtectedZNodePath(path, null), path);
path = ZKPaths.makePath("hola", name);
- Assert.assertEquals(ProtectedUtils.normalizePath(path), "/hola/yo");
+ assertEquals(ProtectedUtils.normalizePath(path), "/hola/yo");
}
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java
index 10b237f..da60ba6 100755
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.BackgroundCallback;
@@ -28,8 +33,8 @@
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.data.Stat;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
@@ -48,7 +53,7 @@
{
Stat queriedStat = client.checkExists().forPath(path);
- Assert.assertEquals(queriedStat, expected);
+ assertEquals(queriedStat, expected);
}
@Test
@@ -62,22 +67,22 @@
final Stat versionZeroStat = new Stat();
client.create().orSetData().storingStatIn(versionZeroStat).forPath(path);
- Assert.assertEquals(0, versionZeroStat.getVersion());
+ assertEquals(0, versionZeroStat.getVersion());
final Stat versionOneStat = new Stat();
client.create().orSetData().storingStatIn(versionOneStat).forPath(path);
- Assert.assertEquals(versionZeroStat.getAversion(), versionOneStat.getAversion());
- Assert.assertEquals(versionZeroStat.getCtime(), versionOneStat.getCtime());
- Assert.assertEquals(versionZeroStat.getCversion(), versionOneStat.getCversion());
- Assert.assertEquals(versionZeroStat.getCzxid(), versionOneStat.getCzxid());
- Assert.assertEquals(versionZeroStat.getDataLength(), versionOneStat.getDataLength());
- Assert.assertEquals(versionZeroStat.getEphemeralOwner(), versionOneStat.getEphemeralOwner());
- Assert.assertTrue(versionZeroStat.getMtime() <= versionOneStat.getMtime());
- Assert.assertNotEquals(versionZeroStat.getMzxid(), versionOneStat.getMzxid());
- Assert.assertEquals(versionZeroStat.getNumChildren(), versionOneStat.getNumChildren());
- Assert.assertEquals(versionZeroStat.getPzxid(), versionOneStat.getPzxid());
- Assert.assertEquals(1, versionOneStat.getVersion());
+ assertEquals(versionZeroStat.getAversion(), versionOneStat.getAversion());
+ assertEquals(versionZeroStat.getCtime(), versionOneStat.getCtime());
+ assertEquals(versionZeroStat.getCversion(), versionOneStat.getCversion());
+ assertEquals(versionZeroStat.getCzxid(), versionOneStat.getCzxid());
+ assertEquals(versionZeroStat.getDataLength(), versionOneStat.getDataLength());
+ assertEquals(versionZeroStat.getEphemeralOwner(), versionOneStat.getEphemeralOwner());
+ assertTrue(versionZeroStat.getMtime() <= versionOneStat.getMtime());
+ assertNotEquals(versionZeroStat.getMzxid(), versionOneStat.getMzxid());
+ assertEquals(versionZeroStat.getNumChildren(), versionOneStat.getNumChildren());
+ assertEquals(versionZeroStat.getPzxid(), versionOneStat.getPzxid());
+ assertEquals(1, versionOneStat.getVersion());
}
}
@@ -212,7 +217,7 @@
if(!timing.awaitLatch(latch))
{
- Assert.fail("Timed out awaing latch");
+ fail("Timed out awaing latch");
}
compare(client, path, statRef.get());
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java
index 1656351..92f3748 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -30,10 +33,10 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -45,7 +48,7 @@
private CuratorFramework client;
private BlockingQueue<ConnectionState> states;
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -71,7 +74,7 @@
client.getConnectionStateListenable().addListener(listener);
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -88,18 +91,18 @@
@Test
public void testResetCausesLost() throws Exception
{
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
client.checkExists().forPath("/"); // establish initial connection
client.getZookeeperClient().reset();
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
}
@Test
public void testInjectedWatchedEvent() throws Exception
{
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
final CountDownLatch latch = new CountDownLatch(1);
Watcher watcher = new Watcher()
@@ -118,24 +121,24 @@
};
client.checkExists().usingWatcher(watcher).forPath("/");
server.stop();
- Assert.assertTrue(timing.forSessionSleep().awaitLatch(latch));
+ assertTrue(timing.forSessionSleep().awaitLatch(latch));
}
@Test
public void testKillSession() throws Exception
{
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
+ assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
}
@Test
public void testReconnectWithoutExpiration() throws Exception
{
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
server.stop();
try
{
@@ -144,33 +147,33 @@
catch ( KeeperException.ConnectionLossException ignore )
{
}
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
server.restart();
client.checkExists().forPath("/");
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
}
@Test
public void testSessionExpirationFromTimeout() throws Exception
{
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
server.stop();
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
- Assert.assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+ assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
}
@Test
public void testSessionExpirationFromTimeoutWithRestart() throws Exception
{
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
server.stop();
timing.forSessionSleep().sleep();
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
- Assert.assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+ assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
server.restart();
client.checkExists().forPath("/");
- Assert.assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
+ assertEquals(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
- Assert.assertNull(states.poll(timing.multiple(.5).milliseconds(), TimeUnit.MILLISECONDS)); // there should be no other events
+ assertNull(states.poll(timing.multiple(.5).milliseconds(), TimeUnit.MILLISECONDS)); // there should be no other events
}
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java
index a4397ab..3943efa 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java
@@ -18,14 +18,16 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.EnsureContainers;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class TestEnsureContainers extends BaseClassForTests
{
@@ -40,7 +42,7 @@
EnsureContainers ensureContainers = new EnsureContainers(client, "/one/two/three");
ensureContainers.ensure();
- Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
+ assertNotNull(client.checkExists().forPath("/one/two/three"));
}
finally
{
@@ -59,11 +61,11 @@
EnsureContainers ensureContainers = new EnsureContainers(client, "/one/two/three");
ensureContainers.ensure();
- Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
+ assertNotNull(client.checkExists().forPath("/one/two/three"));
client.delete().forPath("/one/two/three");
ensureContainers.ensure();
- Assert.assertNull(client.checkExists().forPath("/one/two/three"));
+ assertNull(client.checkExists().forPath("/one/two/three"));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestExistsBuilder.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestExistsBuilder.java
index 8557e64..54704ab 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestExistsBuilder.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestExistsBuilder.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.imps;
+import static org.apache.zookeeper.ZooDefs.Ids.ANYONE_ID_UNSAFE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.ACLProvider;
@@ -28,17 +32,13 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import static org.apache.zookeeper.ZooDefs.Ids.ANYONE_ID_UNSAFE;
-import static org.testng.Assert.assertNull;
-
public class TestExistsBuilder extends BaseClassForTests {
/**
@@ -57,9 +57,9 @@
List<ACL> acl = Collections.singletonList(new ACL(ZooDefs.Perms.CREATE | ZooDefs.Perms.READ, ANYONE_ID_UNSAFE));
assertNull(client.checkExists().creatingParentsIfNeeded().withACL(acl).forPath(path));
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, acl);
+ assertEquals(actual_bar, acl);
List<ACL> actual_bar_foo = client.getACL().forPath("/bar/foo");
- Assert.assertEquals(actual_bar_foo, acl);
+ assertEquals(actual_bar_foo, acl);
}
finally
{
@@ -86,11 +86,11 @@
}
};
client.checkExists().creatingParentsIfNeeded().withACL(acl).inBackground(callback).forPath(path);
- Assert.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
+ assertTrue(latch.await(2000, TimeUnit.MILLISECONDS), "Callback not invoked");
List<ACL> actual_bar = client.getACL().forPath("/bar");
- Assert.assertEquals(actual_bar, acl);
+ assertEquals(actual_bar, acl);
List<ACL> actual_bar_foo = client.getACL().forPath("/bar/foo");
- Assert.assertEquals(actual_bar_foo, acl);
+ assertEquals(actual_bar_foo, acl);
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java
index 50692d2..4ce804a 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java
@@ -18,6 +18,12 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.BackgroundCallback;
@@ -31,8 +37,7 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NoNodeException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
@@ -71,26 +76,26 @@
client.getConnectionStateListenable().addListener(listener);
server.stop();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
try
{
client.delete().guaranteed().forPath("/test-me");
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e )
{
// expected
}
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
timing.sleepABit();
server.restart();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
timing.sleepABit();
- Assert.assertNull(client.checkExists().forPath("/test-me"));
+ assertNull(client.checkExists().forPath("/test-me"));
}
finally
{
@@ -134,26 +139,26 @@
client.getConnectionStateListenable().addListener(listener);
server.stop();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
try
{
client.delete().guaranteed().forPath("/test-me");
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e )
{
// expected
}
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
timing.sleepABit();
server.restart();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
timing.sleepABit();
- Assert.assertNull(client.checkExists().forPath("/test-me"));
+ assertNull(client.checkExists().forPath("/test-me"));
}
finally
{
@@ -197,26 +202,26 @@
namespaceClient.getConnectionStateListenable().addListener(listener);
server.stop();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
try
{
namespaceClient.delete().guaranteed().forPath("/test-me");
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e )
{
// expected
}
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
timing.sleepABit();
server.restart();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
timing.sleepABit();
- Assert.assertNull(namespaceClient.checkExists().forPath("/test-me"));
+ assertNull(namespaceClient.checkExists().forPath("/test-me"));
}
finally
{
@@ -237,13 +242,13 @@
try
{
client.create().creatingParentsIfNeeded().forPath(PATH);
- Assert.assertNotNull(client.checkExists().forPath(PATH));
+ assertNotNull(client.checkExists().forPath(PATH));
server.stop(); // cause the next delete to fail
try
{
client.delete().forPath(PATH);
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e )
{
@@ -251,13 +256,13 @@
}
server.restart();
- Assert.assertNotNull(client.checkExists().forPath(PATH));
+ assertNotNull(client.checkExists().forPath(PATH));
server.stop(); // cause the next delete to fail
try
{
client.delete().guaranteed().forPath(PATH);
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e )
{
@@ -274,7 +279,7 @@
timing.sleepABit();
}
}
- Assert.assertNull(client.checkExists().forPath(PATH));
+ assertNull(client.checkExists().forPath(PATH));
}
finally
{
@@ -303,12 +308,12 @@
try
{
client.delete().guaranteed().forPath("/nonexistent");
- Assert.fail();
+ fail();
}
catch(NoNodeException e)
{
//Exception is expected, the delete should not be retried
- Assert.assertFalse(pathAdded.get());
+ assertFalse(pathAdded.get());
}
finally
{
@@ -354,7 +359,7 @@
backgroundLatch.await();
//Exception is expected, the delete should not be retried
- Assert.assertFalse(pathAdded.get());
+ assertFalse(pathAdded.get());
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
index db4a9a5..a1aea52 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
@@ -18,6 +18,13 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Lists;
import org.apache.curator.framework.AuthInfo;
import org.apache.curator.framework.CuratorFramework;
@@ -45,10 +52,11 @@
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Stat;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -59,10 +67,10 @@
import java.util.concurrent.TimeUnit;
@SuppressWarnings("deprecation")
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestFramework extends BaseClassForTests
{
- @BeforeMethod(alwaysRun = true)
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -70,7 +78,7 @@
super.setup();
}
- @AfterMethod(alwaysRun = true)
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -115,10 +123,10 @@
}
Integer polledValue = timeoutQueue.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertNotNull(polledValue);
- Assert.assertEquals(10064, polledValue.intValue());
+ assertNotNull(polledValue);
+ assertEquals(10064, polledValue.intValue());
}
-
+
@Test
public void testSessionLossWithLongTimeout() throws Exception
{
@@ -152,15 +160,15 @@
client.start();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
server.stop();
timing.sleepABit();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
server.restart();
- Assert.assertTrue(timing.awaitLatch(restartedLatch));
+ assertTrue(timing.awaitLatch(restartedLatch));
}
}
@@ -183,10 +191,10 @@
client.getConnectionStateListenable().addListener(listener);
client.start();
- Assert.assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.CONNECTED);
+ assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.CONNECTED);
server.stop();
- Assert.assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.SUSPENDED);
- Assert.assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.LOST);
+ assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.SUSPENDED);
+ assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.LOST);
}
finally
{
@@ -203,16 +211,16 @@
client.start();
String name = client.create().forPath("/hey", "there".getBytes());
- Assert.assertEquals(name, "/hey");
+ assertEquals(name, "/hey");
name = client.create().orSetData().forPath("/hey", "other".getBytes());
- Assert.assertEquals(name, "/hey");
- Assert.assertEquals(client.getData().forPath("/hey"), "other".getBytes());
+ assertEquals(name, "/hey");
+ assertArrayEquals(client.getData().forPath("/hey"), "other".getBytes());
name = client.create().orSetData().creatingParentsIfNeeded().forPath("/a/b/c", "there".getBytes());
- Assert.assertEquals(name, "/a/b/c");
+ assertEquals(name, "/a/b/c");
name = client.create().orSetData().creatingParentsIfNeeded().forPath("/a/b/c", "what".getBytes());
- Assert.assertEquals(name, "/a/b/c");
- Assert.assertEquals(client.getData().forPath("/a/b/c"), "what".getBytes());
+ assertEquals(name, "/a/b/c");
+ assertArrayEquals(client.getData().forPath("/a/b/c"), "what".getBytes());
final BlockingQueue<CuratorEvent> queue = new LinkedBlockingQueue<>();
BackgroundCallback backgroundCallback = new BackgroundCallback()
@@ -226,15 +234,15 @@
client.create().orSetData().inBackground(backgroundCallback).forPath("/a/b/c", "another".getBytes());
CuratorEvent event = queue.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertNotNull(event);
- Assert.assertEquals(event.getResultCode(), KeeperException.Code.OK.intValue());
- Assert.assertEquals(event.getType(), CuratorEventType.CREATE);
- Assert.assertEquals(event.getPath(), "/a/b/c");
- Assert.assertEquals(event.getName(), "/a/b/c");
+ assertNotNull(event);
+ assertEquals(event.getResultCode(), KeeperException.Code.OK.intValue());
+ assertEquals(event.getType(), CuratorEventType.CREATE);
+ assertEquals(event.getPath(), "/a/b/c");
+ assertEquals(event.getName(), "/a/b/c");
// callback should only be called once
CuratorEvent unexpectedEvent = queue.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertNull(unexpectedEvent);
+ assertNull(unexpectedEvent);
}
finally
{
@@ -264,8 +272,8 @@
client.delete().quietly().inBackground(backgroundCallback).forPath("/foo/bar/hey");
Integer code = rc.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertNotNull(code);
- Assert.assertEquals(code.intValue(), KeeperException.Code.OK.intValue());
+ assertNotNull(code);
+ assertEquals(code.intValue(), KeeperException.Code.OK.intValue());
}
finally
{
@@ -302,7 +310,7 @@
client.create().forPath("/base/child");
String path = new Timing2().takeFromQueue(queue);
- Assert.assertEquals(path, "/base");
+ assertEquals(path, "/base");
}
finally
{
@@ -336,7 +344,7 @@
client.checkExists().inBackground().forPath("/base");
String path = queue.poll(10, TimeUnit.SECONDS);
- Assert.assertEquals(path, "/base");
+ assertEquals(path, "/base");
client.getCuratorListenable().removeListener(listener);
@@ -350,7 +358,7 @@
};
client.getChildren().inBackground(callback).forPath("/base");
path = queue.poll(10, TimeUnit.SECONDS);
- Assert.assertEquals(path, "/base");
+ assertEquals(path, "/base");
}
finally
{
@@ -388,7 +396,7 @@
}
catch ( KeeperException.NoAuthException e )
{
- Assert.fail("Auth failed");
+ fail("Auth failed");
}
client.close();
@@ -402,7 +410,7 @@
try
{
client.setData().forPath("/test", "test".getBytes());
- Assert.fail("Should have failed with auth exception");
+ fail("Should have failed with auth exception");
}
catch ( KeeperException.NoAuthException e )
{
@@ -421,12 +429,12 @@
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.connectString(server.getConnectString())
.retryPolicy(new RetryOneTime(1));
- Assert.assertNull(builder.getAuthScheme());
- Assert.assertNull(builder.getAuthValue());
+ assertNull(builder.getAuthScheme());
+ assertNull(builder.getAuthValue());
builder = builder.authorization("digest", "me1:pass1".getBytes());
- Assert.assertEquals(builder.getAuthScheme(), "digest");
- Assert.assertEquals(builder.getAuthValue(), "me1:pass1".getBytes());
+ assertEquals(builder.getAuthScheme(), "digest");
+ assertArrayEquals(builder.getAuthValue(), "me1:pass1".getBytes());
}
@Test
@@ -464,7 +472,7 @@
}
catch ( KeeperException.NoAuthException e )
{
- Assert.fail("Auth failed");
+ fail("Auth failed");
}
client.close();
@@ -481,7 +489,7 @@
}
catch ( KeeperException.NoAuthException e )
{
- Assert.fail("Auth failed");
+ fail("Auth failed");
}
client.close();
@@ -495,7 +503,7 @@
try
{
client.setData().forPath("/test", "test".getBytes());
- Assert.fail("Should have failed with auth exception");
+ fail("Should have failed with auth exception");
}
catch ( KeeperException.NoAuthException e )
{
@@ -542,11 +550,11 @@
client.create().withACL(aclList).forPath("/test", "test".getBytes());
server.stop();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
try
{
client.checkExists().forPath("/");
- Assert.fail("Connection should be down");
+ fail("Connection should be down");
}
catch ( KeeperException.ConnectionLossException e )
{
@@ -560,7 +568,7 @@
}
catch ( KeeperException.NoAuthException e )
{
- Assert.fail("Auth failed");
+ fail("Auth failed");
}
}
finally
@@ -579,11 +587,11 @@
{
client.create().creatingParentsIfNeeded().forPath("/one/two/three", "foo".getBytes());
byte[] data = client.getData().forPath("/one/two/three");
- Assert.assertEquals(data, "foo".getBytes());
+ assertArrayEquals(data, "foo".getBytes());
client.create().creatingParentsIfNeeded().forPath("/one/two/another", "bar".getBytes());
data = client.getData().forPath("/one/two/another");
- Assert.assertEquals(data, "bar".getBytes());
+ assertArrayEquals(data, "bar".getBytes());
}
finally
{
@@ -609,14 +617,14 @@
client.start();
client.create().creatingParentContainersIfNeeded().forPath("/one/two/three", "foo".getBytes());
byte[] data = client.getData().forPath("/one/two/three");
- Assert.assertEquals(data, "foo".getBytes());
+ assertArrayEquals(data, "foo".getBytes());
client.delete().forPath("/one/two/three");
new Timing().sleepABit();
- Assert.assertNotNull(client.checkExists().forPath("/one/two"));
+ assertNotNull(client.checkExists().forPath("/one/two"));
new Timing().sleepABit();
- Assert.assertNotNull(client.checkExists().forPath("/one"));
+ assertNotNull(client.checkExists().forPath("/one"));
}
finally
{
@@ -639,14 +647,14 @@
client.start();
client.create().creatingParentContainersIfNeeded().forPath("/one/two/three", "foo".getBytes());
byte[] data = client.getData().forPath("/one/two/three");
- Assert.assertEquals(data, "foo".getBytes());
+ assertArrayEquals(data, "foo".getBytes());
client.delete().forPath("/one/two/three");
new Timing().sleepABit();
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
new Timing().sleepABit();
- Assert.assertNull(client.checkExists().forPath("/one"));
+ assertNull(client.checkExists().forPath("/one"));
}
finally
{
@@ -672,17 +680,17 @@
{
client.start();
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
client.create().creatingParentContainersIfNeeded().forPath("/one/two/three");
- Assert.assertNotNull(client.checkExists().forPath("/one/two"));
+ assertNotNull(client.checkExists().forPath("/one/two"));
client.delete().deletingChildrenIfNeeded().forPath("/one");
- Assert.assertNull(client.checkExists().forPath("/one"));
+ assertNull(client.checkExists().forPath("/one"));
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
client.checkExists().creatingParentContainersIfNeeded().forPath("/one/two/three");
- Assert.assertNotNull(client.checkExists().forPath("/one/two"));
- Assert.assertNull(client.checkExists().forPath("/one/two/three"));
+ assertNotNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two/three"));
}
finally
{
@@ -698,11 +706,11 @@
{
client.start();
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
client.checkExists().creatingParentContainersIfNeeded().forPath("/one/two/three");
- Assert.assertNotNull(client.checkExists().forPath("/one/two"));
- Assert.assertNull(client.checkExists().forPath("/one/two/three"));
- Assert.assertNull(client.checkExists().creatingParentContainersIfNeeded().forPath("/one/two/three"));
+ assertNotNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two/three"));
+ assertNull(client.checkExists().creatingParentContainersIfNeeded().forPath("/one/two/three"));
}
finally
{
@@ -718,7 +726,7 @@
{
client.start();
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
final CountDownLatch latch = new CountDownLatch(1);
BackgroundCallback callback = new BackgroundCallback()
@@ -730,10 +738,10 @@
}
};
client.checkExists().creatingParentContainersIfNeeded().inBackground(callback).forPath("/one/two/three");
- Assert.assertTrue(new Timing().awaitLatch(latch));
- Assert.assertNotNull(client.checkExists().forPath("/one/two"));
- Assert.assertNull(client.checkExists().forPath("/one/two/three"));
- Assert.assertNull(client.checkExists().creatingParentContainersIfNeeded().forPath("/one/two/three"));
+ assertTrue(new Timing().awaitLatch(latch));
+ assertNotNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two/three"));
+ assertNull(client.checkExists().creatingParentContainersIfNeeded().forPath("/one/two/three"));
}
finally
{
@@ -753,18 +761,18 @@
{
EnsurePath ensurePath = new EnsurePath("/pity/the/fool");
ensurePath.ensure(client.getZookeeperClient());
- Assert.assertNull(client.getZookeeperClient().getZooKeeper().exists("/jz/pity/the/fool", false));
+ assertNull(client.getZookeeperClient().getZooKeeper().exists("/jz/pity/the/fool", false));
ensurePath = client.newNamespaceAwareEnsurePath("/pity/the/fool");
ensurePath.ensure(client.getZookeeperClient());
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/jz/pity/the/fool", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/jz/pity/the/fool", false));
}
finally
{
CloseableUtils.closeQuietly(client);
}
}
-
+
@Test
public void testCreateContainersWithNamespace() throws Exception
{
@@ -776,16 +784,16 @@
client.start();
String path = "/path1/path2";
client.createContainers(path);
- Assert.assertNotNull(client.checkExists().forPath(path));
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/" + namespace + path, false));
+ assertNotNull(client.checkExists().forPath(path));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/" + namespace + path, false));
}
finally
{
CloseableUtils.closeQuietly(client);
}
}
-
-
+
+
@Test
public void testCreateContainersUsingNamespace() throws Exception
{
@@ -798,8 +806,8 @@
CuratorFramework nsClient = client.usingNamespace(namespace);
String path = "/path1/path2";
nsClient.createContainers(path);
- Assert.assertNotNull(nsClient.checkExists().forPath(path));
- Assert.assertNotNull(nsClient.getZookeeperClient().getZooKeeper().exists("/" + namespace + path, false));
+ assertNotNull(nsClient.checkExists().forPath(path));
+ assertNotNull(nsClient.getZookeeperClient().getZooKeeper().exists("/" + namespace + path, false));
}
finally
{
@@ -818,20 +826,20 @@
try
{
String actualPath = client.create().forPath("/test");
- Assert.assertEquals(actualPath, "/test");
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/" + namespace + "/test", false));
- Assert.assertNull(client.getZookeeperClient().getZooKeeper().exists("/test", false));
+ assertEquals(actualPath, "/test");
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/" + namespace + "/test", false));
+ assertNull(client.getZookeeperClient().getZooKeeper().exists("/test", false));
actualPath = client.usingNamespace(null).create().forPath("/non");
- Assert.assertEquals(actualPath, "/non");
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/non", false));
+ assertEquals(actualPath, "/non");
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/non", false));
client.create().forPath("/test/child", "hey".getBytes());
byte[] bytes = client.getData().forPath("/test/child");
- Assert.assertEquals(bytes, "hey".getBytes());
+ assertArrayEquals(bytes, "hey".getBytes());
bytes = client.usingNamespace(null).getData().forPath("/" + namespace + "/test/child");
- Assert.assertEquals(bytes, "hey".getBytes());
+ assertArrayEquals(bytes, "hey".getBytes());
}
finally
{
@@ -862,7 +870,7 @@
}
};
client.create().inBackground(callback).forPath("/head");
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
@@ -886,7 +894,7 @@
{
if ( event.getType() == CuratorEventType.SYNC )
{
- Assert.assertEquals(event.getPath(), "/head");
+ assertEquals(event.getPath(), "/head");
((CountDownLatch)event.getContext()).countDown();
}
}
@@ -894,11 +902,11 @@
);
client.create().forPath("/head");
- Assert.assertNotNull(client.checkExists().forPath("/head"));
+ assertNotNull(client.checkExists().forPath("/head"));
CountDownLatch latch = new CountDownLatch(1);
client.sync("/head", latch);
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
@@ -914,7 +922,7 @@
try
{
client.create().forPath("/head");
- Assert.assertNotNull(client.checkExists().forPath("/head"));
+ assertNotNull(client.checkExists().forPath("/head"));
final CountDownLatch latch = new CountDownLatch(1);
BackgroundCallback callback = new BackgroundCallback()
@@ -929,7 +937,7 @@
}
};
client.sync().inBackground(callback).forPath("/head");
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
@@ -953,7 +961,7 @@
{
if ( event.getType() == CuratorEventType.DELETE )
{
- Assert.assertEquals(event.getPath(), "/head");
+ assertEquals(event.getPath(), "/head");
((CountDownLatch)event.getContext()).countDown();
}
}
@@ -961,12 +969,12 @@
);
client.create().forPath("/head");
- Assert.assertNotNull(client.checkExists().forPath("/head"));
+ assertNotNull(client.checkExists().forPath("/head"));
CountDownLatch latch = new CountDownLatch(1);
client.delete().inBackground(latch).forPath("/head");
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
- Assert.assertNull(client.checkExists().forPath("/head"));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertNull(client.checkExists().forPath("/head"));
}
finally
{
@@ -990,7 +998,7 @@
{
if ( event.getType() == CuratorEventType.DELETE )
{
- Assert.assertEquals(event.getPath(), "/one/two");
+ assertEquals(event.getPath(), "/one/two");
((CountDownLatch)event.getContext()).countDown();
}
}
@@ -998,12 +1006,12 @@
);
client.create().creatingParentsIfNeeded().forPath("/one/two/three/four");
- Assert.assertNotNull(client.checkExists().forPath("/one/two/three/four"));
+ assertNotNull(client.checkExists().forPath("/one/two/three/four"));
CountDownLatch latch = new CountDownLatch(1);
client.delete().deletingChildrenIfNeeded().inBackground(latch).forPath("/one/two");
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertNull(client.checkExists().forPath("/one/two"));
}
finally
{
@@ -1019,9 +1027,9 @@
try
{
client.create().forPath("/head");
- Assert.assertNotNull(client.checkExists().forPath("/head"));
+ assertNotNull(client.checkExists().forPath("/head"));
client.delete().forPath("/head");
- Assert.assertNull(client.checkExists().forPath("/head"));
+ assertNull(client.checkExists().forPath("/head"));
}
finally
{
@@ -1039,9 +1047,9 @@
{
client.create().creatingParentsIfNeeded().forPath("/one/two/three/four/five/six", "foo".getBytes());
client.delete().deletingChildrenIfNeeded().forPath("/one/two/three/four/five");
- Assert.assertNull(client.checkExists().forPath("/one/two/three/four/five"));
+ assertNull(client.checkExists().forPath("/one/two/three/four/five"));
client.delete().deletingChildrenIfNeeded().forPath("/one/two");
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
}
finally
{
@@ -1059,9 +1067,9 @@
{
client.create().creatingParentsIfNeeded().forPath("/one/two/three/four/five/six", "foo".getBytes());
client.delete().guaranteed().deletingChildrenIfNeeded().forPath("/one/two/three/four/five");
- Assert.assertNull(client.checkExists().forPath("/one/two/three/four/five"));
+ assertNull(client.checkExists().forPath("/one/two/three/four/five"));
client.delete().guaranteed().deletingChildrenIfNeeded().forPath("/one/two");
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
}
finally
{
@@ -1084,7 +1092,7 @@
}
List<String> children = client.getChildren().forPath("/head");
- Assert.assertEquals(children.size(), 10);
+ assertEquals(children.size(), 10);
}
finally
{
@@ -1112,15 +1120,15 @@
{
if ( event.getType() == CuratorEventType.GET_DATA )
{
- Assert.assertEquals(event.getPath(), "/test");
- Assert.assertEquals(event.getData(), data1);
+ assertEquals(event.getPath(), "/test");
+ assertArrayEquals(event.getData(), data1);
((CountDownLatch)event.getContext()).countDown();
}
else if ( event.getType() == CuratorEventType.WATCHED )
{
if ( event.getWatchedEvent().getType() == Watcher.Event.EventType.NodeDataChanged )
{
- Assert.assertEquals(event.getPath(), "/test");
+ assertEquals(event.getPath(), "/test");
watchedLatch.countDown();
}
}
@@ -1132,12 +1140,12 @@
CountDownLatch backgroundLatch = new CountDownLatch(1);
client.getData().watched().inBackground(backgroundLatch).forPath("/test");
- Assert.assertTrue(backgroundLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(backgroundLatch.await(10, TimeUnit.SECONDS));
client.setData().forPath("/test", data2);
- Assert.assertTrue(watchedLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(watchedLatch.await(10, TimeUnit.SECONDS));
byte[] checkData = client.getData().forPath("/test");
- Assert.assertEquals(checkData, data2);
+ assertArrayEquals(checkData, data2);
}
finally
{
@@ -1161,7 +1169,7 @@
{
if ( event.getType() == CuratorEventType.CREATE )
{
- Assert.assertEquals(event.getPath(), "/test");
+ assertEquals(event.getPath(), "/test");
((CountDownLatch)event.getContext()).countDown();
}
}
@@ -1170,7 +1178,7 @@
CountDownLatch latch = new CountDownLatch(1);
client.create().inBackground(latch).forPath("/test", new byte[]{1, 2, 3});
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
@@ -1193,7 +1201,7 @@
client.start();
byte[] readBytes = client.getData().forPath("/test");
- Assert.assertEquals(writtenBytes, readBytes);
+ assertArrayEquals(writtenBytes, readBytes);
client.create().withMode(CreateMode.EPHEMERAL).forPath("/ghost", writtenBytes);
@@ -1202,29 +1210,29 @@
client.start();
readBytes = client.getData().forPath("/test");
- Assert.assertEquals(writtenBytes, readBytes);
+ assertArrayEquals(writtenBytes, readBytes);
Stat stat = client.checkExists().forPath("/ghost");
- Assert.assertNull(stat);
+ assertNull(stat);
String realPath = client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/pseq", writtenBytes);
- Assert.assertNotSame(realPath, "/pseq");
+ assertNotSame(realPath, "/pseq");
client.close();
client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
client.start();
readBytes = client.getData().forPath(realPath);
- Assert.assertEquals(writtenBytes, readBytes);
+ assertArrayEquals(writtenBytes, readBytes);
realPath = client.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/eseq", writtenBytes);
- Assert.assertNotSame(realPath, "/eseq");
+ assertNotSame(realPath, "/eseq");
client.close();
client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
client.start();
stat = client.checkExists().forPath(realPath);
- Assert.assertNull(stat);
+ assertNull(stat);
}
finally
{
@@ -1240,7 +1248,7 @@
try
{
String path = client.create().withMode(CreateMode.PERSISTENT).forPath("/test", new byte[]{1, 2, 3});
- Assert.assertEquals(path, "/test");
+ assertEquals(path, "/test");
}
finally
{
@@ -1258,7 +1266,7 @@
client.create().forPath("/test");
//This should create a node in the form of "/test/00000001"
String path = client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/test/");
- Assert.assertTrue(path.startsWith("/test/"));
+ assertTrue(path.startsWith("/test/"));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java
index c62a299..bbf052e 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java
@@ -19,6 +19,9 @@
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
@@ -36,11 +39,9 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.KeeperException.Code;
import org.apache.zookeeper.data.ACL;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
@@ -112,7 +113,7 @@
}
};
client.create().inBackground().withUnhandledErrorListener(listener).forPath("/foo");
- Assert.assertTrue(new Timing().awaitLatch(errorLatch));
+ assertTrue(new Timing().awaitLatch(errorLatch));
}
finally
{
@@ -157,10 +158,10 @@
server.restart();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
- Assert.assertFalse(firstListenerAction.get());
+ assertTrue(timing.awaitLatch(connectedLatch));
+ assertFalse(firstListenerAction.get());
ConnectionState firstconnectionState = firstListenerState.get();
- Assert.assertEquals(firstconnectionState, ConnectionState.CONNECTED, "First listener state MUST BE CONNECTED but is " + firstconnectionState);
+ assertEquals(firstconnectionState, ConnectionState.CONNECTED, "First listener state MUST BE CONNECTED but is " + firstconnectionState);
}
finally
{
@@ -206,7 +207,7 @@
for ( long elapsed : times.subList(1, times.size()) ) // first one isn't a retry
{
- Assert.assertTrue(elapsed >= SLEEP, elapsed + ": " + times);
+ assertTrue(elapsed >= SLEEP, elapsed + ": " + times);
}
}
finally
@@ -234,11 +235,11 @@
}
};
client.create().inBackground(callback).forPath("/one");
- Assert.assertEquals(paths.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), "/one");
+ assertEquals(paths.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), "/one");
client.create().inBackground(callback).forPath("/one/two");
- Assert.assertEquals(paths.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), "/one/two");
+ assertEquals(paths.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), "/one/two");
client.create().inBackground(callback).forPath("/one/two/three");
- Assert.assertEquals(paths.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), "/one/two/three");
+ assertEquals(paths.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), "/one/two/three");
}
finally
{
@@ -276,7 +277,7 @@
// Attempt to retrieve children list
client.getChildren().inBackground(curatorCallback).forPath("/");
// Check if the callback has been called with a correct return code
- Assert.assertTrue(timing.awaitLatch(latch), "Callback has not been called by curator !");
+ assertTrue(timing.awaitLatch(latch), "Callback has not been called by curator !");
}
finally
{
@@ -345,7 +346,7 @@
timing.sleepABit();
// should not generate an exception
- Assert.assertFalse(hadIllegalStateException.get());
+ assertFalse(hadIllegalStateException.get());
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
index 3e7754a..1fda248 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
@@ -19,6 +19,12 @@
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Queues;
import org.apache.curator.RetryPolicy;
import org.apache.curator.RetrySleeper;
@@ -47,11 +53,12 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.data.Stat;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@@ -65,19 +72,20 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestFrameworkEdges extends BaseClassForTests
{
private final Logger log = LoggerFactory.getLogger(getClass());
private final Timing2 timing = new Timing2();
- @BeforeClass
+ @BeforeAll
public static void setUpClass()
{
System.setProperty("zookeeper.extendedTypesEnabled", "true");
}
- @Test(description = "test case for CURATOR-525")
+ @Test
+ @DisplayName("test case for CURATOR-525")
public void testValidateConnectionEventRaces() throws Exception
{
// test for CURATOR-525 - there is a race whereby Curator can go to LOST
@@ -95,8 +103,8 @@
client.getConnectionStateListenable().addListener((__, newState) -> stateQueue.add(newState));
server.stop();
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.SUSPENDED);
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.LOST);
+ assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.SUSPENDED);
+ assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.LOST);
clientImpl.debugCheckBackgroundRetryReadyLatch = new CountDownLatch(1);
clientImpl.debugCheckBackgroundRetryLatch = new CountDownLatch(1);
@@ -104,12 +112,12 @@
client.delete().guaranteed().inBackground().forPath("/foo");
timing.awaitLatch(clientImpl.debugCheckBackgroundRetryReadyLatch);
server.restart();
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.RECONNECTED);
+ assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.RECONNECTED);
clientImpl.injectedCode = KeeperException.Code.SESSIONEXPIRED; // simulate an expiration being handled after the connection is repaired
clientImpl.debugCheckBackgroundRetryLatch.countDown();
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.LOST);
+ assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.LOST);
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.RECONNECTED);
+ assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.RECONNECTED);
}
}
@@ -129,7 +137,7 @@
};
client.checkExists().usingWatcher(watcher).forPath("/foobar");
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(timing.awaitLatch(expiredLatch));
+ assertTrue(timing.awaitLatch(expiredLatch));
}
}
@@ -192,13 +200,13 @@
builder.forPath("/test/hey");
- Assert.assertTrue(timing.awaitLatch(serverStoppedLatch));
+ assertTrue(timing.awaitLatch(serverStoppedLatch));
timing.forSessionSleep().sleep(); // wait for session to expire
cluster.restartServer(instanceSpec0);
String path = timing.takeFromQueue(createdNode);
List<String> children = client.getChildren().forPath("/test");
- Assert.assertEquals(Collections.singletonList(ZKPaths.getNodeFromPath(path)), children);
+ assertEquals(Collections.singletonList(ZKPaths.getNodeFromPath(path)), children);
}
}
}
@@ -232,7 +240,7 @@
client.create().inBackground(callback).forPath("/test/two");
server.restart();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
finally
{
@@ -268,7 +276,7 @@
client.start();
client.createContainers("/this/does/not/exist");
- Assert.assertNotNull(client.checkExists().forPath("/this/does/not/exist"));
+ assertNotNull(client.checkExists().forPath("/this/does/not/exist"));
}
finally
{
@@ -303,7 +311,7 @@
{
CuratorFramework localClient = (i == 0) ? client : client.usingNamespace("nm");
localClient.create().forPath("/parent");
- Assert.assertEquals(localClient.getChildren().forPath("/parent").size(), 0);
+ assertEquals(localClient.getChildren().forPath("/parent").size(), 0);
CreateBuilderImpl createBuilder = (CreateBuilderImpl)localClient.create();
createBuilder.failNextCreateForTesting = true;
@@ -311,7 +319,7 @@
try
{
createBuilder.withProtection().forPath("/parent/test");
- Assert.fail("failNextCreateForTesting should have caused a ConnectionLossException");
+ fail("failNextCreateForTesting should have caused a ConnectionLossException");
}
catch ( KeeperException.ConnectionLossException e )
{
@@ -320,7 +328,7 @@
timing.sleepABit();
List<String> children = localClient.getChildren().forPath("/parent");
- Assert.assertEquals(children.size(), 0, children.toString()); // protected mode should have deleted the node
+ assertEquals(children.size(), 0, children.toString()); // protected mode should have deleted the node
localClient.delete().forPath("/parent");
}
@@ -391,10 +399,10 @@
String name2 = timing.takeFromQueue(paths);
String path2 = timing.takeFromQueue(paths);
- Assert.assertEquals(ZKPaths.getPathAndNode(name1).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
- Assert.assertEquals(ZKPaths.getPathAndNode(name2).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
- Assert.assertEquals(ZKPaths.getPathAndNode(path1).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
- Assert.assertEquals(ZKPaths.getPathAndNode(path2).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
+ assertEquals(ZKPaths.getPathAndNode(name1).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
+ assertEquals(ZKPaths.getPathAndNode(name2).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
+ assertEquals(ZKPaths.getPathAndNode(path1).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
+ assertEquals(ZKPaths.getPathAndNode(path2).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
client.delete().deletingChildrenIfNeeded().forPath("/a/b/c");
client.delete().forPath("/a/b");
@@ -423,7 +431,7 @@
latch.countDown();
}
}).forPath("/");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
finally
{
@@ -457,12 +465,12 @@
server.stop();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
try
{
client.checkExists().forPath("/");
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException e )
{
@@ -491,7 +499,7 @@
}
catch ( NullPointerException e )
{
- Assert.fail();
+ fail();
}
}
finally
@@ -521,8 +529,8 @@
};
createBuilder.withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).inBackground(callback).forPath("/");
String ourPath = queue.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertTrue(ourPath.startsWith(ZKPaths.makePath("/", ProtectedUtils.PROTECTED_PREFIX)));
- Assert.assertFalse(createBuilder.failNextCreateForTesting);
+ assertTrue(ourPath.startsWith(ZKPaths.makePath("/", ProtectedUtils.PROTECTED_PREFIX)));
+ assertFalse(createBuilder.failNextCreateForTesting);
}
finally
{
@@ -540,8 +548,8 @@
CreateBuilderImpl createBuilder = (CreateBuilderImpl)client.create();
createBuilder.failNextCreateForTesting = true;
String ourPath = createBuilder.withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/");
- Assert.assertTrue(ourPath.startsWith(ZKPaths.makePath("/", ProtectedUtils.PROTECTED_PREFIX)));
- Assert.assertFalse(createBuilder.failNextCreateForTesting);
+ assertTrue(ourPath.startsWith(ZKPaths.makePath("/", ProtectedUtils.PROTECTED_PREFIX)));
+ assertFalse(createBuilder.failNextCreateForTesting);
}
finally
{
@@ -568,8 +576,8 @@
client.checkExists().usingWatcher(watcher).forPath("/sessionTest");
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(timing.awaitLatch(sessionDiedLatch));
- Assert.assertNotNull(client.checkExists().forPath("/sessionTest"));
+ assertTrue(timing.awaitLatch(sessionDiedLatch));
+ assertNotNull(client.checkExists().forPath("/sessionTest"));
}
finally
{
@@ -592,7 +600,7 @@
if ( event.getType() == CuratorEventType.EXISTS )
{
Stat stat = client.checkExists().forPath("/yo/yo/yo");
- Assert.assertNull(stat);
+ assertNull(stat);
client.create().inBackground(event.getContext()).forPath("/what");
}
@@ -605,7 +613,7 @@
CountDownLatch latch = new CountDownLatch(1);
client.checkExists().inBackground(latch).forPath("/hey");
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
@@ -639,7 +647,7 @@
server.stop();
client.checkExists().inBackground().forPath("/hey");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
finally
{
@@ -660,7 +668,7 @@
server.stop();
client.checkExists().forPath("/hey");
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException e )
{
@@ -717,7 +725,7 @@
// test foreground retry
client.checkExists().forPath("/hey");
- Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS), "Remaining leases: " + semaphore.availablePermits());
+ assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS), "Remaining leases: " + semaphore.availablePermits());
// make sure we're reconnected
client.getZookeeperClient().setRetryPolicy(new RetryOneTime(100));
@@ -731,7 +739,7 @@
// test background retry
client.checkExists().inBackground().forPath("/hey");
- Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS), "Remaining leases: " + semaphore.availablePermits());
+ assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS), "Remaining leases: " + semaphore.availablePermits());
}
finally
{
@@ -746,7 +754,7 @@
try
{
client.getData();
- Assert.fail();
+ fail();
}
catch ( Exception e )
{
@@ -754,7 +762,7 @@
}
catch ( Throwable e )
{
- Assert.fail("", e);
+ fail("", e);
}
}
@@ -775,7 +783,7 @@
try
{
client.getData();
- Assert.fail();
+ fail();
}
catch ( Exception e )
{
@@ -814,11 +822,11 @@
{
if ( e instanceof KeeperException.NoNodeException )
{
- Assert.fail("client delete failed, shouldn't throw NoNodeException", e);
+ fail("client delete failed, shouldn't throw NoNodeException", e);
}
else
{
- Assert.fail("unexpected exception", e);
+ fail("unexpected exception", e);
}
}
finally
@@ -858,18 +866,18 @@
}
catch ( Exception e )
{
- Assert.fail("unexpected exception", e);
+ fail("unexpected exception", e);
}
}
}
catch ( Exception e )
{
- Assert.fail("unexpected exception", e);
+ fail("unexpected exception", e);
}
}
- Assert.assertTrue(timing.awaitLatch(latch));
- Assert.assertNull(client2.checkExists().forPath("/parent"));
+ assertTrue(timing.awaitLatch(latch));
+ assertNull(client2.checkExists().forPath("/parent"));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestGzipCompressionProvider.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestGzipCompressionProvider.java
index 2856b4d..78c0bb2 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestGzipCompressionProvider.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestGzipCompressionProvider.java
@@ -18,9 +18,10 @@
*/
package org.apache.curator.framework.imps;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
@@ -36,9 +37,9 @@
byte[] data = "Hello, world!".getBytes();
byte[] compressedData = provider.compress(null, data);
byte[] jdkCompressedData = jdkCompress(data);
- Assert.assertTrue(Arrays.equals(compressedData, jdkCompressedData));
+ assertTrue(Arrays.equals(compressedData, jdkCompressedData));
byte[] decompressedData = provider.decompress(null, compressedData);
- Assert.assertTrue(Arrays.equals(decompressedData, data));
+ assertTrue(Arrays.equals(decompressedData, data));
}
@Test
@@ -49,10 +50,10 @@
byte[] compressedData2 = GzipCompressionProvider.doCompress(new byte[0]);
byte[] jdkCompress = jdkCompress(new byte[0]);
// Ensures GzipCompressionProvider.COMPRESSED_EMPTY_BYTES value is valid
- Assert.assertTrue(Arrays.equals(compressedData, compressedData2));
- Assert.assertTrue(Arrays.equals(compressedData, jdkCompress));
+ assertTrue(Arrays.equals(compressedData, compressedData2));
+ assertTrue(Arrays.equals(compressedData, jdkCompress));
byte[] decompressedData = provider.decompress(null, compressedData);
- Assert.assertEquals(0, decompressedData.length);
+ assertEquals(0, decompressedData.length);
}
/**
@@ -65,7 +66,7 @@
GzipCompressionProvider provider = new GzipCompressionProvider();
try {
provider.decompress(null, new byte[100]);
- Assert.fail("Expected IOException");
+ fail("Expected IOException");
} catch (IOException ignore) {
// expected
}
@@ -104,9 +105,9 @@
for (int i = 0; i < 100; i++) {
byte[] compressedData = provider.compress(null, data);
byte[] jdkCompressedData = jdkCompress(data);
- Assert.assertTrue(Arrays.equals(compressedData, jdkCompressedData));
+ assertTrue(Arrays.equals(compressedData, jdkCompressedData));
byte[] decompressedData = provider.decompress(null, compressedData);
- Assert.assertTrue(Arrays.equals(decompressedData, data));
+ assertTrue(Arrays.equals(decompressedData, data));
// in the end of the iteration to test empty array first
random.nextBytes(data);
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java
index de210ab..f4e0fdf 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -27,8 +29,8 @@
import org.apache.curator.framework.api.CuratorListener;
import org.apache.curator.retry.RetryOneTime;
import org.apache.zookeeper.Watcher;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -89,7 +91,7 @@
client2.sync().forPath("/test");
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java
index 9c1c99b..cd33cb6 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.Collections;
import java.util.List;
@@ -25,13 +30,11 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.retry.RetryOneTime;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.KeeperException.NoAuthException;
import org.apache.zookeeper.data.ACL;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class TestNamespaceFacade extends BaseClassForTests
{
@@ -41,7 +44,7 @@
try
{
CuratorFrameworkFactory.builder().namespace("/snafu").retryPolicy(new RetryOneTime(1)).connectString("foo").build();
- Assert.fail();
+ fail();
}
catch ( IllegalArgumentException e )
{
@@ -61,10 +64,10 @@
CuratorFramework fooClient = client.usingNamespace("foo");
CuratorFramework barClient = client.usingNamespace("bar");
- Assert.assertEquals(client.getNamespace(), "");
- Assert.assertEquals(client2.getNamespace(), "snafu");
- Assert.assertEquals(fooClient.getNamespace(), "foo");
- Assert.assertEquals(barClient.getNamespace(), "bar");
+ assertEquals(client.getNamespace(), "");
+ assertEquals(client2.getNamespace(), "snafu");
+ assertEquals(fooClient.getNamespace(), "foo");
+ assertEquals(barClient.getNamespace(), "bar");
}
finally
{
@@ -87,8 +90,8 @@
fooClient.create().forPath("/one");
barClient.create().forPath("/one");
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/foo/one", false));
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/bar/one", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/foo/one", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/bar/one", false));
}
finally
{
@@ -104,8 +107,8 @@
{
client.start();
- Assert.assertSame(client.usingNamespace("foo"), client.usingNamespace("foo"));
- Assert.assertNotSame(client.usingNamespace("foo"), client.usingNamespace("bar"));
+ assertSame(client.usingNamespace("foo"), client.usingNamespace("foo"));
+ assertNotSame(client.usingNamespace("foo"), client.usingNamespace("bar"));
}
finally
{
@@ -122,14 +125,14 @@
client.start();
client.create().forPath("/one");
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/one", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/one", false));
client.usingNamespace("space").create().forPath("/one");
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/space", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/space", false));
client.usingNamespace("name").create().forPath("/one");
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/name", false));
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/name/one", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/name", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/name/one", false));
}
finally
{
@@ -149,23 +152,23 @@
client.start();
client.create().forPath("/one");
- Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/one", false));
+ assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/one", false));
- Assert.assertNotNull(client.checkExists().forPath("/"));
+ assertNotNull(client.checkExists().forPath("/"));
try
{
client.checkExists().forPath("");
- Assert.fail("IllegalArgumentException expected");
+ fail("IllegalArgumentException expected");
}
catch ( IllegalArgumentException expected )
{
}
- Assert.assertNotNull(client.usingNamespace("one").checkExists().forPath("/"));
+ assertNotNull(client.usingNamespace("one").checkExists().forPath("/"));
try
{
client.usingNamespace("one").checkExists().forPath("");
- Assert.fail("IllegalArgumentException expected");
+ fail("IllegalArgumentException expected");
}
catch ( IllegalArgumentException expected )
{
@@ -185,10 +188,10 @@
client.start();
CuratorFramework namespaced = client.usingNamespace(null);
- Assert.assertEquals(client.getState(), namespaced.getState(), "Namespaced state did not match true state after call to start.");
+ assertEquals(client.getState(), namespaced.getState(), "Namespaced state did not match true state after call to start.");
client.close();
- Assert.assertEquals(client.getState(), namespaced.getState(), "Namespaced state did not match true state after call to close.");
+ assertEquals(client.getState(), namespaced.getState(), "Namespaced state did not match true state after call to close.");
}
/**
@@ -205,7 +208,7 @@
client.create().creatingParentsIfNeeded().forPath("/parent/child", "A string".getBytes());
CuratorFramework client2 = client.usingNamespace("parent");
- Assert.assertNotNull(client2.getData().forPath("/child"));
+ assertNotNull(client2.getData().forPath("/child"));
client.setACL().withACL(Collections.singletonList(
new ACL(ZooDefs.Perms.WRITE, ZooDefs.Ids.ANYONE_ID_UNSAFE))).
forPath("/parent/child");
@@ -215,14 +218,14 @@
try
{
List<ACL> acls = client2.getACL().forPath("/child");
- Assert.assertNotNull(acls);
- Assert.assertEquals(acls.size(), 1);
- Assert.assertEquals(acls.get(0).getId(), ZooDefs.Ids.ANYONE_ID_UNSAFE);
- Assert.assertEquals(acls.get(0).getPerms(), ZooDefs.Perms.WRITE);
+ assertNotNull(acls);
+ assertEquals(acls.size(), 1);
+ assertEquals(acls.get(0).getId(), ZooDefs.Ids.ANYONE_ID_UNSAFE);
+ assertEquals(acls.get(0).getPerms(), ZooDefs.Perms.WRITE);
client2.setACL().withACL(Collections.singletonList(
new ACL(ZooDefs.Perms.DELETE, ZooDefs.Ids.ANYONE_ID_UNSAFE))).
forPath("/child");
- Assert.fail("Expected auth exception was not thrown");
+ fail("Expected auth exception was not thrown");
}
catch(NoAuthException e)
{
@@ -235,7 +238,7 @@
CuratorFramework client = CuratorFrameworkFactory.builder().namespace("").retryPolicy(new RetryOneTime(1)).connectString("foo").build();
CuratorFrameworkImpl clientImpl = (CuratorFrameworkImpl) client;
- Assert.assertEquals(clientImpl.unfixForNamespace("/foo/bar"), "/foo/bar");
+ assertEquals(clientImpl.unfixForNamespace("/foo/bar"), "/foo/bar");
CloseableUtils.closeQuietly(client);
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java
index ecfd8b4..64ba576 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java
@@ -19,6 +19,7 @@
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Queues;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -27,8 +28,7 @@
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.Timing;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -58,9 +58,9 @@
client.create().inBackground().forPath("/");
ConnectionState polled = queue.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertEquals(polled, ConnectionState.SUSPENDED);
+ assertEquals(polled, ConnectionState.SUSPENDED);
polled = queue.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertEquals(polled, ConnectionState.LOST);
+ assertEquals(polled, ConnectionState.LOST);
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java
index b5f90ae..2af98b2 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java
@@ -19,6 +19,8 @@
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -32,10 +34,10 @@
import org.apache.curator.test.TestingCluster;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.Iterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
@@ -43,13 +45,13 @@
public class TestReadOnly extends BaseClassForTests
{
- @BeforeMethod
+ @BeforeEach
public void setup()
{
System.setProperty("readonlymode.enabled", "true");
}
- @AfterMethod
+ @AfterEach
public void tearDown()
{
System.setProperty("readonlymode.enabled", "false");
@@ -100,7 +102,7 @@
client.checkExists().forPath("/");
ConnectionState state = states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertEquals(state, ConnectionState.READ_ONLY);
+ assertEquals(state, ConnectionState.READ_ONLY);
}
finally
{
@@ -151,12 +153,12 @@
}
cluster.killServer(killInstance);
- Assert.assertEquals(reconnectedLatch.getCount(), 1);
- Assert.assertTrue(timing.awaitLatch(readOnlyLatch));
+ assertEquals(reconnectedLatch.getCount(), 1);
+ assertTrue(timing.awaitLatch(readOnlyLatch));
- Assert.assertEquals(reconnectedLatch.getCount(), 1);
+ assertEquals(reconnectedLatch.getCount(), 1);
cluster.restartServer(killInstance);
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
index 96fa384..435d17a 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
@@ -41,10 +41,11 @@
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj;
import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.InetAddress;
@@ -59,6 +60,11 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class TestReconfiguration extends CuratorTestBase
{
private final Timing2 timing = new Timing2();
@@ -68,7 +74,7 @@
private static final String superUserPasswordDigest = "curator-test:zghsj3JfJqK7DbWf0RQ1BgbJH9w="; // ran from DigestAuthenticationProvider.generateDigest(superUserPassword);
private static final String superUserPassword = "curator-test";
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -81,7 +87,7 @@
cluster = createAndStartCluster(3);
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -93,7 +99,8 @@
}
@SuppressWarnings("ConstantConditions")
- @Test(enabled = false)
+ @Test
+ @Disabled
public void testApiPermutations() throws Exception
{
// not an actual test. Specifies all possible API possibilities
@@ -172,7 +179,7 @@
QuorumVerifier quorumVerifier = toQuorumVerifier(configData);
System.out.println(quorumVerifier);
assertConfig(quorumVerifier, cluster.getInstances());
- Assert.assertEquals(EnsembleTracker.configToConnectionString(quorumVerifier), ensembleProvider.getConnectionString());
+ assertEquals(EnsembleTracker.configToConnectionString(quorumVerifier), ensembleProvider.getConnectionString());
}
}
@@ -182,7 +189,7 @@
final String initialClusterCS = cluster.getConnectString();
try ( CuratorFramework client = newClient(cluster.getConnectString(), false))
{
- Assert.assertEquals(((CuratorFrameworkImpl) client).getEnsembleTracker(), null);
+ assertEquals(((CuratorFrameworkImpl) client).getEnsembleTracker(), null);
client.start();
QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
@@ -195,16 +202,16 @@
client.reconfig().joining(toReconfigSpec(newCluster.getInstances())).fromConfig(oldConfig.getVersion()).forEnsemble();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
List<InstanceSpec> newInstances = Lists.newArrayList(cluster.getInstances());
newInstances.addAll(newCluster.getInstances());
assertConfig(newConfig, newInstances);
- Assert.assertEquals(ensembleProvider.getConnectionString(), initialClusterCS);
- Assert.assertNotEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
- Assert.assertEquals(client.getZookeeperClient().getCurrentConnectionString(), initialClusterCS);
+ assertEquals(ensembleProvider.getConnectionString(), initialClusterCS);
+ assertNotEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertEquals(client.getZookeeperClient().getCurrentConnectionString(), initialClusterCS);
final CountDownLatch reconnectLatch = new CountDownLatch(1);
client.getConnectionStateListenable().addListener(
(cfClient, newState) -> {
@@ -212,11 +219,11 @@
}
);
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(reconnectLatch.await(2, TimeUnit.SECONDS));
- Assert.assertEquals(client.getZookeeperClient().getCurrentConnectionString(), initialClusterCS);
- Assert.assertEquals(ensembleProvider.getConnectionString(), initialClusterCS);
+ assertTrue(reconnectLatch.await(2, TimeUnit.SECONDS));
+ assertEquals(client.getZookeeperClient().getCurrentConnectionString(), initialClusterCS);
+ assertEquals(ensembleProvider.getConnectionString(), initialClusterCS);
newConfigData = client.getConfig().forEnsemble();
- Assert.assertNotEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertNotEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
}
}
}
@@ -238,14 +245,14 @@
client.reconfig().joining(toReconfigSpec(newCluster.getInstances())).fromConfig(oldConfig.getVersion()).forEnsemble();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
List<InstanceSpec> newInstances = Lists.newArrayList(cluster.getInstances());
newInstances.addAll(newCluster.getInstances());
assertConfig(newConfig, newInstances);
- Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
}
}
}
@@ -279,15 +286,15 @@
};
client.reconfig().inBackground(callback).joining(toReconfigSpec(newCluster.getInstances())).fromConfig(oldConfig.getVersion()).forEnsemble();
- Assert.assertTrue(timing.awaitLatch(callbackLatch));
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(callbackLatch));
+ assertTrue(timing.awaitLatch(latch));
byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
List<InstanceSpec> newInstances = Lists.newArrayList(cluster.getInstances());
newInstances.addAll(newCluster.getInstances());
assertConfig(newConfig, newInstances);
- Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
}
}
}
@@ -320,7 +327,7 @@
Collection<InstanceSpec> instances = newCluster.getInstances();
client.reconfig().leaving(Integer.toString(removeSpec.getServerId())).joining(toReconfigSpec(instances)).fromConfig(oldConfig.getVersion()).forEnsemble();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
@@ -328,7 +335,7 @@
newInstances.addAll(instances);
newInstances.remove(removeSpec);
assertConfig(newConfig, newInstances);
- Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
}
}
}
@@ -348,12 +355,12 @@
Collection<InstanceSpec> oldInstances = cluster.getInstances();
client.reconfig().leaving(Collections.emptyList()).joining(Collections.emptyList()).fromConfig(oldConfig.getVersion()).forEnsemble();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
assertConfig(newConfig, oldInstances);
- Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
}
}
@@ -372,16 +379,17 @@
Collection<InstanceSpec> oldInstances = cluster.getInstances();
client.reconfig().withNewMembers(Collections.emptyList()).fromConfig(oldConfig.getVersion()).forEnsemble();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
assertConfig(newConfig, oldInstances);
- Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
}
}
- @Test(enabled = false) // it's what this test is inteded to do and it keeps failing - disable for now
+ @Test
+ @Disabled // it's what this test is inteded to do and it keeps failing - disable for now
public void testNewMembers() throws Exception
{
cluster.close();
@@ -406,19 +414,19 @@
client.start();
QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
- Assert.assertEquals(oldConfig.getAllMembers().size(), 5);
+ assertEquals(oldConfig.getAllMembers().size(), 5);
assertConfig(oldConfig, localCluster.getInstances());
CountDownLatch latch = setChangeWaiter(client);
client.reconfig().withNewMembers(toReconfigSpec(smallClusterInstances)).forEnsemble();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
- Assert.assertEquals(newConfig.getAllMembers().size(), 3);
+ assertEquals(newConfig.getAllMembers().size(), 3);
assertConfig(newConfig, smallClusterInstances);
- Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+ assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
}
}
finally
@@ -433,7 +441,7 @@
{
String config = "server.1=10.1.2.3:2888:3888:participant;10.2.3.4:2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("10.2.3.4:2181", configString);
+ assertEquals("10.2.3.4:2181", configString);
}
@Test
@@ -441,7 +449,7 @@
{
String config = "server.1=[1010:0001:0002:0003:0004:0005:0006:0007]:2888:3888:participant;[2001:db8:85a3:0:0:8a2e:370:7334]:2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("2001:db8:85a3:0:0:8a2e:370:7334:2181", configString);
+ assertEquals("2001:db8:85a3:0:0:8a2e:370:7334:2181", configString);
}
@Test
@@ -449,7 +457,7 @@
{
String config = "server.1=10.1.2.3:2888:3888:participant;2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("10.1.2.3:2181", configString);
+ assertEquals("10.1.2.3:2181", configString);
}
@Test
@@ -457,7 +465,7 @@
{
String config = "server.1=10.1.2.3:2888:3888:participant;0.0.0.0:2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("10.1.2.3:2181", configString);
+ assertEquals("10.1.2.3:2181", configString);
}
@Test
@@ -465,7 +473,7 @@
{
String config = "server.1=10.1.2.3:2888:3888:participant";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("", configString);
+ assertEquals("", configString);
}
@Test
@@ -473,7 +481,7 @@
{
String config = "server.1=[2001:db8:85a3:0:0:8a2e:370:7334]:2888:3888:participant;[::]:2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("2001:db8:85a3:0:0:8a2e:370:7334:2181", configString);
+ assertEquals("2001:db8:85a3:0:0:8a2e:370:7334:2181", configString);
}
@Test
@@ -481,7 +489,7 @@
{
String config = "server.1=[1010:0001:0002:0003:0004:0005:0006:0007]:2888:3888:participant;[::0]:2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("1010:1:2:3:4:5:6:7:2181", configString);
+ assertEquals("1010:1:2:3:4:5:6:7:2181", configString);
}
@Test
@@ -489,7 +497,7 @@
{
String config = "server.1=10.1.2.3:2888:3888:participant;[::]:2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("10.1.2.3:2181", configString);
+ assertEquals("10.1.2.3:2181", configString);
}
@Test
@@ -497,7 +505,7 @@
{
String config = "server.1=[2001:db8:85a3:0:0:8a2e:370:7334]:2888:3888:participant;127.0.0.1:2181";
String configString = EnsembleTracker.configToConnectionString(toQuorumVerifier(config.getBytes()));
- Assert.assertEquals("127.0.0.1:2181", configString);
+ assertEquals("127.0.0.1:2181", configString);
}
@Override
@@ -581,8 +589,8 @@
for ( InstanceSpec instance : instances )
{
QuorumPeer.QuorumServer quorumServer = config.getAllMembers().get((long)instance.getServerId());
- Assert.assertNotNull(quorumServer, String.format("Looking for %s - found %s", instance.getServerId(), config.getAllMembers()));
- Assert.assertEquals(quorumServer.clientAddr.getPort(), instance.getPort());
+ assertNotNull(quorumServer, String.format("Looking for %s - found %s", instance.getServerId(), config.getAllMembers()));
+ assertEquals(quorumServer.clientAddr.getPort(), instance.getPort());
}
}
@@ -598,7 +606,7 @@
private static QuorumVerifier toQuorumVerifier(byte[] bytes) throws Exception
{
- Assert.assertNotNull(bytes);
+ assertNotNull(bytes);
Properties properties = new Properties();
properties.load(new ByteArrayInputStream(bytes));
return new QuorumMaj(properties);
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTempFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTempFramework.java
index d87e138..f17ee7c 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTempFramework.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTempFramework.java
@@ -18,13 +18,16 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.CuratorTempFramework;
import org.apache.curator.retry.RetryOneTime;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -40,7 +43,7 @@
client.inTransaction().create().forPath("/foo", "data".getBytes()).and().commit();
byte[] bytes = client.getData().forPath("/foo");
- Assert.assertEquals(bytes, "data".getBytes());
+ assertArrayEquals(bytes, "data".getBytes());
}
finally
{
@@ -68,8 +71,8 @@
service.shutdownNow();
Thread.sleep(2000);
- Assert.assertNull(client.getCleanup());
- Assert.assertNull(client.getClient());
+ assertNull(client.getCleanup());
+ assertNull(client.getClient());
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsNew.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsNew.java
index 4974739..c4144f0 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsNew.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsNew.java
@@ -19,6 +19,14 @@
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Iterables;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
@@ -35,8 +43,8 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
import java.util.List;
import java.util.concurrent.BlockingQueue;
@@ -65,11 +73,11 @@
};
client.transaction().inBackground(callback).forOperations(createOp1, createOp2);
CuratorEvent event = callbackQueue.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertNotNull(event);
- Assert.assertNotNull(event.getOpResults());
- Assert.assertEquals(event.getOpResults().size(), 2);
- Assert.assertEquals(event.getOpResults().get(0).getError(), KeeperException.Code.OK.intValue());
- Assert.assertEquals(event.getOpResults().get(1).getError(), KeeperException.Code.NONODE.intValue());
+ assertNotNull(event);
+ assertNotNull(event.getOpResults());
+ assertEquals(event.getOpResults().size(), 2);
+ assertEquals(event.getOpResults().get(0).getError(), KeeperException.Code.OK.intValue());
+ assertEquals(event.getOpResults().get(1).getError(), KeeperException.Code.NONODE.intValue());
}
finally
{
@@ -92,14 +100,14 @@
try
{
client.transaction().forOperations(statOp, createOp);
- Assert.fail();
+ fail();
}
catch ( KeeperException.BadVersionException correct )
{
// correct
}
- Assert.assertNull(client.checkExists().forPath("/bar"));
+ assertNull(client.checkExists().forPath("/bar"));
}
finally
{
@@ -122,15 +130,15 @@
Collection<CuratorTransactionResult> results = client.transaction().forOperations(createOp1, createOp2, setDataOp, createOp3, deleteOp);
- Assert.assertTrue(client.checkExists().forPath("/foo") != null);
- Assert.assertTrue(client.usingNamespace(null).checkExists().forPath("/galt/foo") != null);
- Assert.assertEquals(client.getData().forPath("/foo"), "two".getBytes());
- Assert.assertTrue(client.checkExists().forPath("/foo/bar") == null);
+ assertTrue(client.checkExists().forPath("/foo") != null);
+ assertTrue(client.usingNamespace(null).checkExists().forPath("/galt/foo") != null);
+ assertArrayEquals(client.getData().forPath("/foo"), "two".getBytes());
+ assertTrue(client.checkExists().forPath("/foo/bar") == null);
CuratorTransactionResult ephemeralResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
- Assert.assertNotNull(ephemeralResult);
- Assert.assertNotEquals(ephemeralResult.getResultPath(), "/test-");
- Assert.assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
+ assertNotNull(ephemeralResult);
+ assertNotEquals(ephemeralResult.getResultPath(), "/test-");
+ assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
}
finally
{
@@ -150,16 +158,16 @@
Collection<CuratorTransactionResult> results = client.transaction().forOperations(createOp1, createOp2);
- Assert.assertTrue(client.checkExists().forPath("/foo/bar") != null);
- Assert.assertEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());
+ assertTrue(client.checkExists().forPath("/foo/bar") != null);
+ assertArrayEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());
CuratorTransactionResult fooResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo"));
CuratorTransactionResult fooBarResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
- Assert.assertNotNull(fooResult);
- Assert.assertNotNull(fooBarResult);
- Assert.assertNotSame(fooResult, fooBarResult);
- Assert.assertEquals(fooResult.getResultPath(), "/foo");
- Assert.assertEquals(fooBarResult.getResultPath(), "/foo/bar");
+ assertNotNull(fooResult);
+ assertNotNull(fooBarResult);
+ assertNotSame(fooResult, fooBarResult);
+ assertEquals(fooResult.getResultPath(), "/foo");
+ assertEquals(fooBarResult.getResultPath(), "/foo/bar");
}
finally
{
@@ -189,17 +197,17 @@
client.transaction().inBackground(callback).forOperations(createOp1, createOp2);
Collection<CuratorTransactionResult> results = queue.poll(5, TimeUnit.SECONDS);
- Assert.assertNotNull(results);
- Assert.assertTrue(client.checkExists().forPath("/foo/bar") != null);
- Assert.assertEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());
+ assertNotNull(results);
+ assertTrue(client.checkExists().forPath("/foo/bar") != null);
+ assertArrayEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());
CuratorTransactionResult fooResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo"));
CuratorTransactionResult fooBarResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
- Assert.assertNotNull(fooResult);
- Assert.assertNotNull(fooBarResult);
- Assert.assertNotSame(fooResult, fooBarResult);
- Assert.assertEquals(fooResult.getResultPath(), "/foo");
- Assert.assertEquals(fooBarResult.getResultPath(), "/foo/bar");
+ assertNotNull(fooResult);
+ assertNotNull(fooBarResult);
+ assertNotSame(fooResult, fooBarResult);
+ assertEquals(fooResult.getResultPath(), "/foo");
+ assertEquals(fooBarResult.getResultPath(), "/foo/bar");
}
finally
{
@@ -233,16 +241,16 @@
Collection<CuratorTransactionResult> results = queue.poll(5, TimeUnit.SECONDS);
- Assert.assertNotNull(results);
- Assert.assertTrue(client.checkExists().forPath("/foo") != null);
- Assert.assertTrue(client.usingNamespace(null).checkExists().forPath("/galt/foo") != null);
- Assert.assertEquals(client.getData().forPath("/foo"), "two".getBytes());
- Assert.assertTrue(client.checkExists().forPath("/foo/bar") == null);
+ assertNotNull(results);
+ assertTrue(client.checkExists().forPath("/foo") != null);
+ assertTrue(client.usingNamespace(null).checkExists().forPath("/galt/foo") != null);
+ assertArrayEquals(client.getData().forPath("/foo"), "two".getBytes());
+ assertTrue(client.checkExists().forPath("/foo/bar") == null);
CuratorTransactionResult ephemeralResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
- Assert.assertNotNull(ephemeralResult);
- Assert.assertNotEquals(ephemeralResult.getResultPath(), "/test-");
- Assert.assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
+ assertNotNull(ephemeralResult);
+ assertNotEquals(ephemeralResult.getResultPath(), "/test-");
+ assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsOld.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsOld.java
index 2c42d61..7fd3f53 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsOld.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactionsOld.java
@@ -18,6 +18,14 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Iterables;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -30,8 +38,8 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.Stat;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
@SuppressWarnings("deprecation")
@@ -56,14 +64,14 @@
.and()
.commit();
- Assert.fail();
+ fail();
}
catch ( KeeperException.BadVersionException correct )
{
// correct
}
- Assert.assertNull(client.checkExists().forPath("/bar"));
+ assertNull(client.checkExists().forPath("/bar"));
}
finally
{
@@ -92,15 +100,15 @@
.and()
.commit();
- Assert.assertTrue(client.checkExists().forPath("/foo") != null);
- Assert.assertTrue(client.usingNamespace(null).checkExists().forPath("/galt/foo") != null);
- Assert.assertEquals(client.getData().forPath("/foo"), "two".getBytes());
- Assert.assertTrue(client.checkExists().forPath("/foo/bar") == null);
+ assertTrue(client.checkExists().forPath("/foo") != null);
+ assertTrue(client.usingNamespace(null).checkExists().forPath("/galt/foo") != null);
+ assertArrayEquals(client.getData().forPath("/foo"), "two".getBytes());
+ assertTrue(client.checkExists().forPath("/foo/bar") == null);
CuratorTransactionResult ephemeralResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
- Assert.assertNotNull(ephemeralResult);
- Assert.assertNotEquals(ephemeralResult.getResultPath(), "/test-");
- Assert.assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
+ assertNotNull(ephemeralResult);
+ assertNotEquals(ephemeralResult.getResultPath(), "/test-");
+ assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
}
finally
{
@@ -129,21 +137,21 @@
.and()
.commit();
- Assert.assertTrue(client.checkExists().forPath("/foo") != null);
- Assert.assertEquals(client.getData().decompressed().forPath("/foo"), "five".getBytes());
+ assertTrue(client.checkExists().forPath("/foo") != null);
+ assertArrayEquals(client.getData().decompressed().forPath("/foo"), "five".getBytes());
- Assert.assertTrue(client.checkExists().forPath("/bar") != null);
- Assert.assertEquals(client.getData().decompressed().forPath("/bar"), "two".getBytes());
- Assert.assertEquals(client.getACL().forPath("/bar"), ZooDefs.Ids.READ_ACL_UNSAFE);
+ assertTrue(client.checkExists().forPath("/bar") != null);
+ assertArrayEquals(client.getData().decompressed().forPath("/bar"), "two".getBytes());
+ assertEquals(client.getACL().forPath("/bar"), ZooDefs.Ids.READ_ACL_UNSAFE);
CuratorTransactionResult ephemeralResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
- Assert.assertNotNull(ephemeralResult);
- Assert.assertNotEquals(ephemeralResult.getResultPath(), "/test-");
- Assert.assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
+ assertNotNull(ephemeralResult);
+ assertNotEquals(ephemeralResult.getResultPath(), "/test-");
+ assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
- Assert.assertTrue(client.checkExists().forPath("/baz") != null);
- Assert.assertEquals(client.getData().decompressed().forPath("/baz"), "four".getBytes());
- Assert.assertEquals(client.getACL().forPath("/baz"), ZooDefs.Ids.READ_ACL_UNSAFE);
+ assertTrue(client.checkExists().forPath("/baz") != null);
+ assertArrayEquals(client.getData().decompressed().forPath("/baz"), "four".getBytes());
+ assertEquals(client.getACL().forPath("/baz"), ZooDefs.Ids.READ_ACL_UNSAFE);
}
finally
{
@@ -166,16 +174,16 @@
.and()
.commit();
- Assert.assertTrue(client.checkExists().forPath("/foo/bar") != null);
- Assert.assertEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());
+ assertTrue(client.checkExists().forPath("/foo/bar") != null);
+ assertArrayEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());
CuratorTransactionResult fooResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo"));
CuratorTransactionResult fooBarResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
- Assert.assertNotNull(fooResult);
- Assert.assertNotNull(fooBarResult);
- Assert.assertNotSame(fooResult, fooBarResult);
- Assert.assertEquals(fooResult.getResultPath(), "/foo");
- Assert.assertEquals(fooBarResult.getResultPath(), "/foo/bar");
+ assertNotNull(fooResult);
+ assertNotNull(fooBarResult);
+ assertNotSame(fooResult, fooBarResult);
+ assertEquals(fooResult.getResultPath(), "/foo");
+ assertEquals(fooBarResult.getResultPath(), "/foo/bar");
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java
index fc37e41..c00ab0e 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.BackgroundCallback;
@@ -26,21 +29,21 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.test.Timing;
import org.apache.zookeeper.CreateMode;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
public class TestTtlNodes extends CuratorTestBase
{
- @BeforeClass
+ @BeforeAll
public static void setUpClass() {
System.setProperty("zookeeper.extendedTypesEnabled", "true");
}
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -48,7 +51,7 @@
super.setup();
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -65,7 +68,7 @@
client.create().withTtl(10).creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT_WITH_TTL).forPath("/a/b/c");
Thread.sleep(20);
- Assert.assertNull(client.checkExists().forPath("/a/b/c"));
+ assertNull(client.checkExists().forPath("/a/b/c"));
}
}
@@ -86,9 +89,9 @@
}
};
client.create().withTtl(10).creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT_WITH_TTL).inBackground(callback).forPath("/a/b/c");
- Assert.assertTrue(new Timing().awaitLatch(latch));
+ assertTrue(new Timing().awaitLatch(latch));
Thread.sleep(20);
- Assert.assertNull(client.checkExists().forPath("/a/b/c"));
+ assertNull(client.checkExists().forPath("/a/b/c"));
}
}
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherIdentity.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherIdentity.java
index 6f91023..1d16450 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherIdentity.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherIdentity.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import com.google.common.collect.Sets;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -28,8 +30,8 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -77,13 +79,13 @@
client.setData().forPath("/test", "foo".getBytes());
client.delete().forPath("/test");
timing.sleepABit();
- Assert.assertEquals(actualWatcher.count.getAndSet(0), 1);
+ assertEquals(actualWatcher.count.getAndSet(0), 1);
client.create().forPath("/test");
client.checkExists().usingWatcher(actualWatcher).forPath("/test");
client.delete().forPath("/test");
timing.sleepABit();
- Assert.assertEquals(actualWatcher.count.get(), 1);
+ assertEquals(actualWatcher.count.get(), 1);
}
finally
{
@@ -109,13 +111,13 @@
client.setData().forPath("/test", "foo".getBytes());
client.delete().forPath("/test");
timing.sleepABit();
- Assert.assertEquals(actualWatcher.count.getAndSet(0), 1);
+ assertEquals(actualWatcher.count.getAndSet(0), 1);
client.create().forPath("/test");
client.checkExists().usingWatcher(actualWatcher).forPath("/test");
client.delete().forPath("/test");
timing.sleepABit();
- Assert.assertEquals(actualWatcher.count.get(), 1);
+ assertEquals(actualWatcher.count.get(), 1);
}
finally
{
@@ -136,13 +138,13 @@
};
NamespaceWatcher namespaceWatcher1 = new NamespaceWatcher(null, watcher, "/foo");
NamespaceWatcher namespaceWatcher2 = new NamespaceWatcher(null, watcher, "/foo");
- Assert.assertEquals(namespaceWatcher1, namespaceWatcher2);
- Assert.assertFalse(namespaceWatcher1.equals(watcher));
- Assert.assertFalse(watcher.equals(namespaceWatcher1));
+ assertEquals(namespaceWatcher1, namespaceWatcher2);
+ assertFalse(namespaceWatcher1.equals(watcher));
+ assertFalse(watcher.equals(namespaceWatcher1));
Set<Watcher> set = Sets.newHashSet();
set.add(namespaceWatcher1);
set.add(namespaceWatcher2);
- Assert.assertEquals(set.size(), 1);
+ assertEquals(set.size(), 1);
}
@Test
@@ -161,7 +163,7 @@
// Ok, let's test it
client.setData().forPath(PATH, new byte[]{});
timing.sleepABit();
- Assert.assertEquals(1, watcher.count.get());
+ assertEquals(1, watcher.count.get());
}
finally
{
@@ -186,7 +188,7 @@
// Ok, let's test it
client.setData().forPath(PATH, new byte[]{});
timing.sleepABit();
- Assert.assertEquals(1, watcher.count.get());
+ assertEquals(1, watcher.count.get());
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
index 8b17576..c6ac16c 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.WatcherRemoveCuratorFramework;
@@ -30,8 +34,8 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -60,7 +64,7 @@
removerClient.create().creatingParentsIfNeeded().forPath("/d/e/f");
Timing timing = new Timing();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
timing.sleepABit();
removerClient.removeWatchers();
@@ -89,7 +93,7 @@
};
removerClient.checkExists().usingWatcher(watcher).forPath("/a/b/c");
removerClient.checkExists().usingWatcher(watcher).forPath("/d/e/f");
- Assert.assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 2);
+ assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 2);
removerClient.removeWatchers();
}
finally
@@ -122,7 +126,7 @@
removerClient.setData().forPath("/a/b/c", "new".getBytes());
Timing timing = new Timing();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
timing.sleepABit();
removerClient.removeWatchers();
@@ -181,13 +185,13 @@
try
{
removerClient.checkExists().usingWatcher(w).forPath("/one/two/three");
- Assert.fail("Should have thrown ConnectionLossException");
+ fail("Should have thrown ConnectionLossException");
}
catch ( KeeperException.ConnectionLossException expected )
{
// expected
}
- Assert.assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 0);
+ assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 0);
}
finally
{
@@ -223,8 +227,8 @@
}
};
removerClient.checkExists().usingWatcher(w).inBackground(callback).forPath("/one/two/three");
- Assert.assertTrue(new Timing().awaitLatch(latch));
- Assert.assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 0);
+ assertTrue(new Timing().awaitLatch(latch));
+ assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 0);
}
finally
{
@@ -251,7 +255,7 @@
try
{
removerClient.getData().usingWatcher(w).forPath("/one/two/three");
- Assert.fail("Should have thrown NoNodeException");
+ fail("Should have thrown NoNodeException");
}
catch ( KeeperException.NoNodeException expected )
{
@@ -294,8 +298,8 @@
}
};
removerClient.getData().usingWatcher(w).inBackground(callback).forPath("/one/two/three");
- Assert.assertTrue(new Timing().awaitLatch(latch));
- Assert.assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 0);
+ assertTrue(new Timing().awaitLatch(latch));
+ assertEquals(removerClient.getWatcherRemovalManager().getEntries().size(), 0);
removerClient.removeWatchers();
return null;
}
@@ -392,9 +396,9 @@
};
removerClient.getData().usingWatcher(watcher).forPath("/test");
- Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
+ assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
removerClient.getData().usingWatcher(watcher).forPath("/test");
- Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
+ assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
removerClient.removeWatchers();
}
finally
@@ -427,12 +431,12 @@
};
removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
- Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
+ assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
removerClient.create().forPath("/yo");
- Assert.assertTrue(new Timing().awaitLatch(latch));
+ assertTrue(new Timing().awaitLatch(latch));
- Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
+ assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
}
finally
{
@@ -478,17 +482,17 @@
};
removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
- Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
+ assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
removerClient.create().forPath("/yo");
- Assert.assertTrue(timing.awaitLatch(createdLatch));
- Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
+ assertTrue(timing.awaitLatch(createdLatch));
+ assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
removerClient.delete().forPath("/yo");
- Assert.assertTrue(timing.awaitLatch(deletedLatch));
+ assertTrue(timing.awaitLatch(deletedLatch));
- Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
+ assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
}
finally
{
@@ -515,13 +519,13 @@
removerClient.checkExists().usingWatcher(watcher).forPath("/hey");
List<String> existWatches = WatchersDebug.getExistWatches(client.getZookeeperClient().getZooKeeper());
- Assert.assertEquals(existWatches.size(), 1);
+ assertEquals(existWatches.size(), 1);
removerClient.removeWatchers();
- Assert.assertTrue(new Timing().awaitLatch(latch));
+ assertTrue(new Timing().awaitLatch(latch));
existWatches = WatchersDebug.getExistWatches(client.getZookeeperClient().getZooKeeper());
- Assert.assertEquals(existWatches.size(), 0);
+ assertEquals(existWatches.size(), 0);
}
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatchesBuilder.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatchesBuilder.java
index 260c292..3052650 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatchesBuilder.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatchesBuilder.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.BackgroundCallback;
@@ -41,8 +45,9 @@
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.WatcherType;
import org.apache.zookeeper.ZooKeeper;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -128,7 +133,7 @@
client.watches().removeAll().forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
{
@@ -167,7 +172,7 @@
client.watches().remove(watcher).forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
{
@@ -196,7 +201,7 @@
client.watches().remove(watcher).forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
{
@@ -238,7 +243,7 @@
client.watches().remove(watcher).ofType(WatcherType.Any).inBackground(callback).forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
@@ -267,7 +272,7 @@
client.watches().remove(watcher).inBackground().forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
@@ -299,7 +304,7 @@
client.watches().removeAll().forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
{
@@ -331,8 +336,8 @@
client.watches().removeAll().ofType(WatcherType.Data).forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
- Assert.assertEquals(removedFlag.get(), false);
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertEquals(removedFlag.get(), false);
}
finally
{
@@ -364,8 +369,8 @@
client.watches().removeAll().ofType(WatcherType.Children).forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
- Assert.assertEquals(removedFlag.get(), false);
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertEquals(removedFlag.get(), false);
}
finally
{
@@ -397,11 +402,11 @@
//Stop the server so we can check if we can remove watches locally when offline
server.stop();
- Assert.assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
+ assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
client.watches().removeAll().locally().forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
{
@@ -433,11 +438,11 @@
//Stop the server so we can check if we can remove watches locally when offline
server.stop();
- Assert.assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
+ assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
client.watches().removeAll().locally().inBackground().forPath(path);
- Assert.assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
+ assertTrue(timing.awaitLatch(removedLatch), "Timed out waiting for watch removal");
}
finally
{
@@ -472,7 +477,7 @@
try
{
client.watches().remove(watcher).forPath(path);
- Assert.fail("Expected KeeperException.NoWatcherException");
+ fail("Expected KeeperException.NoWatcherException");
}
catch ( KeeperException.NoWatcherException expected )
{
@@ -484,7 +489,7 @@
CloseableUtils.closeQuietly(client);
}
}
-
+
/**
* Test the case where we try and remove an unregistered watcher but have the quietly flag set. In this case we expect success.
* @throws Exception
@@ -511,7 +516,7 @@
timing.sleepABit();
//There should be no watcher removed as none were registered.
- Assert.assertEquals(watcherRemoved.get(), false);
+ assertEquals(watcherRemoved.get(), false);
}
finally
{
@@ -541,13 +546,13 @@
server.stop();
- Assert.assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
+ assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
//Remove the watch while we're not connected
try
{
client.watches().remove(watcher).guaranteed().forPath(path);
- Assert.fail();
+ fail();
}
catch(KeeperException.ConnectionLossException e)
{
@@ -596,7 +601,7 @@
client.checkExists().usingWatcher(watcher).forPath(path);
server.stop();
- Assert.assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
+ assertTrue(blockUntilDesiredConnectionState(stateRef, timing, ConnectionState.SUSPENDED));
//Remove the watch while we're not connected
client.watches().remove(watcher).guaranteed().inBackground().forPath(path);
@@ -613,7 +618,8 @@
}
}
- @Test(groups = CuratorTestBase.zk36Group)
+ @Test
+ @Tag(CuratorTestBase.zk36Group)
public void testPersistentWatch() throws Exception
{
try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
@@ -629,11 +635,12 @@
client.setData().forPath("/test/foo", "hey".getBytes());
client.delete().forPath("/test/foo");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
}
- @Test(groups = CuratorTestBase.zk36Group)
+ @Test
+ @Tag(CuratorTestBase.zk36Group)
public void testPersistentWatchInBackground() throws Exception
{
try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
@@ -651,12 +658,13 @@
client.setData().forPath("/test/foo", "hey".getBytes());
client.delete().forPath("/test/foo");
- Assert.assertTrue(timing.awaitLatch(backgroundLatch));
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(backgroundLatch));
+ assertTrue(timing.awaitLatch(latch));
}
}
- @Test(groups = CuratorTestBase.zk36Group)
+ @Test
+ @Tag(CuratorTestBase.zk36Group)
public void testPersistentRecursiveWatch() throws Exception
{
try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
@@ -674,11 +682,12 @@
client.create().forPath("/test/a/b/c");
client.create().forPath("/test/a/b/c/d");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
}
- @Test(groups = CuratorTestBase.zk36Group)
+ @Test
+ @Tag(CuratorTestBase.zk36Group)
public void testPersistentRecursiveWatchInBackground() throws Exception
{
try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
@@ -698,12 +707,13 @@
client.create().forPath("/test/a/b/c");
client.create().forPath("/test/a/b/c/d");
- Assert.assertTrue(timing.awaitLatch(backgroundLatch));
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(backgroundLatch));
+ assertTrue(timing.awaitLatch(latch));
}
}
- @Test(groups = CuratorTestBase.zk36Group)
+ @Test
+ @Tag(CuratorTestBase.zk36Group)
public void testPersistentRecursiveDefaultWatch() throws Exception
{
CountDownLatch latch = new CountDownLatch(6); // 5 creates plus the initial sync
@@ -727,7 +737,7 @@
client.create().forPath("/test/a/b/c");
client.create().forPath("/test/a/b/c/d");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWithCluster.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWithCluster.java
index 1f1e213..4784af1 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWithCluster.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWithCluster.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -30,8 +33,8 @@
import org.apache.curator.test.TestingCluster;
import org.apache.curator.test.Timing;
import org.apache.zookeeper.CreateMode;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
public class TestWithCluster extends CuratorTestBase
@@ -63,7 +66,7 @@
client.getConnectionStateListenable().addListener(listener);
client.create().withMode(CreateMode.EPHEMERAL).forPath("/temp", "value".getBytes());
- Assert.assertNotNull(client.checkExists().forPath("/temp"));
+ assertNotNull(client.checkExists().forPath("/temp"));
for ( InstanceSpec spec : cluster.getInstances() )
{
@@ -73,8 +76,8 @@
timing.sleepABit();
}
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
- Assert.assertNotNull(client.checkExists().forPath("/temp"));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertNotNull(client.checkExists().forPath("/temp"));
}
finally
{
@@ -127,11 +130,11 @@
{
if ( !instanceSpec.equals(cluster.findConnectionInstance(client.getZookeeperClient().getZooKeeper())) )
{
- Assert.assertTrue(cluster.killServer(instanceSpec));
+ assertTrue(cluster.killServer(instanceSpec));
}
}
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
finally
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
index cd8e977..9454ef5 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
@@ -32,8 +35,8 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.data.ACL;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -45,11 +48,11 @@
{
SchemaSet schemaSet = loadSchemaSet("schema1.json", null);
Schema schema = schemaSet.getNamedSchema("test");
- Assert.assertNotNull(schema);
+ assertNotNull(schema);
Map<String, String> expectedMetadata = Maps.newHashMap();
expectedMetadata.put("one", "1");
expectedMetadata.put("two", "2");
- Assert.assertEquals(schema.getMetadata(), expectedMetadata);
+ assertEquals(schema.getMetadata(), expectedMetadata);
CuratorFramework client = newClient(schemaSet);
try
@@ -59,9 +62,9 @@
try
{
String rawPath = schema.getRawPath();
- Assert.assertEquals(rawPath, "/a/b/c");
+ assertEquals(rawPath, "/a/b/c");
client.create().creatingParentsIfNeeded().forPath(rawPath);
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -104,7 +107,7 @@
try
{
client.create().forPath("/test", new byte[0]);
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -131,7 +134,7 @@
try
{
client.create().creatingParentsIfNeeded().forPath("/a/b/c");
- Assert.fail("Should've violated schema: test");
+ fail("Should've violated schema: test");
}
catch ( SchemaViolation dummy )
{
@@ -141,7 +144,7 @@
try
{
client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath("/a/b/c/d/e");
- Assert.fail("Should've violated schema: test2");
+ fail("Should've violated schema: test2");
}
catch ( SchemaViolation dummy )
{
@@ -190,7 +193,7 @@
try
{
client.transaction().forOperations(createAPersistent, createAEphemeral);
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -201,7 +204,7 @@
try
{
client.transaction().forOperations(deleteA);
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -211,7 +214,7 @@
try
{
client.transaction().forOperations(createBEmptyData);
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -222,7 +225,7 @@
try
{
client.transaction().forOperations(setBEmptyData);
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -242,12 +245,12 @@
String yaml = Resources.toString(Resources.getResource("schema.yaml"), Charsets.UTF_8);
JsonNode root = new ObjectMapper(new YAMLFactory()).readTree(yaml);
List<Schema> schemas = new SchemaSetLoader(root, null).getSchemas();
- Assert.assertEquals(schemas.size(), 2);
- Assert.assertEquals(schemas.get(0).getName(), "test");
- Assert.assertEquals(schemas.get(0).getMetadata().size(), 0);
- Assert.assertEquals(schemas.get(1).getName(), "test2");
- Assert.assertEquals(schemas.get(1).getMetadata().size(), 2);
- Assert.assertEquals(schemas.get(1).getMetadata().get("two"), "2");
+ assertEquals(schemas.size(), 2);
+ assertEquals(schemas.get(0).getName(), "test");
+ assertEquals(schemas.get(0).getMetadata().size(), 0);
+ assertEquals(schemas.get(1).getName(), "test2");
+ assertEquals(schemas.get(1).getMetadata().size(), 2);
+ assertEquals(schemas.get(1).getMetadata().get("two"), "2");
}
@Test
@@ -262,7 +265,7 @@
try
{
client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath("/exact/match");
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -272,7 +275,7 @@
try
{
client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/exact/foo/bar");
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
@@ -282,7 +285,7 @@
try
{
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/exact/other/bar");
- Assert.fail("Should've violated schema");
+ fail("Should've violated schema");
}
catch ( SchemaViolation dummy )
{
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreaker.java b/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreaker.java
index bee917e..f6cd399 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreaker.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreaker.java
@@ -18,13 +18,15 @@
*/
package org.apache.curator.framework.state;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.curator.RetryPolicy;
import org.apache.curator.retry.RetryForever;
import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.retry.RetryUntilElapsed;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.ScheduledFuture;
@@ -34,8 +36,8 @@
public class TestCircuitBreaker
{
- private Duration[] lastDelay = new Duration[]{Duration.ZERO};
- private ScheduledThreadPoolExecutor service = new ScheduledThreadPoolExecutor(1)
+ private static Duration[] lastDelay = new Duration[]{Duration.ZERO};
+ private static ScheduledThreadPoolExecutor service = new ScheduledThreadPoolExecutor(1)
{
@Override
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
@@ -46,8 +48,8 @@
}
};
- @AfterClass
- public void tearDown()
+ @AfterAll
+ public static void tearDown()
{
service.shutdownNow();
}
@@ -61,30 +63,30 @@
CircuitBreaker circuitBreaker = CircuitBreaker.build(new RetryNTimes(retryQty, (int)delay.toMillis()), service);
AtomicInteger counter = new AtomicInteger(0);
- Assert.assertTrue(circuitBreaker.tryToOpen(counter::incrementAndGet));
- Assert.assertEquals(lastDelay[0], delay);
+ assertTrue(circuitBreaker.tryToOpen(counter::incrementAndGet));
+ assertEquals(lastDelay[0], delay);
- Assert.assertFalse(circuitBreaker.tryToOpen(counter::incrementAndGet));
- Assert.assertEquals(circuitBreaker.getRetryCount(), 1);
- Assert.assertEquals(counter.get(), 1);
- Assert.assertFalse(circuitBreaker.tryToRetry(counter::incrementAndGet));
- Assert.assertEquals(circuitBreaker.getRetryCount(), 1);
- Assert.assertEquals(counter.get(), 1);
+ assertFalse(circuitBreaker.tryToOpen(counter::incrementAndGet));
+ assertEquals(circuitBreaker.getRetryCount(), 1);
+ assertEquals(counter.get(), 1);
+ assertFalse(circuitBreaker.tryToRetry(counter::incrementAndGet));
+ assertEquals(circuitBreaker.getRetryCount(), 1);
+ assertEquals(counter.get(), 1);
- Assert.assertTrue(circuitBreaker.close());
- Assert.assertEquals(circuitBreaker.getRetryCount(), 0);
- Assert.assertFalse(circuitBreaker.close());
+ assertTrue(circuitBreaker.close());
+ assertEquals(circuitBreaker.getRetryCount(), 0);
+ assertFalse(circuitBreaker.close());
}
@Test
public void testVariousOpenRetryFails()
{
CircuitBreaker circuitBreaker = CircuitBreaker.build(new RetryForever(1), service);
- Assert.assertFalse(circuitBreaker.tryToRetry(() -> {}));
- Assert.assertTrue(circuitBreaker.tryToOpen(() -> {}));
- Assert.assertFalse(circuitBreaker.tryToOpen(() -> {}));
- Assert.assertTrue(circuitBreaker.close());
- Assert.assertFalse(circuitBreaker.close());
+ assertFalse(circuitBreaker.tryToRetry(() -> {}));
+ assertTrue(circuitBreaker.tryToOpen(() -> {}));
+ assertFalse(circuitBreaker.tryToOpen(() -> {}));
+ assertTrue(circuitBreaker.close());
+ assertFalse(circuitBreaker.close());
}
@Test
@@ -92,7 +94,7 @@
{
RetryPolicy retryPolicy = new RetryUntilElapsed(10000, 10000);
CircuitBreaker circuitBreaker = CircuitBreaker.build(retryPolicy, service);
- Assert.assertTrue(circuitBreaker.tryToOpen(() -> {}));
- Assert.assertEquals(lastDelay[0], Duration.ofMillis(10000));
+ assertTrue(circuitBreaker.tryToOpen(() -> {}));
+ assertEquals(lastDelay[0], Duration.ofMillis(10000));
}
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreakingConnectionStateListener.java b/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreakingConnectionStateListener.java
index 5c80a9a..61c8da8 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreakingConnectionStateListener.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/state/TestCircuitBreakingConnectionStateListener.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.state;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.curator.RetryPolicy;
import org.apache.curator.RetrySleeper;
import org.apache.curator.framework.CuratorFramework;
@@ -25,10 +28,9 @@
import org.apache.curator.retry.RetryForever;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.compatibility.Timing2;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -68,13 +70,13 @@
}
}
- @BeforeMethod
+ @BeforeEach
public void setup()
{
service = new ScheduledThreadPoolExecutor(1);
}
- @AfterMethod
+ @AfterEach
public void tearDown()
{
service.shutdownNow();
@@ -88,14 +90,14 @@
CircuitBreakingConnectionStateListener listener = new CircuitBreakingConnectionStateListener(dummyClient, recordingListener, retryPolicy, service);
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.RECONNECTED);
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.RECONNECTED);
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED);
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED); // 2nd suspended is ignored
- Assert.assertTrue(recordingListener.stateChanges.isEmpty());
+ assertTrue(recordingListener.stateChanges.isEmpty());
listener.stateChanged(dummyClient, ConnectionState.LOST);
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
synchronized(listener) // don't let retry policy run while we're pushing state changes
{
@@ -106,10 +108,10 @@
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED); // all further events are ignored - this will be the last event
}
retryTiming.multiple(2).sleep();
- Assert.assertTrue(recordingListener.stateChanges.isEmpty());
+ assertTrue(recordingListener.stateChanges.isEmpty());
retryPolicy.isRetrying = false; // retry policy will return false
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
}
@Test
@@ -124,11 +126,11 @@
listener.stateChanged(dummyClient, ConnectionState.LOST);
listener.stateChanged(dummyClient, ConnectionState.LOST); // second LOST ignored
}
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
- Assert.assertTrue(recordingListener.stateChanges.isEmpty());
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
+ assertTrue(recordingListener.stateChanges.isEmpty());
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED); // causes circuit to close on next retry
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.RECONNECTED);
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.RECONNECTED);
}
@Test
@@ -139,11 +141,11 @@
CircuitBreakingConnectionStateListener listener = new CircuitBreakingConnectionStateListener(dummyClient, recordingListener, retryNever, service);
listener.stateChanged(dummyClient, ConnectionState.LOST);
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
- Assert.assertFalse(listener.isOpen());
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
+ assertFalse(listener.isOpen());
listener.stateChanged(dummyClient, ConnectionState.LOST);
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
- Assert.assertFalse(listener.isOpen());
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
+ assertFalse(listener.isOpen());
}
@Test
@@ -157,11 +159,11 @@
{
listener.stateChanged(dummyClient, ConnectionState.LOST);
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED);
- Assert.assertTrue(listener.isOpen());
+ assertTrue(listener.isOpen());
}
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
- Assert.assertFalse(listener.isOpen());
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
+ assertFalse(listener.isOpen());
}
@Test
@@ -172,12 +174,12 @@
CircuitBreakingConnectionStateListener listener = new CircuitBreakingConnectionStateListener(dummyClient, recordingListener, retryInfinite, service);
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);
- Assert.assertFalse(listener.isOpen());
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.RECONNECTED);
+ assertFalse(listener.isOpen());
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.RECONNECTED);
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED);
- Assert.assertTrue(listener.isOpen());
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
+ assertTrue(listener.isOpen());
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.SUSPENDED);
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);
listener.stateChanged(dummyClient, ConnectionState.READ_ONLY);
@@ -188,12 +190,12 @@
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);
listener.stateChanged(dummyClient, ConnectionState.READ_ONLY);
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED);
- Assert.assertTrue(recordingListener.stateChanges.isEmpty());
- Assert.assertTrue(listener.isOpen());
+ assertTrue(recordingListener.stateChanges.isEmpty());
+ assertTrue(listener.isOpen());
listener.stateChanged(dummyClient, ConnectionState.LOST);
- Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
- Assert.assertTrue(listener.isOpen());
+ assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
+ assertTrue(listener.isOpen());
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);
listener.stateChanged(dummyClient, ConnectionState.READ_ONLY);
@@ -204,8 +206,8 @@
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);
listener.stateChanged(dummyClient, ConnectionState.READ_ONLY);
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED);
- Assert.assertTrue(recordingListener.stateChanges.isEmpty());
- Assert.assertTrue(listener.isOpen());
+ assertTrue(recordingListener.stateChanges.isEmpty());
+ assertTrue(listener.isOpen());
listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);
listener.stateChanged(dummyClient, ConnectionState.READ_ONLY);
@@ -221,7 +223,7 @@
listener.stateChanged(dummyClient, ConnectionState.LOST);
listener.stateChanged(dummyClient, ConnectionState.SUSPENDED);
listener.stateChanged(dummyClient, ConnectionState.LOST);
- Assert.assertTrue(recordingListener.stateChanges.isEmpty());
- Assert.assertTrue(listener.isOpen());
+ assertTrue(recordingListener.stateChanges.isEmpty());
+ assertTrue(listener.isOpen());
}
}
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java b/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
index 1dbb5e7..4bd94e2 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.state;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
@@ -25,12 +27,13 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestConnectionStateManager extends BaseClassForTests {
@Test
@@ -71,10 +74,10 @@
client.getConnectionStateListenable().addListener(stateListener);
client.start();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
server.close();
- Assert.assertTrue(lostLatch.await(lostStateExpectedMs, TimeUnit.MILLISECONDS));
+ assertTrue(lostLatch.await(lostStateExpectedMs, TimeUnit.MILLISECONDS));
}
finally {
CloseableUtils.closeQuietly(client);
diff --git a/curator-recipes/pom.xml b/curator-recipes/pom.xml
index 9a0acaf..8cd2e51 100644
--- a/curator-recipes/pom.xml
+++ b/curator-recipes/pom.xml
@@ -70,8 +70,8 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
diff --git a/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java b/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java
index d1cc243..11a5af5 100644
--- a/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java
+++ b/curator-recipes/src/test/java/org/apache/curator/connection/TestThreadLocalRetryLoop.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.connection;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.curator.RetryLoop;
import org.apache.curator.RetryPolicy;
import org.apache.curator.RetrySleeper;
@@ -28,8 +32,9 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.KeeperException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -41,7 +46,8 @@
private static final int retryCount = 4;
private static final String backgroundThreadNameBase = "ignore-curator-background-thread";
- @Test(description = "Check for fix for CURATOR-559")
+ @Test
+ @DisplayName("Check for fix for CURATOR-559")
public void testRecursingRetry() throws Exception
{
AtomicInteger count = new AtomicInteger();
@@ -49,11 +55,12 @@
{
prep(client, count);
doOperation(client);
- Assert.assertEquals(count.get(), retryCount + 1); // Curator's retry policy has been off by 1 since inception - we might consider fixing it someday
+ assertEquals(count.get(), retryCount + 1); // Curator's retry policy has been off by 1 since inception - we might consider fixing it someday
}
}
- @Test(description = "Check for fix for CURATOR-559 with multiple threads")
+ @Test
+ @DisplayName("Check for fix for CURATOR-559 with multiple threads")
public void testThreadedRecursingRetry() throws Exception
{
final int threadQty = 4;
@@ -67,16 +74,18 @@
executorService.submit(() -> doOperation(client));
}
executorService.shutdown();
- Assert.assertTrue(executorService.awaitTermination(timing.milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertEquals(count.get(), threadQty * (retryCount + 1)); // Curator's retry policy has been off by 1 since inception - we might consider fixing it someday
+ assertTrue(executorService.awaitTermination(timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertEquals(count.get(), threadQty * (retryCount + 1)); // Curator's retry policy has been off by 1 since inception - we might consider fixing it someday
}
}
- @Test(expectedExceptions = NullPointerException.class)
+ @Test
public void testBadReleaseWithNoGet()
{
- ThreadLocalRetryLoop retryLoopStack = new ThreadLocalRetryLoop();
- retryLoopStack.release();
+ assertThrows(NullPointerException.class, ()-> {
+ ThreadLocalRetryLoop retryLoopStack = new ThreadLocalRetryLoop();
+ retryLoopStack.release();
+ });
}
private CuratorFramework newClient(AtomicInteger count)
@@ -97,7 +106,7 @@
}
});
server.stop();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
count.set(0); // in case the server shutdown incremented the count
}
@@ -109,7 +118,7 @@
client.checkExists().forPath("/hey");
return null;
});
- Assert.fail("Should have thrown an exception");
+ fail("Should have thrown an exception");
}
catch ( KeeperException dummy )
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/client/TestBackgroundStates.java b/curator-recipes/src/test/java/org/apache/curator/framework/client/TestBackgroundStates.java
index f264615..cf90a67 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/client/TestBackgroundStates.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/client/TestBackgroundStates.java
@@ -19,6 +19,8 @@
package org.apache.curator.framework.client;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -30,8 +32,8 @@
import org.apache.curator.test.TestingServer;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -77,14 +79,14 @@
client.getConnectionStateListenable().addListener(listener);
timing.sleepABit();
server = new TestingServer(server.getPort());
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
timing.sleepABit();
- Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
server.restart();
timing.sleepABit();
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
timing.sleepABit();
- Assert.assertEquals(lastState.get(), ConnectionState.RECONNECTED);
+ assertEquals(lastState.get(), ConnectionState.RECONNECTED);
}
finally
{
@@ -118,15 +120,15 @@
client.getConnectionStateListenable().addListener(listener);
server = new TestingServer(server.getPort());
- Assert.assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
server.stop();
- Assert.assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
- Assert.assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+ assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
server.restart();
- Assert.assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
+ assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
server.close();
- Assert.assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
- Assert.assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+ assertEquals(stateVector.poll(waitingTiming.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java b/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java
index 852d9aa..7bcd93a 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java
@@ -19,26 +19,22 @@
package org.apache.curator.framework.client;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.imps.CuratorFrameworkImpl;
import org.apache.curator.framework.recipes.leader.LeaderSelector;
import org.apache.curator.framework.recipes.leader.LeaderSelectorListener;
import org.apache.curator.framework.recipes.leader.LeaderSelectorListenerAdapter;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
-import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.ZooDefs;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -86,21 +82,21 @@
client.getConnectionStateListenable().addListener(listener1);
log.debug("Starting ZK server");
server.restart();
- Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
+ assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
log.debug("Stopping ZK server");
server.stop();
- Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
- Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+ assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
log.debug("Starting ZK server");
server.restart();
- Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
+ assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
log.debug("Stopping ZK server");
server.close();
- Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
- Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
+ assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+ assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestCachedAtomicCounter.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestCachedAtomicCounter.java
index bdc03c2..28813fe 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestCachedAtomicCounter.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestCachedAtomicCounter.java
@@ -18,12 +18,16 @@
*/
package org.apache.curator.framework.recipes.atomic;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.atomic.AtomicReference;
public class TestCachedAtomicCounter extends BaseClassForTests
@@ -92,9 +96,9 @@
for ( int i = 0; i < FACTOR; ++i )
{
value = cachedLong.next();
- Assert.assertTrue(value.succeeded());
- Assert.assertEquals(value.preValue().longValue(), i);
- Assert.assertEquals(value.postValue().longValue(), i + 1);
+ assertTrue(value.succeeded());
+ assertEquals(value.preValue().longValue(), i);
+ assertEquals(value.postValue().longValue(), i + 1);
if ( i == 0 )
{
@@ -105,7 +109,7 @@
}
value = cachedLong.next();
- Assert.assertFalse(value.succeeded());
+ assertFalse(value.succeeded());
}
finally
{
@@ -125,9 +129,9 @@
for ( long i = 0; i < 200; ++i )
{
AtomicValue<Long> value = cachedLong.next();
- Assert.assertTrue(value.succeeded());
- Assert.assertEquals(value.preValue().longValue(), i);
- Assert.assertEquals(value.postValue().longValue(), i + 1);
+ assertTrue(value.succeeded());
+ assertEquals(value.preValue().longValue(), i);
+ assertEquals(value.postValue().longValue(), i + 1);
}
}
finally
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestDistributedAtomicLong.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestDistributedAtomicLong.java
index 9d9fe03..1cd0f96 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestDistributedAtomicLong.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/atomic/TestDistributedAtomicLong.java
@@ -18,6 +18,12 @@
*/
package org.apache.curator.framework.recipes.atomic;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import com.google.common.collect.Lists;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -27,9 +33,8 @@
import org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatistics;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-import org.testng.collections.Lists;
+import org.junit.jupiter.api.Test;
+
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.util.List;
@@ -58,11 +63,11 @@
}
catch ( BufferUnderflowException e )
{
- Assert.fail("", e);
+ fail("", e);
}
catch ( BufferOverflowException e )
{
- Assert.fail("", e);
+ fail("", e);
}
catch ( RuntimeException e )
{
@@ -84,13 +89,13 @@
client.start();
DistributedAtomicLong dal = new DistributedAtomicLong(client, "/counter", new RetryOneTime(1));
AtomicValue<Long> result = dal.compareAndSet(0L, 1L);
- Assert.assertFalse(result.succeeded());
+ assertFalse(result.succeeded());
- Assert.assertTrue(dal.initialize(0L));
+ assertTrue(dal.initialize(0L));
result = dal.compareAndSet(0L, 1L);
- Assert.assertTrue(result.succeeded());
+ assertTrue(result.succeeded());
- Assert.assertFalse(dal.initialize(0L));
+ assertFalse(dal.initialize(0L));
}
finally
{
@@ -130,11 +135,11 @@
};
dal.forceSet(1L);
- Assert.assertTrue(dal.compareAndSet(1L, 5L).succeeded());
- Assert.assertFalse(dal.compareAndSet(1L, 5L).succeeded());
+ assertTrue(dal.compareAndSet(1L, 5L).succeeded());
+ assertFalse(dal.compareAndSet(1L, 5L).succeeded());
doIncrement.set(true);
- Assert.assertFalse(dal.compareAndSet(5L, 10L).succeeded());
+ assertFalse(dal.compareAndSet(5L, 10L).succeeded());
}
finally
{
@@ -185,7 +190,7 @@
}
);
- Assert.assertTrue(dal.get().preValue() < 10);
+ assertTrue(dal.get().preValue() < 10);
}
finally
{
@@ -237,9 +242,9 @@
System.out.println("Min time: " + timingStats.getMin());
System.out.println("Qty: " + timingStats.getN());
- Assert.assertEquals(errors.get(), 0);
- Assert.assertTrue(optimisticTries.get() > 0);
- Assert.assertTrue(promotedLockTries.get() > 0);
+ assertEquals(errors.get(), 0);
+ assertTrue(optimisticTries.get() > 0);
+ assertTrue(promotedLockTries.get() > 0);
}
@Test
@@ -252,32 +257,32 @@
DistributedAtomicLong dal = new DistributedAtomicLong(client, "/foo/bar/counter", new RetryOneTime(1));
AtomicValue<Long> value = dal.increment();
- Assert.assertTrue(value.succeeded());
- Assert.assertEquals(value.getStats().getOptimisticTries(), 1);
- Assert.assertEquals(value.getStats().getPromotedLockTries(), 0);
- Assert.assertEquals(value.preValue().longValue(), 0L);
- Assert.assertEquals(value.postValue().longValue(), 1L);
+ assertTrue(value.succeeded());
+ assertEquals(value.getStats().getOptimisticTries(), 1);
+ assertEquals(value.getStats().getPromotedLockTries(), 0);
+ assertEquals(value.preValue().longValue(), 0L);
+ assertEquals(value.postValue().longValue(), 1L);
value = dal.decrement();
- Assert.assertTrue(value.succeeded());
- Assert.assertEquals(value.getStats().getOptimisticTries(), 1);
- Assert.assertEquals(value.getStats().getPromotedLockTries(), 0);
- Assert.assertEquals(value.preValue().longValue(), 1L);
- Assert.assertEquals(value.postValue().longValue(), 0L);
+ assertTrue(value.succeeded());
+ assertEquals(value.getStats().getOptimisticTries(), 1);
+ assertEquals(value.getStats().getPromotedLockTries(), 0);
+ assertEquals(value.preValue().longValue(), 1L);
+ assertEquals(value.postValue().longValue(), 0L);
value = dal.add(10L);
- Assert.assertTrue(value.succeeded());
- Assert.assertEquals(value.getStats().getOptimisticTries(), 1);
- Assert.assertEquals(value.getStats().getPromotedLockTries(), 0);
- Assert.assertEquals(value.preValue().longValue(), 0L);
- Assert.assertEquals(value.postValue().longValue(), 10L);
+ assertTrue(value.succeeded());
+ assertEquals(value.getStats().getOptimisticTries(), 1);
+ assertEquals(value.getStats().getPromotedLockTries(), 0);
+ assertEquals(value.preValue().longValue(), 0L);
+ assertEquals(value.postValue().longValue(), 10L);
value = dal.subtract(5L);
- Assert.assertTrue(value.succeeded());
- Assert.assertEquals(value.getStats().getOptimisticTries(), 1);
- Assert.assertEquals(value.getStats().getPromotedLockTries(), 0);
- Assert.assertEquals(value.preValue().longValue(), 10L);
- Assert.assertEquals(value.postValue().longValue(), 5L);
+ assertTrue(value.succeeded());
+ assertEquals(value.getStats().getOptimisticTries(), 1);
+ assertEquals(value.getStats().getPromotedLockTries(), 0);
+ assertEquals(value.preValue().longValue(), 10L);
+ assertEquals(value.postValue().longValue(), 5L);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedBarrier.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedBarrier.java
index a870367..f43a943 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedBarrier.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedBarrier.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.recipes.barriers;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Lists;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
@@ -25,8 +27,8 @@
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.apache.zookeeper.KeeperException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
@@ -66,7 +68,7 @@
barrier.waitOnBarrier(TIMEOUT * 2, TimeUnit.SECONDS);
future.get();
- Assert.fail();
+ fail();
}
catch ( KeeperException.ConnectionLossException expected )
{
@@ -159,7 +161,7 @@
client.start();
final DistributedBarrier barrier = new DistributedBarrier(client, "/barrier");
- Assert.assertTrue(barrier.waitOnBarrier(10, TimeUnit.SECONDS));
+ assertTrue(barrier.waitOnBarrier(10, TimeUnit.SECONDS));
// just for grins, test the infinite wait
ExecutorService service = Executors.newSingleThreadExecutor();
@@ -175,7 +177,7 @@
}
}
);
- Assert.assertTrue(future.get(10, TimeUnit.SECONDS) != null);
+ assertTrue(future.get(10, TimeUnit.SECONDS) != null);
}
finally
{
@@ -209,7 +211,7 @@
}
);
- Assert.assertTrue(barrier.waitOnBarrier(10, TimeUnit.SECONDS));
+ assertTrue(barrier.waitOnBarrier(10, TimeUnit.SECONDS));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedDoubleBarrier.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedDoubleBarrier.java
index 24fd3cb..aa4aaa6 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedDoubleBarrier.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/barriers/TestDistributedDoubleBarrier.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.recipes.barriers;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
@@ -25,8 +27,8 @@
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.Timing;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.io.Closeable;
import java.util.List;
import java.util.concurrent.Callable;
@@ -68,7 +70,7 @@
client.start();
DistributedDoubleBarrier barrier = new DistributedDoubleBarrier(client, "/barrier", QTY);
- Assert.assertTrue(barrier.enter(timing.seconds(), TimeUnit.SECONDS));
+ assertTrue(barrier.enter(timing.seconds(), TimeUnit.SECONDS));
synchronized(TestDistributedDoubleBarrier.this)
{
@@ -80,15 +82,15 @@
}
postEnterLatch.countDown();
- Assert.assertTrue(timing.awaitLatch(postEnterLatch));
+ assertTrue(timing.awaitLatch(postEnterLatch));
- Assert.assertEquals(count.get(), QTY);
+ assertEquals(count.get(), QTY);
- Assert.assertTrue(barrier.leave(timing.seconds(), TimeUnit.SECONDS));
+ assertTrue(barrier.leave(timing.seconds(), TimeUnit.SECONDS));
count.decrementAndGet();
postLeaveLatch.countDown();
- Assert.assertTrue(timing.awaitLatch(postEnterLatch));
+ assertTrue(timing.awaitLatch(postEnterLatch));
}
finally
{
@@ -106,8 +108,8 @@
{
f.get();
}
- Assert.assertEquals(count.get(), 0);
- Assert.assertEquals(max.get(), QTY);
+ assertEquals(count.get(), 0);
+ assertEquals(max.get(), QTY);
}
@Test
@@ -138,19 +140,19 @@
protected List<String> getChildrenForEntering() throws Exception
{
semaphore.release();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
return super.getChildrenForEntering();
}
};
- Assert.assertTrue(barrier.enter(timing.seconds(), TimeUnit.SECONDS));
- Assert.assertTrue(barrier.leave(timing.seconds(), TimeUnit.SECONDS));
+ assertTrue(barrier.enter(timing.seconds(), TimeUnit.SECONDS));
+ assertTrue(barrier.leave(timing.seconds(), TimeUnit.SECONDS));
return null;
}
}
);
}
- Assert.assertTrue(semaphore.tryAcquire(QTY + 1, timing.seconds(), TimeUnit.SECONDS)); // wait until all QTY+1 barriers are trying to enter
+ assertTrue(semaphore.tryAcquire(QTY + 1, timing.seconds(), TimeUnit.SECONDS)); // wait until all QTY+1 barriers are trying to enter
latch.countDown();
for ( int i = 0; i < (QTY + 1); ++i )
@@ -193,7 +195,7 @@
{
DistributedDoubleBarrier barrier = new DistributedDoubleBarrier(client, "/barrier", QTY);
- Assert.assertTrue(barrier.enter(timing.seconds(), TimeUnit.SECONDS));
+ assertTrue(barrier.enter(timing.seconds(), TimeUnit.SECONDS));
synchronized(TestDistributedDoubleBarrier.this)
{
@@ -205,15 +207,15 @@
}
postEnterLatch.countDown();
- Assert.assertTrue(timing.awaitLatch(postEnterLatch));
+ assertTrue(timing.awaitLatch(postEnterLatch));
- Assert.assertEquals(count.get(), QTY);
+ assertEquals(count.get(), QTY);
- Assert.assertTrue(barrier.leave(10, TimeUnit.SECONDS));
+ assertTrue(barrier.leave(10, TimeUnit.SECONDS));
count.decrementAndGet();
postLeaveLatch.countDown();
- Assert.assertTrue(timing.awaitLatch(postLeaveLatch));
+ assertTrue(timing.awaitLatch(postLeaveLatch));
return null;
}
@@ -226,8 +228,8 @@
{
f.get();
}
- Assert.assertEquals(count.get(), 0);
- Assert.assertEquals(max.get(), QTY);
+ assertEquals(count.get(), 0);
+ assertEquals(max.get(), QTY);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
index dfeb2ff..2a5adf6 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
@@ -27,14 +27,21 @@
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class BaseTestTreeCache extends BaseClassForTests
{
CuratorFramework client;
@@ -96,7 +103,7 @@
}
@Override
- @BeforeMethod(alwaysRun = true)
+ @BeforeEach
public void setup() throws Exception
{
super.setup();
@@ -111,14 +118,14 @@
}
@Override
- @AfterMethod(alwaysRun = true)
+ @AfterEach
public void teardown() throws Exception
{
try
{
try
{
- Assert.assertFalse(hadBackgroundException.get(), "Background exceptions were thrown, see stderr for details");
+ assertFalse(hadBackgroundException.get(), "Background exceptions were thrown, see stderr for details");
assertNoMoreEvents();
}
finally
@@ -139,7 +146,7 @@
void assertNoMoreEvents() throws InterruptedException
{
timing.sleepABit();
- Assert.assertTrue(events.isEmpty(), String.format("Expected no events, found %d; first event: %s", events.size(), events.peek()));
+ assertTrue(events.isEmpty(), String.format("Expected no events, found %d; first event: %s", events.size(), events.peek()));
}
/**
@@ -169,7 +176,7 @@
TreeCacheEvent assertEvent(TreeCacheEvent.Type expectedType, String expectedPath, byte[] expectedData, boolean ignoreConnectionEvents) throws InterruptedException
{
TreeCacheEvent event = events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(event, String.format("Expected type: %s, path: %s", expectedType, expectedPath));
+ assertNotNull(event, String.format("Expected type: %s, path: %s", expectedType, expectedPath));
if ( ignoreConnectionEvents )
{
if ( (event.getType() == TreeCacheEvent.Type.CONNECTION_SUSPENDED) || (event.getType() == TreeCacheEvent.Type.CONNECTION_LOST) || (event.getType() == TreeCacheEvent.Type.CONNECTION_RECONNECTED) )
@@ -179,28 +186,28 @@
}
String message = event.toString();
- Assert.assertEquals(event.getType(), expectedType, message);
+ assertEquals(event.getType(), expectedType, message);
if ( expectedPath == null )
{
- Assert.assertNull(event.getData(), message);
+ assertNull(event.getData(), message);
}
else
{
- Assert.assertNotNull(event.getData(), message);
- Assert.assertEquals(event.getData().getPath(), expectedPath, message);
+ assertNotNull(event.getData(), message);
+ assertEquals(event.getData().getPath(), expectedPath, message);
}
if ( expectedData != null )
{
- Assert.assertEquals(event.getData().getData(), expectedData, message);
+ assertArrayEquals(event.getData().getData(), expectedData, message);
}
if ( event.getType() == TreeCacheEvent.Type.NODE_UPDATED)
{
- Assert.assertNotNull(event.getOldData());
+ assertNotNull(event.getOldData());
}
else
{
- Assert.assertNull(event.getOldData());
+ assertNull(event.getOldData());
}
return event;
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCache.java
index 993a4c9..2667213 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCache.java
@@ -19,20 +19,23 @@
package org.apache.curator.framework.recipes.cache;
+import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.DO_NOT_CLEAR_ON_CLOSE;
+import static org.apache.curator.framework.recipes.cache.CuratorCacheListener.builder;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.compatibility.CuratorTestBase;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.DO_NOT_CLEAR_ON_CLOSE;
-import static org.apache.curator.framework.recipes.cache.CuratorCacheListener.builder;
-
-@Test(groups = CuratorTestBase.zk36Group)
+@Tag(CuratorTestBase.zk36Group)
public class TestCuratorCache extends CuratorTestBase
{
@Test
@@ -52,10 +55,10 @@
cache.start();
client.create().forPath("/test/foo", "first".getBytes());
- Assert.assertTrue(timing.awaitLatch(addedLatch));
+ assertTrue(timing.awaitLatch(addedLatch));
client.setData().forPath("/test/foo", "something new".getBytes());
- Assert.assertTrue(timing.awaitLatch(updatedLatch));
+ assertTrue(timing.awaitLatch(updatedLatch));
}
}
}
@@ -90,14 +93,14 @@
};
cache.listenable().addListener(builder().forAll(listener).afterInitialized().build());
cache.start();
- Assert.assertTrue(timing.awaitLatch(initializedLatch));
+ assertTrue(timing.awaitLatch(initializedLatch));
- Assert.assertEquals(initializedLatch.getCount(), 0);
- Assert.assertEquals(cache.size(), 4);
- Assert.assertTrue(cache.get("/test").isPresent());
- Assert.assertTrue(cache.get("/test/one").isPresent());
- Assert.assertTrue(cache.get("/test/one/two").isPresent());
- Assert.assertTrue(cache.get("/test/one/two/three").isPresent());
+ assertEquals(initializedLatch.getCount(), 0);
+ assertEquals(cache.size(), 4);
+ assertTrue(cache.get("/test").isPresent());
+ assertTrue(cache.get("/test/one").isPresent());
+ assertTrue(cache.get("/test/one/two").isPresent());
+ assertTrue(cache.get("/test/one/two/three").isPresent());
}
}
}
@@ -121,25 +124,25 @@
cache.start();
client.create().forPath("/test");
- Assert.assertTrue(timing.acquireSemaphore(all, 1));
- Assert.assertTrue(timing.acquireSemaphore(creates, 1));
- Assert.assertTrue(timing.acquireSemaphore(createsAndChanges, 1));
- Assert.assertEquals(changes.availablePermits(), 0);
- Assert.assertEquals(deletes.availablePermits(), 0);
+ assertTrue(timing.acquireSemaphore(all, 1));
+ assertTrue(timing.acquireSemaphore(creates, 1));
+ assertTrue(timing.acquireSemaphore(createsAndChanges, 1));
+ assertEquals(changes.availablePermits(), 0);
+ assertEquals(deletes.availablePermits(), 0);
client.setData().forPath("/test", "new".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(all, 1));
- Assert.assertTrue(timing.acquireSemaphore(changes, 1));
- Assert.assertTrue(timing.acquireSemaphore(createsAndChanges, 1));
- Assert.assertEquals(creates.availablePermits(), 0);
- Assert.assertEquals(deletes.availablePermits(), 0);
+ assertTrue(timing.acquireSemaphore(all, 1));
+ assertTrue(timing.acquireSemaphore(changes, 1));
+ assertTrue(timing.acquireSemaphore(createsAndChanges, 1));
+ assertEquals(creates.availablePermits(), 0);
+ assertEquals(deletes.availablePermits(), 0);
client.delete().forPath("/test");
- Assert.assertTrue(timing.acquireSemaphore(all, 1));
- Assert.assertTrue(timing.acquireSemaphore(deletes, 1));
- Assert.assertEquals(creates.availablePermits(), 0);
- Assert.assertEquals(changes.availablePermits(), 0);
- Assert.assertEquals(createsAndChanges.availablePermits(), 0);
+ assertTrue(timing.acquireSemaphore(all, 1));
+ assertTrue(timing.acquireSemaphore(deletes, 1));
+ assertEquals(creates.availablePermits(), 0);
+ assertEquals(changes.availablePermits(), 0);
+ assertEquals(createsAndChanges.availablePermits(), 0);
}
}
}
@@ -161,7 +164,7 @@
client.create().forPath("/test/bar", "bar".getBytes());
timing.sleepABit();
}
- Assert.assertEquals(storage.size(), 2);
+ assertEquals(storage.size(), 2);
try ( CuratorCache cache = CuratorCache.build(client, "/test") )
{
@@ -170,7 +173,7 @@
timing.sleepABit();
}
- Assert.assertEquals(storage.size(), 0);
+ assertEquals(storage.size(), 0);
}
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheBridge.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheBridge.java
index b663ff2..1c0f8cd 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheBridge.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheBridge.java
@@ -19,13 +19,15 @@
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.Compatibility;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class TestCuratorCacheBridge extends CuratorTestBase
{
@@ -37,13 +39,13 @@
CuratorCacheBridge cache = CuratorCache.bridgeBuilder(client, "/foo").build();
if ( Compatibility.hasPersistentWatchers() )
{
- Assert.assertTrue(cache instanceof CuratorCacheImpl);
- Assert.assertTrue(cache.isCuratorCache());
+ assertTrue(cache instanceof CuratorCacheImpl);
+ assertTrue(cache.isCuratorCache());
}
else
{
- Assert.assertTrue(cache instanceof CompatibleCuratorCacheBridge);
- Assert.assertFalse(cache.isCuratorCache());
+ assertTrue(cache instanceof CompatibleCuratorCacheBridge);
+ assertFalse(cache.isCuratorCache());
}
}
}
@@ -55,8 +57,8 @@
try (CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)))
{
CuratorCacheBridge cache = CuratorCache.bridgeBuilder(client, "/foo").build();
- Assert.assertTrue(cache instanceof CompatibleCuratorCacheBridge);
- Assert.assertFalse(cache.isCuratorCache());
+ assertTrue(cache instanceof CompatibleCuratorCacheBridge);
+ assertFalse(cache.isCuratorCache());
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheConsistency.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheConsistency.java
index 6cf51d8..2f9eb52 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheConsistency.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheConsistency.java
@@ -19,6 +19,10 @@
package org.apache.curator.framework.recipes.cache;
+import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.DO_NOT_CLEAR_ON_CLOSE;
+import static org.apache.curator.framework.recipes.cache.CuratorCacheListener.builder;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
@@ -26,10 +30,10 @@
import org.apache.curator.test.TestingCluster;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.ZKPaths;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.io.Closeable;
import java.time.Duration;
import java.time.Instant;
@@ -45,14 +49,11 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.DO_NOT_CLEAR_ON_CLOSE;
-import static org.apache.curator.framework.recipes.cache.CuratorCacheListener.builder;
-
/**
* Randomly create nodes in a tree while a set of CuratorCaches listens. Afterwards, validate
* that the caches contain the same values as ZK itself
*/
-@Test(groups = CuratorTestBase.zk36Group)
+@Tag(CuratorTestBase.zk36Group)
public class TestCuratorCacheConsistency extends CuratorTestBase
{
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -166,7 +167,7 @@
log.error("");
});
- Assert.fail("Errors found");
+ fail("Errors found");
}
}
@@ -192,7 +193,7 @@
}
catch ( Exception e )
{
- Assert.fail("", e);
+ fail("", e);
}
}
@@ -229,7 +230,7 @@
Exception errorSignalException = errorSignal.get();
if ( errorSignalException != null )
{
- Assert.fail("A client's error handler was called", errorSignalException);
+ fail("A client's error handler was called", errorSignalException);
}
Duration elapsedFromLastServerKill = Duration.between(lastServerKill, Instant.now());
@@ -267,7 +268,7 @@
}
catch ( Exception e )
{
- Assert.fail("Could not create/set: " + thisPath);
+ fail("Could not create/set: " + thisPath);
}
}
@@ -283,7 +284,7 @@
}
catch ( Exception e )
{
- Assert.fail("Could not delete: " + thisPath);
+ fail("Could not delete: " + thisPath);
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEdges.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEdges.java
index 2573bf6..ba588af 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEdges.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEdges.java
@@ -19,6 +19,11 @@
package org.apache.curator.framework.recipes.cache;
+import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.DO_NOT_CLEAR_ON_CLOSE;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.state.ConnectionState;
@@ -26,13 +31,12 @@
import org.apache.curator.test.InstanceSpec;
import org.apache.curator.test.TestingCluster;
import org.apache.curator.test.compatibility.CuratorTestBase;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
-import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.DO_NOT_CLEAR_ON_CLOSE;
-
-@Test(groups = CuratorTestBase.zk36Group)
+@Tag(CuratorTestBase.zk36Group)
public class TestCuratorCacheEdges extends CuratorTestBase
{
@Test
@@ -59,7 +63,7 @@
CountDownLatch latch = new CountDownLatch(1);
cache.listenable().addListener(CuratorCacheListener.builder().forInitialized(latch::countDown).build());
cache.start();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
// we now have a storage loaded with the initial nodes created
@@ -83,21 +87,21 @@
CountDownLatch latch = new CountDownLatch(1);
cache.listenable().addListener(CuratorCacheListener.builder().forInitialized(latch::countDown).build());
cache.start();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
- Assert.assertEquals(storage.size(), 11);
- Assert.assertEquals(storage.get("/root").map(ChildData::getData).orElse(null), second);
- Assert.assertEquals(storage.get("/root/1").map(ChildData::getData).orElse(null), first);
- Assert.assertEquals(storage.get("/root/1/11").map(ChildData::getData).orElse(null), first);
- Assert.assertEquals(storage.get("/root/1/11/111").map(ChildData::getData).orElse(null), second);
- Assert.assertEquals(storage.get("/root/1/11/111/1111").map(ChildData::getData).orElse(null), second);
- Assert.assertEquals(storage.get("/root/1/11/111/1112").map(ChildData::getData).orElse(null), second);
- Assert.assertEquals(storage.get("/root/1/12").map(ChildData::getData).orElse(null), first);
- Assert.assertEquals(storage.get("/root/1/13").map(ChildData::getData).orElse(null), first);
- Assert.assertEquals(storage.get("/root/1/13/131").map(ChildData::getData).orElse(null), second);
- Assert.assertEquals(storage.get("/root/1/13/132").map(ChildData::getData).orElse(null), second);
- Assert.assertEquals(storage.get("/root/1/13/132/1321").map(ChildData::getData).orElse(null), second);
+ assertEquals(storage.size(), 11);
+ assertArrayEquals(storage.get("/root").map(ChildData::getData).orElse(null), second);
+ assertArrayEquals(storage.get("/root/1").map(ChildData::getData).orElse(null), first);
+ assertArrayEquals(storage.get("/root/1/11").map(ChildData::getData).orElse(null), first);
+ assertArrayEquals(storage.get("/root/1/11/111").map(ChildData::getData).orElse(null), second);
+ assertArrayEquals(storage.get("/root/1/11/111/1111").map(ChildData::getData).orElse(null), second);
+ assertArrayEquals(storage.get("/root/1/11/111/1112").map(ChildData::getData).orElse(null), second);
+ assertArrayEquals(storage.get("/root/1/12").map(ChildData::getData).orElse(null), first);
+ assertArrayEquals(storage.get("/root/1/13").map(ChildData::getData).orElse(null), first);
+ assertArrayEquals(storage.get("/root/1/13/131").map(ChildData::getData).orElse(null), second);
+ assertArrayEquals(storage.get("/root/1/13/132").map(ChildData::getData).orElse(null), second);
+ assertArrayEquals(storage.get("/root/1/13/132/1321").map(ChildData::getData).orElse(null), second);
}
}
@@ -131,16 +135,16 @@
client.create().forPath("/test/two");
client.create().forPath("/test/three");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
InstanceSpec connectionInstance = cluster.findConnectionInstance(client.getZookeeperClient().getZooKeeper());
cluster.killServer(connectionInstance);
- Assert.assertTrue(timing.awaitLatch(reconnectLatch));
+ assertTrue(timing.awaitLatch(reconnectLatch));
timing.sleepABit();
- Assert.assertEquals(cache.stream().count(), 4);
+ assertEquals(cache.stream().count(), 4);
}
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEventOrdering.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEventOrdering.java
index 2f86040..d212116 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEventOrdering.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheEventOrdering.java
@@ -20,10 +20,10 @@
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.test.compatibility.CuratorTestBase;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
import java.util.concurrent.BlockingQueue;
-@Test(groups = CuratorTestBase.zk36Group)
+@Tag(CuratorTestBase.zk36Group)
public class TestCuratorCacheEventOrdering extends TestEventOrdering<CuratorCache>
{
@Override
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheWrappers.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheWrappers.java
index a757054..056e9cc 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheWrappers.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestCuratorCacheWrappers.java
@@ -19,13 +19,22 @@
package org.apache.curator.framework.recipes.cache;
+import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.SINGLE_NODE_CACHE;
+import static org.apache.curator.framework.recipes.cache.CuratorCacheAccessor.parentPathFilter;
+import static org.apache.curator.framework.recipes.cache.CuratorCacheListener.builder;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.ImmutableSet;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.compatibility.CuratorTestBase;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.AbstractMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
@@ -35,13 +44,9 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
-import static org.apache.curator.framework.recipes.cache.CuratorCache.Options.SINGLE_NODE_CACHE;
-import static org.apache.curator.framework.recipes.cache.CuratorCacheAccessor.parentPathFilter;
-import static org.apache.curator.framework.recipes.cache.CuratorCacheListener.builder;
import java.util.concurrent.CopyOnWriteArrayList;
-@Test(groups = CuratorTestBase.zk36Group)
+@Tag(CuratorTestBase.zk36Group)
public class TestCuratorCacheWrappers extends CuratorTestBase
{
@Test
@@ -67,14 +72,14 @@
cache.start();
client.create().forPath("/test/one", "hey there".getBytes());
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
client.setData().forPath("/test/one", "sup!".getBytes());
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
- Assert.assertEquals(new String(cache.get("/test/one").orElseThrow(AssertionError::new).getData()), "sup!");
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
+ assertEquals(new String(cache.get("/test/one").orElseThrow(AssertionError::new).getData()), "sup!");
client.delete().forPath("/test/one");
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
// Please note that there is not guarantee on the order of events
// For instance INITIALIZED event can appear in the middle of the observed sequence.
@@ -83,16 +88,16 @@
case CHILD_ADDED:
case CHILD_REMOVED:
case CHILD_UPDATED:
- Assert.assertEquals("/test/one", event.getData().getPath());
+ assertEquals("/test/one", event.getData().getPath());
break;
case INITIALIZED:
- Assert.assertNull(event.getData());
+ assertNull(event.getData());
break;
default:
- Assert.fail();
+ fail();
}
}
- Assert.assertEquals(eventsTrace.size(), 4);
+ assertEquals(eventsTrace.size(), 4);
}
}
}
@@ -113,26 +118,26 @@
treeCacheBase.assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
treeCacheBase.assertEvent(TreeCacheEvent.Type.INITIALIZED);
- Assert.assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of());
- Assert.assertEquals(cache.stream().filter(parentPathFilter("/t")).count(), 0);
- Assert.assertEquals(cache.stream().filter(parentPathFilter("/testing")).count(), 0);
+ assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of());
+ assertEquals(cache.stream().filter(parentPathFilter("/t")).count(), 0);
+ assertEquals(cache.stream().filter(parentPathFilter("/testing")).count(), 0);
client.create().forPath("/test/one", "hey there".getBytes());
treeCacheBase.assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
- Assert.assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of("/test/one"));
- Assert.assertEquals(new String(cache.get("/test/one").orElseThrow(AssertionError::new).getData()), "hey there");
- Assert.assertEquals(toMap(cache.stream().filter(parentPathFilter("/test/one"))).keySet(), ImmutableSet.of());
- Assert.assertEquals(cache.stream().filter(parentPathFilter("/test/o")).count(), 0);
- Assert.assertEquals(cache.stream().filter(parentPathFilter("/test/onely")).count(), 0);
+ assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of("/test/one"));
+ assertEquals(new String(cache.get("/test/one").orElseThrow(AssertionError::new).getData()), "hey there");
+ assertEquals(toMap(cache.stream().filter(parentPathFilter("/test/one"))).keySet(), ImmutableSet.of());
+ assertEquals(cache.stream().filter(parentPathFilter("/test/o")).count(), 0);
+ assertEquals(cache.stream().filter(parentPathFilter("/test/onely")).count(), 0);
client.setData().forPath("/test/one", "sup!".getBytes());
treeCacheBase.assertEvent(TreeCacheEvent.Type.NODE_UPDATED, "/test/one");
- Assert.assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of("/test/one"));
- Assert.assertEquals(new String(cache.get("/test/one").orElseThrow(AssertionError::new).getData()), "sup!");
+ assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of("/test/one"));
+ assertEquals(new String(cache.get("/test/one").orElseThrow(AssertionError::new).getData()), "sup!");
client.delete().forPath("/test/one");
treeCacheBase.assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/one", "sup!".getBytes());
- Assert.assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of());
+ assertEquals(toMap(cache.stream().filter(parentPathFilter("/test"))).keySet(), ImmutableSet.of());
}
}
}
@@ -155,7 +160,7 @@
try
{
getRootData.get();
- Assert.fail("Should have thrown");
+ fail("Should have thrown");
}
catch ( AssertionError expected )
{
@@ -163,19 +168,19 @@
}
client.create().forPath("/test/node", "a".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(getRootData.get().getData(), "a".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertArrayEquals(getRootData.get().getData(), "a".getBytes());
client.setData().forPath("/test/node", "b".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(getRootData.get().getData(), "b".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertArrayEquals(getRootData.get().getData(), "b".getBytes());
client.delete().forPath("/test/node");
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
try
{
getRootData.get();
- Assert.fail("Should have thrown");
+ fail("Should have thrown");
}
catch ( AssertionError expected )
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
index 3d369e1..d039fa1 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
@@ -27,8 +29,8 @@
import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.KeeperException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.io.Closeable;
import java.util.List;
import java.util.Random;
@@ -135,7 +137,7 @@
};
executorService.submit(wrapped);
}
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
timing.sleepABit();
@@ -148,7 +150,7 @@
eventSuggestedQty += (event.eventType == EventType.ADDED) ? 1 : -1;
}
int actualQty = getActualQty(cache);
- Assert.assertEquals(actualQty, eventSuggestedQty, String.format("actual %s expected %s:\n %s", actualQty, eventSuggestedQty, asString(localEvents)));
+ assertEquals(actualQty, eventSuggestedQty, String.format("actual %s expected %s:\n %s", actualQty, eventSuggestedQty, asString(localEvents)));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
index bed4606..28a53da 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
@@ -18,6 +18,13 @@
*/
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.compatibility.CuratorTestBase;
@@ -28,8 +35,9 @@
import org.apache.curator.framework.api.UnhandledErrorListener;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.Timing;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Exchanger;
@@ -40,7 +48,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestNodeCache extends BaseClassForTests
{
@Test
@@ -81,20 +89,20 @@
);
cache.start(true);
- Assert.assertEquals(cache.getCurrentData().getData(), "one".getBytes());
+ assertArrayEquals(cache.getCurrentData().getData(), "one".getBytes());
client.delete().forPath("/test/foo");
- Assert.assertTrue(semaphore.tryAcquire(1, 10, TimeUnit.SECONDS));
+ assertTrue(semaphore.tryAcquire(1, 10, TimeUnit.SECONDS));
client.create().forPath("/test/foo", "two".getBytes());
- Assert.assertTrue(semaphore.tryAcquire(1, 10, TimeUnit.SECONDS));
+ assertTrue(semaphore.tryAcquire(1, 10, TimeUnit.SECONDS));
Throwable t = error.get();
if ( t != null )
{
- Assert.fail("Assert", t);
+ fail("Assert", t);
}
- Assert.assertEquals(cache.getCurrentData().getData(), "two".getBytes());
+ assertArrayEquals(cache.getCurrentData().getData(), "two".getBytes());
cache.close();
}
@@ -147,7 +155,7 @@
client.setData().forPath("/test/snafu", "other".getBytes());
ChildData currentData = finalCache.getCurrentData();
- Assert.assertNotNull(currentData);
+ assertNotNull(currentData);
finalCache.rebuildTestExchanger.exchange(new Object(), timing2.forWaiting().seconds(), TimeUnit.SECONDS);
@@ -158,9 +166,9 @@
cache.start(false);
future.get();
- Assert.assertTrue(timing2.awaitLatch(latch));
- Assert.assertNotNull(cache.getCurrentData());
- Assert.assertEquals(cache.getCurrentData().getData(), "other".getBytes());
+ assertTrue(timing2.awaitLatch(latch));
+ assertNotNull(cache.getCurrentData());
+ assertArrayEquals(cache.getCurrentData().getData(), "other".getBytes());
}
finally
{
@@ -200,10 +208,10 @@
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
Thread.sleep(timing.multiple(1.5).session());
- Assert.assertEquals(cache.getCurrentData().getData(), "start".getBytes());
+ assertArrayEquals(cache.getCurrentData().getData(), "start".getBytes());
client.setData().forPath("/test/node", "new data".getBytes());
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
finally
{
@@ -239,19 +247,19 @@
}
);
- Assert.assertNull(cache.getCurrentData());
+ assertNull(cache.getCurrentData());
client.create().forPath("/test/node", "a".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(cache.getCurrentData().getData(), "a".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertArrayEquals(cache.getCurrentData().getData(), "a".getBytes());
client.setData().forPath("/test/node", "b".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(cache.getCurrentData().getData(), "b".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertArrayEquals(cache.getCurrentData().getData(), "b".getBytes());
client.delete().forPath("/test/node");
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertNull(cache.getCurrentData());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertNull(cache.getCurrentData());
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
index 11a25fe..3790b34 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
@@ -19,6 +19,14 @@
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
@@ -36,16 +44,15 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import static org.testng.AssertJUnit.assertNotNull;
-
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestPathChildrenCache extends BaseClassForTests
{
@Test
@@ -64,7 +71,7 @@
startedLatch.countDown();
}
});
- Assert.assertTrue(timing.awaitLatch(startedLatch));
+ assertTrue(timing.awaitLatch(startedLatch));
final BlockingQueue<PathChildrenCacheEvent.Type> events = Queues.newLinkedBlockingQueue();
PathChildrenCacheListener listener = new PathChildrenCacheListener()
@@ -77,23 +84,23 @@
};
cache.getListenable().addListener(listener);
cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
- Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.INITIALIZED);
+ assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.INITIALIZED);
client.create().forPath("/a/b/test/one");
client.create().forPath("/a/b/test/two");
- Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
- Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
client.delete().forPath("/a/b/test/one");
client.delete().forPath("/a/b/test/two");
client.delete().forPath("/a/b/test");
- Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
- Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
+ assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
+ assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
timing.sleepABit();
client.create().creatingParentContainersIfNeeded().forPath("/a/b/test/new");
- Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
}
finally
{
@@ -143,8 +150,8 @@
cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
- Assert.assertTrue(timing.awaitLatch(cacheInitialized));
- Assert.assertEquals(cache.getCurrentData().size(), 0);
+ assertTrue(timing.awaitLatch(cacheInitialized));
+ assertEquals(cache.getCurrentData().size(), 0);
}
finally
{
@@ -197,7 +204,7 @@
};
cache.getListenable().addListener(listener);
cache.start();
- Assert.assertTrue(timing.awaitLatch(ensurePathLatch));
+ assertTrue(timing.awaitLatch(ensurePathLatch));
final CountDownLatch connectedLatch = new CountDownLatch(1);
client.getConnectionStateListenable().addListener(new ConnectionStateListener()
@@ -215,15 +222,15 @@
server = new TestingServer(serverPort, true);
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
client.create().creatingParentContainersIfNeeded().forPath("/baz", new byte[]{1, 2, 3});
- assertNotNull("/baz does not exist", client.checkExists().forPath("/baz"));
+ assertNotNull(client.checkExists().forPath("/baz"), "/baz does not exist");
- Assert.assertTrue(timing.awaitLatch(addedLatch));
+ assertTrue(timing.awaitLatch(addedLatch));
- assertNotNull("cache doesn't see /baz", cache.getCurrentData("/baz"));
+ assertNotNull(cache.getCurrentData("/baz"), "cache doesn't see /baz");
}
finally
{
@@ -258,7 +265,7 @@
}
);
cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
finally
{
@@ -296,11 +303,11 @@
cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
PathChildrenCacheEvent event = events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertEquals(event.getType(), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(event.getType(), PathChildrenCacheEvent.Type.CHILD_ADDED);
event = events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertEquals(event.getType(), PathChildrenCacheEvent.Type.INITIALIZED);
- Assert.assertEquals(event.getInitialData().size(), 1);
+ assertEquals(event.getType(), PathChildrenCacheEvent.Type.INITIALIZED);
+ assertEquals(event.getInitialData().size(), 1);
}
finally
{
@@ -349,12 +356,12 @@
cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
- Assert.assertTrue(timing.awaitLatch(addedLatch));
- Assert.assertTrue(timing.awaitLatch(initLatch));
- Assert.assertEquals(cache.getCurrentData().size(), 3);
- Assert.assertEquals(cache.getCurrentData().get(0).getData(), "1".getBytes());
- Assert.assertEquals(cache.getCurrentData().get(1).getData(), "2".getBytes());
- Assert.assertEquals(cache.getCurrentData().get(2).getData(), "3".getBytes());
+ assertTrue(timing.awaitLatch(addedLatch));
+ assertTrue(timing.awaitLatch(initLatch));
+ assertEquals(cache.getCurrentData().size(), 3);
+ assertArrayEquals(cache.getCurrentData().get(0).getData(), "1".getBytes());
+ assertArrayEquals(cache.getCurrentData().get(1).getData(), "2".getBytes());
+ assertArrayEquals(cache.getCurrentData().get(2).getData(), "3".getBytes());
}
finally
{
@@ -384,7 +391,7 @@
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception
{
- Assert.assertNotEquals(event.getType(), PathChildrenCacheEvent.Type.INITIALIZED);
+ assertNotEquals(event.getType(), PathChildrenCacheEvent.Type.INITIALIZED);
if ( event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED )
{
addedLatch.countDown();
@@ -399,11 +406,11 @@
cache.start(PathChildrenCache.StartMode.NORMAL);
- Assert.assertTrue(timing.awaitLatch(addedLatch));
- Assert.assertEquals(cache.getCurrentData().size(), 3);
- Assert.assertEquals(cache.getCurrentData().get(0).getData(), "1".getBytes());
- Assert.assertEquals(cache.getCurrentData().get(1).getData(), "2".getBytes());
- Assert.assertEquals(cache.getCurrentData().get(2).getData(), "3".getBytes());
+ assertTrue(timing.awaitLatch(addedLatch));
+ assertEquals(cache.getCurrentData().size(), 3);
+ assertArrayEquals(cache.getCurrentData().get(0).getData(), "1".getBytes());
+ assertArrayEquals(cache.getCurrentData().get(1).getData(), "2".getBytes());
+ assertArrayEquals(cache.getCurrentData().get(2).getData(), "3".getBytes());
}
finally
{
@@ -447,10 +454,10 @@
cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
client.create().forPath("/test/foo", "first".getBytes());
- Assert.assertTrue(timing.awaitLatch(addedLatch));
+ assertTrue(timing.awaitLatch(addedLatch));
client.setData().forPath("/test/foo", "something new".getBytes());
- Assert.assertTrue(timing.awaitLatch(updatedLatch));
+ assertTrue(timing.awaitLatch(updatedLatch));
}
finally
{
@@ -479,7 +486,7 @@
}
catch ( KeeperException.NoNodeException e )
{
- Assert.fail("Path should exist", e);
+ fail("Path should exist", e);
}
}
timing.sleepABit();
@@ -529,13 +536,13 @@
if ( event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED )
{
removedLatch.countDown();
- Assert.assertTrue(postRemovedLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(postRemovedLatch.await(10, TimeUnit.SECONDS));
}
else
{
try
{
- Assert.assertEquals(event.getData().getData(), "two".getBytes());
+ assertArrayEquals(event.getData().getData(), "two".getBytes());
}
finally
{
@@ -548,15 +555,15 @@
cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
client.delete().forPath("/test/foo");
- Assert.assertTrue(timing.awaitLatch(removedLatch));
+ assertTrue(timing.awaitLatch(removedLatch));
client.create().forPath("/test/foo", "two".getBytes());
postRemovedLatch.countDown();
- Assert.assertTrue(timing.awaitLatch(dataLatch));
+ assertTrue(timing.awaitLatch(dataLatch));
Throwable t = error.get();
if ( t != null )
{
- Assert.fail("Assert", t);
+ fail("Assert", t);
}
}
}
@@ -622,7 +629,7 @@
client.create().forPath("/test/test");
List<ChildData> currentData = cache.getCurrentData();
- Assert.assertTrue(currentData.size() > 0);
+ assertTrue(currentData.size() > 0);
// simulate another process removing a node while we're rebuilding
client.delete().forPath(currentData.get(0).getPath());
@@ -636,7 +643,7 @@
childData = cache.getCurrentData("/test/snafu");
Thread.sleep(1000);
}
- Assert.assertEquals(childData.getData(), "original".getBytes());
+ assertArrayEquals(childData.getData(), "original".getBytes());
client.setData().forPath("/test/snafu", "grilled".getBytes());
cache.rebuildTestExchanger.exchange(new Object());
@@ -648,10 +655,10 @@
cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
future.get();
- Assert.assertTrue(timing.awaitLatch(addedLatch));
- Assert.assertNotNull(cache.getCurrentData("/test/test"));
- Assert.assertNull(cache.getCurrentData(deletedPath.get()));
- Assert.assertEquals(cache.getCurrentData("/test/snafu").getData(), "grilled".getBytes());
+ assertTrue(timing.awaitLatch(addedLatch));
+ assertNotNull(cache.getCurrentData("/test/test"));
+ assertNull(cache.getCurrentData(deletedPath.get()));
+ assertArrayEquals(cache.getCurrentData("/test/snafu").getData(), "grilled".getBytes());
}
}
finally
@@ -694,13 +701,13 @@
);
cache.start();
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 3));
+ assertTrue(timing.acquireSemaphore(semaphore, 3));
client.delete().forPath("/base/a");
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
client.create().forPath("/base/a");
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
List<PathChildrenCacheEvent.Type> expected = Lists.newArrayList
(
@@ -710,7 +717,7 @@
PathChildrenCacheEvent.Type.CHILD_REMOVED,
PathChildrenCacheEvent.Type.CHILD_ADDED
);
- Assert.assertEquals(expected, events);
+ assertEquals(expected, events);
}
finally
{
@@ -754,17 +761,17 @@
cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
client.delete().forPath("/base/a");
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
client.create().forPath("/base/a");
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
List<PathChildrenCacheEvent.Type> expected = Lists.newArrayList
(
PathChildrenCacheEvent.Type.CHILD_REMOVED,
PathChildrenCacheEvent.Type.CHILD_ADDED
);
- Assert.assertEquals(expected, events);
+ assertEquals(expected, events);
}
finally
{
@@ -820,12 +827,12 @@
);
client.create().withMode(CreateMode.EPHEMERAL).forPath("/test/me", "data".getBytes());
- Assert.assertTrue(timing.awaitLatch(childAddedLatch));
+ assertTrue(timing.awaitLatch(childAddedLatch));
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
- Assert.assertTrue(timing.awaitLatch(removedLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(removedLatch));
}
finally
{
@@ -885,13 +892,13 @@
};
cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
int saveCounter = counter.get();
client.setData().forPath("/test/one", "alt".getBytes());
cache.rebuildNode("/test/one");
- Assert.assertEquals(cache.getCurrentData("/test/one").getData(), "alt".getBytes());
- Assert.assertEquals(saveCounter, counter.get());
+ assertArrayEquals(cache.getCurrentData("/test/one").getData(), "alt".getBytes());
+ assertEquals(saveCounter, counter.get());
semaphore.release(1000);
timing.sleepABit();
@@ -926,19 +933,19 @@
client.create().forPath("/test/one", "one".getBytes());
client.create().forPath("/test/two", "two".getBytes());
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
for ( ChildData data : cache.getCurrentData() )
{
if ( cacheData )
{
- Assert.assertNotNull(data.getData());
- Assert.assertNotNull(data.getStat());
+ assertNotNull(data.getData());
+ assertNotNull(data.getStat());
}
else
{
- Assert.assertNull(data.getData());
- Assert.assertNotNull(data.getStat());
+ assertNull(data.getData());
+ assertNotNull(data.getStat());
}
}
}
@@ -974,14 +981,14 @@
cache.start();
client.create().forPath("/test/one", "hey there".getBytes());
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
client.setData().forPath("/test/one", "sup!".getBytes());
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
client.delete().forPath("/test/one");
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
}
}
finally
@@ -1040,18 +1047,18 @@
cache2.start();
client.create().forPath("/test/one", "hey there".getBytes());
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
- Assert.assertEquals(events2.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events2.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
client.setData().forPath("/test/one", "sup!".getBytes());
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
- Assert.assertEquals(events2.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
- Assert.assertEquals(new String(cache2.getCurrentData("/test/one").getData()), "sup!");
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
+ assertEquals(events2.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
+ assertEquals(new String(cache2.getCurrentData("/test/one").getData()), "sup!");
client.delete().forPath("/test/one");
- Assert.assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
- Assert.assertEquals(events2.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
+ assertEquals(events.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
+ assertEquals(events2.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
}
}
}
@@ -1079,16 +1086,16 @@
client.create().forPath("/test/one", "hey there".getBytes());
cache.rebuild();
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
- Assert.assertTrue(exec.isExecuteCalled());
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertTrue(exec.isExecuteCalled());
exec.setExecuteCalled(false);
}
- Assert.assertFalse(exec.isExecuteCalled());
+ assertFalse(exec.isExecuteCalled());
client.delete().forPath("/test/one");
timing.sleepABit();
- Assert.assertFalse(exec.isExecuteCalled());
+ assertFalse(exec.isExecuteCalled());
}
finally
{
@@ -1137,7 +1144,7 @@
latch.await(5, TimeUnit.SECONDS);
- Assert.assertTrue(latch.getCount() == 1, "Unexpected exception occurred");
+ assertTrue(latch.getCount() == 1, "Unexpected exception occurred");
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCacheInCluster.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCacheInCluster.java
index a8a93a8..3b90254 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCacheInCluster.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCacheInCluster.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Queues;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.compatibility.CuratorTestBase;
@@ -28,17 +30,20 @@
import org.apache.curator.test.InstanceSpec;
import org.apache.curator.test.TestingCluster;
import org.apache.curator.test.Timing;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestPathChildrenCacheInCluster extends BaseClassForTests
{
- @Test(enabled = false) // this test is very flakey - it needs to be re-written at some point
+ @Test
+ @Disabled // this test is very flakey - it needs to be re-written at some point
public void testMissedDelete() throws Exception
{
Timing timing = new Timing();
@@ -68,22 +73,22 @@
client1.start();
client2.start();
cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
- Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED);
- Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.INITIALIZED);
+ assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED);
+ assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.INITIALIZED);
client2.create().creatingParentsIfNeeded().forPath("/test/node", "first".getBytes());
- Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+ assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
cluster.killServer(client1Instance);
- Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_SUSPENDED);
- Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_LOST);
+ assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_SUSPENDED);
+ assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_LOST);
client2.delete().forPath("/test/node");
client2.create().forPath("/test/node", "second".getBytes());
cluster.restartServer(client1Instance);
- Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED);
- Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED); // "/test/node" is different - should register as updated
+ assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED);
+ assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED); // "/test/node" is different - should register as updated
}
finally
{
@@ -141,14 +146,14 @@
client.create().forPath("/test/two");
client.create().forPath("/test/three");
- Assert.assertTrue(latch.get().await(10, TimeUnit.SECONDS));
+ assertTrue(latch.get().await(10, TimeUnit.SECONDS));
InstanceSpec connectionInstance = cluster.findConnectionInstance(client.getZookeeperClient().getZooKeeper());
cluster.killServer(connectionInstance);
- Assert.assertTrue(timing.awaitLatch(reconnectLatch));
+ assertTrue(timing.awaitLatch(reconnectLatch));
- Assert.assertEquals(cache.getCurrentData().size(), 3);
+ assertEquals(cache.getCurrentData().size(), 3);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
index 22b0369..2b9e491 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
@@ -19,6 +19,11 @@
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ImmutableSet;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.api.UnhandledErrorListener;
@@ -26,12 +31,13 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.CreateMode;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestTreeCache extends BaseTestTreeCache
{
@Test
@@ -92,10 +98,10 @@
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("1", "2", "3"));
- Assert.assertEquals(cache.getCurrentChildren("/test/1").keySet(), ImmutableSet.of());
- Assert.assertEquals(cache.getCurrentChildren("/test/2").keySet(), ImmutableSet.of("sub"));
- Assert.assertNull(cache.getCurrentChildren("/test/non_exist"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("1", "2", "3"));
+ assertEquals(cache.getCurrentChildren("/test/1").keySet(), ImmutableSet.of());
+ assertEquals(cache.getCurrentChildren("/test/2").keySet(), ImmutableSet.of("sub"));
+ assertNull(cache.getCurrentChildren("/test/non_exist"));
}
@Test
@@ -105,7 +111,7 @@
cache.start();
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertNull(client.checkExists().forPath("/one/two/three"));
+ assertNull(client.checkExists().forPath("/one/two/three"));
cache.close();
cache = buildWithListeners(TreeCache.newBuilder(client, "/one/two/three").setCreateParentNodes(true));
@@ -113,7 +119,7 @@
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/one/two/three");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
+ assertNotNull(client.checkExists().forPath("/one/two/three"));
}
@Test
@@ -157,10 +163,10 @@
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
- Assert.assertNull(cache.getCurrentData("/test/1"));
- Assert.assertNull(cache.getCurrentChildren("/test/1"));
- Assert.assertNull(cache.getCurrentData("/test/non_exist"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
+ assertNull(cache.getCurrentData("/test/1"));
+ assertNull(cache.getCurrentChildren("/test/1"));
+ assertNull(cache.getCurrentData("/test/non_exist"));
}
@Test
@@ -181,12 +187,12 @@
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("1", "2", "3"));
- Assert.assertEquals(cache.getCurrentChildren("/test/1").keySet(), ImmutableSet.of());
- Assert.assertEquals(cache.getCurrentChildren("/test/2").keySet(), ImmutableSet.of());
- Assert.assertNull(cache.getCurrentData("/test/2/sub"));
- Assert.assertNull(cache.getCurrentChildren("/test/2/sub"));
- Assert.assertNull(cache.getCurrentChildren("/test/non_exist"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("1", "2", "3"));
+ assertEquals(cache.getCurrentChildren("/test/1").keySet(), ImmutableSet.of());
+ assertEquals(cache.getCurrentChildren("/test/2").keySet(), ImmutableSet.of());
+ assertNull(cache.getCurrentData("/test/2/sub"));
+ assertNull(cache.getCurrentChildren("/test/2/sub"));
+ assertNull(cache.getCurrentChildren("/test/non_exist"));
}
@Test
@@ -238,10 +244,10 @@
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertTrue(cache.getCurrentChildren("/").keySet().contains("test"));
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
- Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertTrue(cache.getCurrentChildren("/").keySet().contains("test"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
+ assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
}
@Test
@@ -257,10 +263,10 @@
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertTrue(cache.getCurrentChildren("/").keySet().contains("test"));
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
- Assert.assertNull(cache.getCurrentData("/test/one"));
- Assert.assertNull(cache.getCurrentChildren("/test/one"));
+ assertTrue(cache.getCurrentChildren("/").keySet().contains("test"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
+ assertNull(cache.getCurrentData("/test/one"));
+ assertNull(cache.getCurrentChildren("/test/one"));
}
@Test
@@ -278,9 +284,9 @@
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
- Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
+ assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
}
@Test
@@ -299,11 +305,11 @@
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
- Assert.assertEquals(cache.getCurrentChildren("/").keySet(), ImmutableSet.of("foo", "test"));
- Assert.assertEquals(cache.getCurrentChildren("/foo").keySet(), ImmutableSet.of());
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
- Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertEquals(cache.getCurrentChildren("/").keySet(), ImmutableSet.of("foo", "test"));
+ assertEquals(cache.getCurrentChildren("/foo").keySet(), ImmutableSet.of());
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
+ assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
}
@Test
@@ -355,9 +361,9 @@
assertEvent(TreeCacheEvent.Type.NODE_UPDATED, "/test/foo");
assertNoMoreEvents();
- Assert.assertNotNull(cache.getCurrentData("/test/foo"));
+ assertNotNull(cache.getCurrentData("/test/foo"));
// No byte data querying the tree because we're not caching data.
- Assert.assertNull(cache.getCurrentData("/test/foo").getData());
+ assertNull(cache.getCurrentData("/test/foo").getData());
}
@Test
@@ -440,26 +446,26 @@
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
- Assert.assertNull(cache.getCurrentChildren("/t"));
- Assert.assertNull(cache.getCurrentChildren("/testing"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
+ assertNull(cache.getCurrentChildren("/t"));
+ assertNull(cache.getCurrentChildren("/testing"));
client.create().forPath("/test/one", "hey there".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
- Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
- Assert.assertNull(cache.getCurrentChildren("/test/o"));
- Assert.assertNull(cache.getCurrentChildren("/test/onely"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
+ assertNull(cache.getCurrentChildren("/test/o"));
+ assertNull(cache.getCurrentChildren("/test/onely"));
client.setData().forPath("/test/one", "sup!".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_UPDATED, "/test/one");
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
client.delete().forPath("/test/one");
assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/one", "sup!".getBytes());
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
assertNoMoreEvents();
}
@@ -477,13 +483,13 @@
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
- Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
- Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
- Assert.assertNull(cache.getCurrentChildren("/test/o"));
- Assert.assertNull(cache.getCurrentChildren("/test/onely"));
- Assert.assertNull(cache.getCurrentChildren("/t"));
- Assert.assertNull(cache.getCurrentChildren("/testing"));
+ assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
+ assertNull(cache.getCurrentChildren("/test/o"));
+ assertNull(cache.getCurrentChildren("/test/onely"));
+ assertNull(cache.getCurrentChildren("/t"));
+ assertNull(cache.getCurrentChildren("/testing"));
assertNoMoreEvents();
}
@@ -519,24 +525,24 @@
client.create().forPath("/test/one", "hey there".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
semaphore.acquire();
- Assert.assertEquals(new String(cache2.getCurrentData("/test/one").getData()), "hey there");
+ assertEquals(new String(cache2.getCurrentData("/test/one").getData()), "hey there");
client.setData().forPath("/test/one", "sup!".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_UPDATED, "/test/one");
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "sup!");
semaphore.acquire();
- Assert.assertEquals(new String(cache2.getCurrentData("/test/one").getData()), "sup!");
+ assertEquals(new String(cache2.getCurrentData("/test/one").getData()), "sup!");
client.delete().forPath("/test/one");
assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/one", "sup!".getBytes());
- Assert.assertNull(cache.getCurrentData("/test/one"));
+ assertNull(cache.getCurrentData("/test/one"));
semaphore.acquire();
- Assert.assertNull(cache2.getCurrentData("/test/one"));
+ assertNull(cache2.getCurrentData("/test/one"));
assertNoMoreEvents();
- Assert.assertEquals(semaphore.availablePermits(), 0);
+ assertEquals(semaphore.availablePermits(), 0);
}
finally
{
@@ -556,7 +562,7 @@
client.create().forPath("/test/one", "hey there".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
- Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
+ assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
cache.close();
assertNoMoreEvents();
@@ -620,7 +626,7 @@
@Override
public void unhandledError(String message, Throwable e)
{
- Assert.assertFalse(isProcessed.compareAndSet(false, true));
+ assertFalse(isProcessed.compareAndSet(false, true));
}
});
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheIteratorAndSize.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheIteratorAndSize.java
index 2d8dbb3..a0daae3 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheIteratorAndSize.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheIteratorAndSize.java
@@ -18,13 +18,17 @@
*/
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Sets;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.compatibility.CuratorTestBase;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -79,13 +83,13 @@
iteratorValues.put(next.getPath(), next.getData());
}
- Assert.assertEquals(iteratorValues.size(), nodes.length);
+ assertEquals(iteratorValues.size(), nodes.length);
for ( String node : nodes )
{
- Assert.assertEquals(iteratorValues.get(node), node.getBytes());
+ assertArrayEquals(iteratorValues.get(node), node.getBytes());
}
- Assert.assertEquals(treeCache.size(), nodes.length);
+ assertEquals(treeCache.size(), nodes.length);
}
}
}
@@ -125,19 +129,19 @@
timing.sleepABit(); // let the cache settle
- Assert.assertEquals(treeCache.size(), pathAndData.size());
+ assertEquals(treeCache.size(), pathAndData.size());
// at this point we have a cached graph of random nodes with random values
Iterator<ChildData> iterator = treeCache.iterator();
while ( iterator.hasNext() )
{
ChildData next = iterator.next();
- Assert.assertTrue(pathAndData.containsKey(next.getPath()));
- Assert.assertEquals(pathAndData.get(next.getPath()).getBytes(), next.getData());
+ assertTrue(pathAndData.containsKey(next.getPath()));
+ assertArrayEquals(pathAndData.get(next.getPath()).getBytes(), next.getData());
pathAndData.remove(next.getPath());
}
- Assert.assertEquals(pathAndData.size(), 0); // above loop should have removed all nodes
+ assertEquals(pathAndData.size(), 0); // above loop should have removed all nodes
}
}
}
@@ -154,8 +158,8 @@
treeCache.start();
Iterator<ChildData> iterator = treeCache.iterator();
- Assert.assertFalse(iterator.hasNext());
- Assert.assertEquals(treeCache.size(), 0);
+ assertFalse(iterator.hasNext());
+ assertEquals(treeCache.size(), 0);
}
}
}
@@ -193,8 +197,8 @@
paths.add(next.getPath());
}
- Assert.assertEquals(paths, Sets.newHashSet("/foo", "/foo/a1", "/foo/a2", "/foo/a2/a2.1", "/foo/a3", "/foo/a3/a3.2"));
- Assert.assertEquals(treeCache.size(), 6);
+ assertEquals(paths, Sets.newHashSet("/foo", "/foo/a1", "/foo/a2", "/foo/a2/a2.1", "/foo/a3", "/foo/a3/a3.2"));
+ assertEquals(treeCache.size(), 6);
}
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheRandomTree.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheRandomTree.java
index e78bb9e..687f027 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheRandomTree.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCacheRandomTree.java
@@ -19,18 +19,20 @@
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import com.google.common.collect.Iterables;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.utils.ZKPaths;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
-import static org.testng.Assert.assertNotNull;
-
public class TestTreeCacheRandomTree extends BaseTestTreeCache
{
/**
@@ -119,7 +121,7 @@
{
// Delete myself from parent.
TestNode removed = last.children.remove(ZKPaths.getNodeFromPath(node.fullPath));
- Assert.assertSame(node, removed);
+ assertSame(node, removed);
// Delete from ZK
cl.delete().forPath(node.fullPath);
@@ -217,7 +219,7 @@
return;
}
- Assert.assertEquals(cacheChildren.keySet(), expectedNode.children.keySet(), path);
+ assertEquals(cacheChildren.keySet(), expectedNode.children.keySet(), path);
for ( Map.Entry<String, TestNode> entry : expectedNode.children.entrySet() )
{
@@ -236,6 +238,6 @@
{
String path = expectedNode.fullPath;
assertNotNull(actualChild, path);
- Assert.assertEquals(actualChild.getData(), expectedNode.data, path);
+ assertArrayEquals(actualChild.getData(), expectedNode.data, path);
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestWrappedNodeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestWrappedNodeCache.java
index 25716a7..26aa64e 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestWrappedNodeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestWrappedNodeCache.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.framework.recipes.cache;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.TestCleanState;
@@ -25,8 +30,9 @@
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
@@ -34,7 +40,7 @@
import static org.apache.curator.framework.recipes.cache.CuratorCacheListener.builder;
-@Test(groups = CuratorTestBase.zk36Group)
+@Tag(CuratorTestBase.zk36Group)
public class TestWrappedNodeCache extends CuratorTestBase
{
@Test
@@ -55,18 +61,18 @@
Supplier<Optional<ChildData>> rootData = getRootDataProc(cache, "/test/foo");
cache.start();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertTrue(rootData.get().isPresent());
- Assert.assertEquals(rootData.get().get().getData(), "one".getBytes());
+ assertTrue(rootData.get().isPresent());
+ assertArrayEquals(rootData.get().get().getData(), "one".getBytes());
client.delete().forPath("/test/foo");
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
client.create().forPath("/test/foo", "two".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertTrue(rootData.get().isPresent());
- Assert.assertEquals(rootData.get().get().getData(), "two".getBytes());
+ assertTrue(rootData.get().isPresent());
+ assertArrayEquals(rootData.get().get().getData(), "two".getBytes());
}
finally
{
@@ -103,18 +109,18 @@
Supplier<Optional<ChildData>> rootData = getRootDataProc(cache, "/test/node");
cache.start();
- Assert.assertTrue(timing.acquireSemaphore(latch));
+ assertTrue(timing.acquireSemaphore(latch));
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
- Assert.assertTrue(rootData.get().isPresent());
- Assert.assertEquals(rootData.get().get().getData(), "start".getBytes());
+ assertTrue(rootData.get().isPresent());
+ assertArrayEquals(rootData.get().get().getData(), "start".getBytes());
client.setData().forPath("/test/node", "new data".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(latch));
- Assert.assertTrue(rootData.get().isPresent());
- Assert.assertEquals(rootData.get().get().getData(), "new data".getBytes());
+ assertTrue(timing.acquireSemaphore(latch));
+ assertTrue(rootData.get().isPresent());
+ assertArrayEquals(rootData.get().get().getData(), "new data".getBytes());
}
finally
{
@@ -143,19 +149,19 @@
NodeCacheListener listener = semaphore::release;
cache.listenable().addListener(builder().forNodeCache(listener).build());
- Assert.assertNull(rootData.get().orElse(null));
+ assertNull(rootData.get().orElse(null));
client.create().forPath("/test/node", "a".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(rootData.get().orElse(null).getData(), "a".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertArrayEquals(rootData.get().orElse(null).getData(), "a".getBytes());
client.setData().forPath("/test/node", "b".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(rootData.get().orElse(null).getData(), "b".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertArrayEquals(rootData.get().orElse(null).getData(), "b".getBytes());
client.delete().forPath("/test/node");
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertNull(rootData.get().orElse(null));
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertNull(rootData.get().orElse(null));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderAcls.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderAcls.java
index 1589c7a..4d1172c 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderAcls.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderAcls.java
@@ -19,6 +19,8 @@
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -33,8 +35,9 @@
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
import org.apache.zookeeper.server.auth.DigestAuthenticationProvider;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.List;
@@ -45,7 +48,8 @@
{
private final Timing timing = new Timing();
- @Test(description = "Validation test for CURATOR-365")
+ @Test
+ @DisplayName("Validation test for CURATOR-365")
public void testAclErrorWithLeader() throws Exception
{
ACLProvider provider = new ACLProvider()
@@ -90,7 +94,7 @@
latch = new LeaderLatch(client, "/base");
latch.start();
- Assert.assertTrue(latch.await(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertTrue(latch.await(timing.forWaiting().seconds(), TimeUnit.SECONDS));
latch.close();
latch = null;
@@ -117,7 +121,7 @@
// but also making sure that the code goes through the backgroundCreateParentsThenNode() codepath
latch = new LeaderLatch(noAuthClient, "/base/second");
latch.start();
- Assert.assertTrue(timing.awaitLatch(noAuthLatch));
+ assertTrue(timing.awaitLatch(noAuthLatch));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java
index 1dca724..d64e7cf 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java
@@ -19,6 +19,12 @@
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
@@ -40,8 +46,9 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -61,7 +68,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestLeaderLatch extends BaseClassForTests
{
private static final String PATH_NAME = "/one/two/me";
@@ -133,7 +140,7 @@
holders.forEach(holder -> {
executorService.submit(() -> {
holder.latch.start();
- Assert.assertTrue(holder.latch.await(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(holder.latch.await(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
holder.isLockedLatch.countDown();
return null;
});
@@ -143,17 +150,17 @@
for ( int i = 0; i < 4; ++i ) // note: 4 is just a random number of loops to simulate disconnections
{
server.stop();
- Assert.assertTrue(timing.acquireSemaphore(lostSemaphore));
+ assertTrue(timing.acquireSemaphore(lostSemaphore));
server.restart();
timing.sleepABit();
}
for ( Holder holder : holders )
{
- Assert.assertTrue(holder.latch.await(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertEquals(timing.takeFromQueue(holder.stateChanges), ConnectionState.SUSPENDED);
- Assert.assertEquals(timing.takeFromQueue(holder.stateChanges), ConnectionState.LOST);
- Assert.assertEquals(timing.takeFromQueue(holder.stateChanges), ConnectionState.RECONNECTED);
+ assertTrue(holder.latch.await(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+ assertEquals(timing.takeFromQueue(holder.stateChanges), ConnectionState.SUSPENDED);
+ assertEquals(timing.takeFromQueue(holder.stateChanges), ConnectionState.LOST);
+ assertEquals(timing.takeFromQueue(holder.stateChanges), ConnectionState.RECONNECTED);
}
}
finally
@@ -187,7 +194,7 @@
try ( LeaderLatch latch2 = new LeaderLatch(client, latchPath, "2") )
{
latch1.start();
- Assert.assertTrue(latch1.await(timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(latch1.await(timing.milliseconds(), TimeUnit.MILLISECONDS));
latch2.start(); // will get a watcher on latch1's node
timing.sleepABit();
@@ -200,9 +207,9 @@
latch2.reset(); // force the internal "ourPath" to get reset
latch2.debugCheckLeaderShipLatch.countDown(); // allow checkLeadership() to continue
- Assert.assertTrue(latch2.await(timing.forSessionSleep().forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(latch2.await(timing.forSessionSleep().forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
timing.sleepABit();
- Assert.assertEquals(client.getChildren().forPath(latchPath).size(), 1);
+ assertEquals(client.getChildren().forPath(latchPath).size(), 1);
}
finally
{
@@ -258,25 +265,25 @@
};
latch.addListener(listener);
latch.start();
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
server.stop();
if ( isSessionIteration )
{
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED.name());
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED.name());
server.restart();
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED.name());
- Assert.assertNull(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED.name());
+ assertNull(states.poll(timing.milliseconds(), TimeUnit.MILLISECONDS));
}
else
{
String s = states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertTrue("false".equals(s) || ConnectionState.SUSPENDED.name().equals(s));
+ assertTrue("false".equals(s) || ConnectionState.SUSPENDED.name().equals(s));
s = states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertTrue("false".equals(s) || ConnectionState.SUSPENDED.name().equals(s));
+ assertTrue("false".equals(s) || ConnectionState.SUSPENDED.name().equals(s));
server.restart();
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED.name());
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED.name());
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
}
}
finally
@@ -329,14 +336,14 @@
};
latch.addListener(listener);
latch.start();
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
server.close();
List<String> next = Lists.newArrayList();
next.add(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
next.add(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertTrue(next.equals(Arrays.asList(ConnectionState.SUSPENDED.name(), "false")) || next.equals(Arrays.asList("false", ConnectionState.SUSPENDED.name())), next.toString());
- Assert.assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST.name());
+ assertTrue(next.equals(Arrays.asList(ConnectionState.SUSPENDED.name(), "false")) || next.equals(Arrays.asList("false", ConnectionState.SUSPENDED.name())), next.toString());
+ assertEquals(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST.name());
latch.close();
client.close();
@@ -356,14 +363,14 @@
latch = new LeaderLatch(client, "/test");
latch.addListener(listener);
latch.start();
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "true");
server.close();
- Assert.assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED.name());
+ assertEquals(states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED.name());
next = Lists.newArrayList();
next.add(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
next.add(states.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertTrue(next.equals(Arrays.asList(ConnectionState.LOST.name(), "false")) || next.equals(Arrays.asList("false", ConnectionState.LOST.name())), next.toString());
+ assertTrue(next.equals(Arrays.asList(ConnectionState.LOST.name(), "false")) || next.equals(Arrays.asList("false", ConnectionState.LOST.name())), next.toString());
}
finally
{
@@ -411,8 +418,8 @@
latch.close();
latch = null;
- Assert.assertTrue(timing.awaitLatch(cancelStartTaskLatch));
- Assert.assertFalse(resetCalled.get());
+ assertTrue(timing.awaitLatch(cancelStartTaskLatch));
+ assertFalse(resetCalled.get());
}
finally
{
@@ -442,7 +449,7 @@
timing.sleepABit();
- Assert.assertEquals(client.getChildren().forPath(PATH_NAME).size(), 1);
+ assertEquals(client.getChildren().forPath(PATH_NAME).size(), 1);
}
finally
{
@@ -474,7 +481,7 @@
timing.sleepABit();
- Assert.assertEquals(client.getChildren().forPath(PATH_NAME).size(), 0);
+ assertEquals(client.getChildren().forPath(PATH_NAME).size(), 0);
}
finally
@@ -519,14 +526,14 @@
waitForALeader(latches, timing);
server.stop();
- Assert.assertTrue(timing.awaitLatch(countDownLatch));
+ assertTrue(timing.awaitLatch(countDownLatch));
timing.forWaiting().sleepABit();
- Assert.assertEquals(getLeaders(latches).size(), 0);
+ assertEquals(getLeaders(latches).size(), 0);
server.restart();
- Assert.assertEquals(waitForALeader(latches, timing).size(), 1); // should reconnect
+ assertEquals(waitForALeader(latches, timing).size(), 1); // should reconnect
}
finally
{
@@ -565,7 +572,7 @@
//As the previous algorithm assumed that if the watched node is deleted gets the leadership
//we need to ensure that the PARTICIPANT_ID-1 is not getting (wrongly) elected as leader.
- Assert.assertTrue(!latches.get(PARTICIPANT_ID - 1).hasLeadership());
+ assertTrue(!latches.get(PARTICIPANT_ID - 1).hasLeadership());
}
finally
{
@@ -617,8 +624,8 @@
try
{
latch.start();
- Assert.assertTrue(latch.await(timing.forWaiting().seconds(), TimeUnit.SECONDS));
- Assert.assertTrue(thereIsALeader.compareAndSet(false, true));
+ assertTrue(latch.await(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertTrue(thereIsALeader.compareAndSet(false, true));
Thread.sleep((int)(10 * Math.random()));
thereIsALeader.set(false);
}
@@ -719,11 +726,11 @@
timesSquare.await();
- Assert.assertEquals(masterCounter.get(), PARTICIPANT_QTY * 2);
- Assert.assertEquals(notLeaderCounter.get(), PARTICIPANT_QTY);
+ assertEquals(masterCounter.get(), PARTICIPANT_QTY * 2);
+ assertEquals(notLeaderCounter.get(), PARTICIPANT_QTY);
for ( LeaderLatch latch : latches )
{
- Assert.assertEquals(latch.getState(), LeaderLatch.State.CLOSED);
+ assertEquals(latch.getState(), LeaderLatch.State.CLOSED);
}
}
finally
@@ -807,11 +814,11 @@
timesSquare.await();
- Assert.assertEquals(masterCounter.get(), PARTICIPANT_QTY * 2);
- Assert.assertEquals(notLeaderCounter.get(), PARTICIPANT_QTY * 2 - SILENT_QTY);
+ assertEquals(masterCounter.get(), PARTICIPANT_QTY * 2);
+ assertEquals(notLeaderCounter.get(), PARTICIPANT_QTY * 2 - SILENT_QTY);
for ( LeaderLatch latch : latches )
{
- Assert.assertEquals(latch.getState(), LeaderLatch.State.CLOSED);
+ assertEquals(latch.getState(), LeaderLatch.State.CLOSED);
}
}
finally
@@ -886,11 +893,11 @@
// Test the close override
leader.close(LeaderLatch.CloseMode.NOTIFY_LEADER);
- Assert.assertEquals(leader.getState(), LeaderLatch.State.CLOSED);
- Assert.assertEquals(notifiedLeader.getState(), LeaderLatch.State.CLOSED);
+ assertEquals(leader.getState(), LeaderLatch.State.CLOSED);
+ assertEquals(notifiedLeader.getState(), LeaderLatch.State.CLOSED);
- Assert.assertEquals(masterCounter.get(), 1);
- Assert.assertEquals(notLeaderCounter.get(), 0);
+ assertEquals(masterCounter.get(), 1);
+ assertEquals(notLeaderCounter.get(), 0);
}
finally
{
@@ -946,14 +953,14 @@
// Start the new server
server = new TestingServer(server.getPort(), server.getTempDirectory());
- Assert.assertTrue(timing.awaitLatch(leaderCounter), "Not elected leader");
+ assertTrue(timing.awaitLatch(leaderCounter), "Not elected leader");
- Assert.assertEquals(leaderCount.get(), 1, "Elected too many times");
- Assert.assertEquals(notLeaderCount.get(), 0, "Unelected too many times");
+ assertEquals(leaderCount.get(), 1, "Elected too many times");
+ assertEquals(notLeaderCount.get(), 0, "Unelected too many times");
}
catch ( Exception e )
{
- Assert.fail("Unexpected exception", e);
+ fail("Unexpected exception", e);
}
finally
{
@@ -1012,11 +1019,11 @@
while ( latches.size() > 0 )
{
List<LeaderLatch> leaders = waitForALeader(latches, timing);
- Assert.assertEquals(leaders.size(), 1); // there can only be one leader
+ assertEquals(leaders.size(), 1); // there can only be one leader
LeaderLatch theLeader = leaders.get(0);
if ( mode == Mode.START_IMMEDIATELY )
{
- Assert.assertEquals(latches.indexOf(theLeader), 0); // assert ordering - leadership should advance in start order
+ assertEquals(latches.indexOf(theLeader), 0); // assert ordering - leadership should advance in start order
}
theLeader.close();
latches.remove(theLeader);
@@ -1059,11 +1066,13 @@
return leaders;
}
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testRelativePath() throws Exception
+ @Test
+ public void testRelativePath()
{
- Timing timing = new Timing();
- CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
- new LeaderLatch(client, "parent");
+ assertThrows(IllegalArgumentException.class, ()->{
+ Timing timing = new Timing();
+ CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
+ new LeaderLatch(client, "parent");
+ });
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java
index 752ed4f..5fba3b1 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatchCluster.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -27,8 +29,8 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
import java.util.List;
@@ -72,16 +74,16 @@
}
ClientAndLatch leader = waitForALeader(clients, timing);
- Assert.assertNotNull(leader);
+ assertNotNull(leader);
cluster.killServer(instances.get(leader.index));
Thread.sleep(sessionLength * 2);
leader = waitForALeader(clients, timing);
- Assert.assertNotNull(leader);
+ assertNotNull(leader);
- Assert.assertEquals(getLeaders(clients).size(), 1);
+ assertEquals(getLeaders(clients).size(), 1);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
index 3b054a2..44e0269 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
@@ -19,6 +19,12 @@
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
@@ -34,8 +40,8 @@
import org.apache.curator.test.Timing;
import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Arrays;
import java.util.List;
import java.util.Set;
@@ -47,8 +53,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.testng.Assert.fail;
-
public class TestLeaderSelector extends BaseClassForTests
{
private static final String PATH_NAME = "/one/two/me";
@@ -86,9 +90,9 @@
selector.start();
Thread leaderThread = timing.takeFromQueue(threadExchange);
leaderThread.interrupt();
- Assert.assertTrue(timing.awaitLatch(exitLatch));
+ assertTrue(timing.awaitLatch(exitLatch));
timing.sleepABit(); // wait for leader selector to clear nodes
- Assert.assertEquals(0, selector.failedMutexReleaseCount.get());
+ assertEquals(0, selector.failedMutexReleaseCount.get());
}
finally
{
@@ -144,14 +148,14 @@
selector = new LeaderSelector(client, "/test", listener);
selector.start();
- Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
- Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "leader");
+ assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
+ assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "leader");
server.close();
List<String> next = Lists.newArrayList();
next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertTrue(next.equals(Arrays.asList(ConnectionState.SUSPENDED.name(), "release")) || next.equals(Arrays.asList("release", ConnectionState.SUSPENDED.name())), next.toString());
- Assert.assertEquals(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST.name());
+ assertTrue(next.equals(Arrays.asList(ConnectionState.SUSPENDED.name(), "release")) || next.equals(Arrays.asList("release", ConnectionState.SUSPENDED.name())), next.toString());
+ assertEquals(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST.name());
selector.close();
client.close();
@@ -172,14 +176,14 @@
selector = new LeaderSelector(client, "/test", listener);
selector.start();
- Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
- Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "leader");
+ assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED.name());
+ assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), "leader");
server.stop();
- Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED.name());
+ assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED.name());
next = Lists.newArrayList();
next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertTrue(next.equals(Arrays.asList(ConnectionState.LOST.name(), "release")) || next.equals(Arrays.asList("release", ConnectionState.LOST.name())), next.toString());
+ assertTrue(next.equals(Arrays.asList(ConnectionState.LOST.name(), "release")) || next.equals(Arrays.asList("release", ConnectionState.LOST.name())), next.toString());
}
finally
{
@@ -241,10 +245,10 @@
server.stop();
leaderThread.interrupt();
server.restart();
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
timing.sleepABit();
- Assert.assertEquals(client.getChildren().forPath("/leader").size(), 0);
+ assertEquals(client.getChildren().forPath("/leader").size(), 0);
}
finally
{
@@ -278,10 +282,10 @@
selector.autoRequeue();
selector.start();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
selector.interruptLeadership();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
}
finally
{
@@ -327,9 +331,9 @@
selector = new LeaderSelector(client, "/leader", listener);
selector.start();
- Assert.assertTrue(timing.awaitLatch(isLeaderLatch));
+ assertTrue(timing.awaitLatch(isLeaderLatch));
selector.interruptLeadership();
- Assert.assertTrue(timing.awaitLatch(losingLeaderLatch));
+ assertTrue(timing.awaitLatch(losingLeaderLatch));
}
finally
{
@@ -382,16 +386,16 @@
selector.start();
- Assert.assertTrue(timing.awaitLatch(debugLeadershipLatch));
+ assertTrue(timing.awaitLatch(debugLeadershipLatch));
server.stop();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
timing.sleepABit();
debugLeadershipWaitLatch.countDown();
server.restart();
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
- Assert.assertFalse(takeLeadershipLatch.await(3, TimeUnit.SECONDS));
+ assertFalse(takeLeadershipLatch.await(3, TimeUnit.SECONDS));
}
finally
{
@@ -429,7 +433,7 @@
selector.autoRequeue();
selector.start();
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 2));
+ assertTrue(timing.acquireSemaphore(semaphore, 2));
}
finally
{
@@ -528,20 +532,20 @@
leaderSelector1.start();
leaderSelector2.start();
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(timing.awaitLatch(interruptedLatch));
+ assertTrue(timing.awaitLatch(interruptedLatch));
timing.sleepABit();
boolean requeued1 = leaderSelector1.requeue();
boolean requeued2 = leaderSelector2.requeue();
- Assert.assertTrue(requeued1);
- Assert.assertTrue(requeued2);
+ assertTrue(requeued1);
+ assertTrue(requeued2);
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
- Assert.assertEquals(leaderCount.get(), 1);
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertEquals(leaderCount.get(), 1);
if ( leaderSelector1.hasLeadership() )
{
@@ -559,8 +563,8 @@
}
// Verify that the other leader took over leadership.
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
- Assert.assertEquals(leaderCount.get(), 1);
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertEquals(leaderCount.get(), 1);
if ( !leaderSelector1Closed )
{
@@ -632,17 +636,17 @@
leaderSelector1.start();
leaderSelector2.start();
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
int port = server.getPort();
server.stop();
timing.sleepABit();
server = new TestingServer(port);
- Assert.assertTrue(timing.awaitLatch(interruptedLatch));
+ assertTrue(timing.awaitLatch(interruptedLatch));
timing.sleepABit();
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
- Assert.assertEquals(leaderCount.get(), 1);
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertEquals(leaderCount.get(), 1);
if ( leaderSelector1.hasLeadership() )
{
@@ -660,8 +664,8 @@
}
// Verify that the other leader took over leadership.
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
- Assert.assertEquals(leaderCount.get(), 1);
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertEquals(leaderCount.get(), 1);
if ( !leaderSelector1Closed )
{
@@ -722,7 +726,7 @@
Thread.sleep(1000);
}
- Assert.assertNotSame(leaderSelector1.hasLeadership(), leaderSelector2.hasLeadership());
+ assertNotSame(leaderSelector1.hasLeadership(), leaderSelector2.hasLeadership());
LeaderSelector positiveLeader;
LeaderSelector negativeLeader;
@@ -739,12 +743,12 @@
negativeLeader.close();
Thread.sleep(1000);
- Assert.assertNotSame(positiveLeader.hasLeadership(), negativeLeader.hasLeadership());
- Assert.assertTrue(positiveLeader.hasLeadership());
+ assertNotSame(positiveLeader.hasLeadership(), negativeLeader.hasLeadership());
+ assertTrue(positiveLeader.hasLeadership());
positiveLeader.close();
Thread.sleep(1000);
- Assert.assertFalse(positiveLeader.hasLeadership());
+ assertFalse(positiveLeader.hasLeadership());
}
finally
{
@@ -804,7 +808,7 @@
while ( localLeaderList.size() != (i * selectors.size()) )
{
Integer polledIndex = leaderList.poll(10, TimeUnit.SECONDS);
- Assert.assertNotNull(polledIndex);
+ assertNotNull(polledIndex);
localLeaderList.add(polledIndex);
}
timing.sleepABit();
@@ -821,10 +825,10 @@
Set<Integer> uniques = Sets.newHashSet();
for ( int j = 0; j < selectors.size(); ++j )
{
- Assert.assertTrue(localLeaderList.size() > 0);
+ assertTrue(localLeaderList.size() > 0);
int thisIndex = localLeaderList.remove(0);
- Assert.assertFalse(uniques.contains(thisIndex));
+ assertFalse(uniques.contains(thisIndex));
uniques.add(thisIndex);
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java
index 6849816..10903ed 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -28,8 +32,8 @@
import org.apache.curator.test.TestingCluster;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.ZKPaths;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -58,7 +62,7 @@
public void takeLeadership(CuratorFramework client) throws Exception
{
List<String> names = client.getChildren().forPath("/leader");
- Assert.assertTrue(names.size() > 0);
+ assertTrue(names.size() > 0);
semaphore.release();
}
@@ -70,12 +74,12 @@
LeaderSelector selector = new LeaderSelector(client, "/leader", listener);
selector.autoRequeue();
selector.start();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
InstanceSpec connectionInstance = cluster.findConnectionInstance(client.getZookeeperClient().getZooKeeper());
cluster.killServer(connectionInstance);
- Assert.assertTrue(timing.multiple(4).acquireSemaphore(semaphore));
+ assertTrue(timing.multiple(4).acquireSemaphore(semaphore));
}
finally
{
@@ -142,7 +146,7 @@
};
LeaderSelector selector = new LeaderSelector(client, "/leader", listener);
selector.start();
- Assert.assertTrue(timing.multiple(4).acquireSemaphore(semaphore));
+ assertTrue(timing.multiple(4).acquireSemaphore(semaphore));
if ( error.get() != null )
{
throw new AssertionError(error.get());
@@ -151,11 +155,11 @@
Collection<InstanceSpec> instances = cluster.getInstances();
cluster.stop();
- Assert.assertTrue(timing.multiple(4).awaitLatch(lostLatch));
+ assertTrue(timing.multiple(4).awaitLatch(lostLatch));
timing.sleepABit();
- Assert.assertFalse(selector.hasLeadership());
+ assertFalse(selector.hasLeadership());
- Assert.assertNotNull(lockNode.get());
+ assertNotNull(lockNode.get());
cluster = new TestingCluster(instances.toArray(new InstanceSpec[instances.size()]));
cluster.start();
@@ -169,11 +173,11 @@
// ignore
}
- Assert.assertTrue(semaphore.availablePermits() == 0);
- Assert.assertFalse(selector.hasLeadership());
+ assertTrue(semaphore.availablePermits() == 0);
+ assertFalse(selector.hasLeadership());
selector.requeue();
- Assert.assertTrue(timing.multiple(4).acquireSemaphore(semaphore));
+ assertTrue(timing.multiple(4).acquireSemaphore(semaphore));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorEdges.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorEdges.java
index 9841677..003f383 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorEdges.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorEdges.java
@@ -19,6 +19,10 @@
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.BackgroundCallback;
@@ -26,16 +30,14 @@
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.test.BaseClassForTests;
-import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.server.ServerCnxnFactory;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -46,13 +48,13 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- @BeforeClass
+ @BeforeAll
public static void setCNXFactory()
{
System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, ChaosMonkeyCnxnFactory.class.getName());
}
- @AfterClass
+ @AfterAll
public static void resetCNXFactory()
{
System.clearProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY);
@@ -86,20 +88,20 @@
leaderSelector1.start();
// At this point the ChaosMonkeyZookeeperServer must close the connection
// right after the lock znode is created.
- Assert.assertTrue(listener.reconnected.await(10, TimeUnit.SECONDS), "Connection has not been lost");
+ assertTrue(listener.reconnected.await(10, TimeUnit.SECONDS), "Connection has not been lost");
// Check that leader ship has failed
- Assert.assertEquals(listener.takeLeadership.getCount(), 1);
+ assertEquals(listener.takeLeadership.getCount(), 1);
// Wait FailedDelete
Thread.sleep(ChaosMonkeyCnxnFactory.LOCKOUT_DURATION_MS * 2);
// Check that there is no znode
final int children = client.getChildren().forPath(ChaosMonkeyCnxnFactory.CHAOS_ZNODE).size();
- Assert.assertEquals(children, 0,
+ assertEquals(children, 0,
"Still " + children + " znodes under " + ChaosMonkeyCnxnFactory.CHAOS_ZNODE + " lock");
// Check that a new LeaderSelector can be started
leaderSelector2 = new LeaderSelector(client, ChaosMonkeyCnxnFactory.CHAOS_ZNODE,
listener);
leaderSelector2.start();
- Assert.assertTrue(listener.takeLeadership.await(1, TimeUnit.SECONDS));
+ assertTrue(listener.takeLeadership.await(1, TimeUnit.SECONDS));
}
finally
{
@@ -109,7 +111,7 @@
}
catch ( IllegalStateException e )
{
- Assert.fail(e.getMessage());
+ fail(e.getMessage());
}
try
{
@@ -120,7 +122,7 @@
}
catch ( IllegalStateException e )
{
- Assert.fail(e.getMessage());
+ fail(e.getMessage());
}
client.close();
}
@@ -187,12 +189,12 @@
)
.forPath(ChaosMonkeyCnxnFactory.CHAOS_ZNODE_PREFIX + "foo-");
- Assert.assertTrue(latch.await(30, TimeUnit.SECONDS), "Callback has not been called");
+ assertTrue(latch.await(30, TimeUnit.SECONDS), "Callback has not been called");
// Wait for the znode to be deleted
Thread.sleep(ChaosMonkeyCnxnFactory.LOCKOUT_DURATION_MS * 2);
// Check that there is no znode
final int children = client.getChildren().forPath(ChaosMonkeyCnxnFactory.CHAOS_ZNODE).size();
- Assert.assertEquals(children, 0,
+ assertEquals(children, 0,
"Still " + children + " znodes under " + ChaosMonkeyCnxnFactory.CHAOS_ZNODE + " lock");
}
finally
@@ -239,12 +241,12 @@
)
.forPath(ChaosMonkeyCnxnFactory.CHAOS_ZNODE_PREFIX + "foo-");
- Assert.assertTrue(latch.await(30, TimeUnit.SECONDS), "Callback has not been called");
+ assertTrue(latch.await(30, TimeUnit.SECONDS), "Callback has not been called");
// Wait for the znode to be deleted
Thread.sleep(ChaosMonkeyCnxnFactory.LOCKOUT_DURATION_MS * 2);
// Check that there is no znode
final int children = client.getChildren().forPath(ChaosMonkeyCnxnFactory.CHAOS_ZNODE).size();
- Assert.assertEquals(children, 0,
+ assertEquals(children, 0,
"Still " + children + " znodes under " + ChaosMonkeyCnxnFactory.CHAOS_ZNODE + " lock");
}
finally
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorParticipants.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorParticipants.java
index e026f87..d80b93f 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorParticipants.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorParticipants.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.curator.test.BaseClassForTests;
@@ -26,8 +29,8 @@
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.retry.RetryOneTime;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -64,16 +67,16 @@
selector.setId("A is A");
selector.start();
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
Participant leader = selector.getLeader();
- Assert.assertTrue(leader.isLeader());
- Assert.assertEquals(leader.getId(), "A is A");
+ assertTrue(leader.isLeader());
+ assertEquals(leader.getId(), "A is A");
Collection<Participant> participants = selector.getParticipants();
- Assert.assertEquals(participants.size(), 1);
- Assert.assertEquals(participants.iterator().next().getId(), "A is A");
- Assert.assertEquals(participants.iterator().next().getId(), selector.getId());
+ assertEquals(participants.size(), 1);
+ assertEquals(participants.iterator().next().getId(), "A is A");
+ assertEquals(participants.iterator().next().getId(), selector.getId());
}
finally
{
@@ -130,15 +133,15 @@
selector.start();
}
- Assert.assertTrue(leaderLatch.await(10, TimeUnit.SECONDS));
- Assert.assertTrue(workingLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(leaderLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(workingLatch.await(10, TimeUnit.SECONDS));
Thread.sleep(1000); // some time for locks to acquire
Collection<Participant> participants = selectors.get(0).getParticipants();
for ( int i = 1; i < selectors.size(); ++i )
{
- Assert.assertEquals(participants, selectors.get(i).getParticipants());
+ assertEquals(participants, selectors.get(i).getParticipants());
}
Set<String> ids = Sets.newHashSet();
@@ -149,17 +152,17 @@
{
++leaderCount;
}
- Assert.assertFalse(ids.contains(participant.getId()));
+ assertFalse(ids.contains(participant.getId()));
ids.add(participant.getId());
}
- Assert.assertEquals(leaderCount, 1);
+ assertEquals(leaderCount, 1);
Set<String> expectedIds = Sets.newHashSet();
for ( int i = 0; i < SELECTOR_QTY; ++i )
{
expectedIds.add(Integer.toString(i));
}
- Assert.assertEquals(expectedIds, ids);
+ assertEquals(expectedIds, ids);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorWithExecutor.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorWithExecutor.java
index 214931b..cd77f18 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorWithExecutor.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorWithExecutor.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.recipes.leader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -26,8 +28,8 @@
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.ThreadUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
@@ -61,7 +63,7 @@
timing.sleepABit();
- Assert.assertEquals(listener.getLeaderCount(), 1);
+ assertEquals(listener.getLeaderCount(), 1);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMultiMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMultiMutex.java
index dceff88..faf0f7f 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMultiMutex.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMultiMutex.java
@@ -18,12 +18,16 @@
*/
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.retry.RetryOneTime;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
@@ -81,14 +85,14 @@
{
lock.acquire();
lock.release();
- Assert.fail();
+ fail();
}
catch ( Exception e )
{
// ignore
}
- Assert.assertFalse(goodLock.isAcquiredInThisProcess());
- Assert.assertTrue(otherGoodLock.isAcquiredInThisProcess());
+ assertFalse(goodLock.isAcquiredInThisProcess());
+ assertTrue(otherGoodLock.isAcquiredInThisProcess());
}
finally
{
@@ -140,14 +144,14 @@
try
{
lock.acquire();
- Assert.fail();
+ fail();
}
catch ( Exception e )
{
// ignore
}
- Assert.assertFalse(goodLock.isAcquiredInThisProcess());
- Assert.assertTrue(goodLockWasLocked.get());
+ assertFalse(goodLock.isAcquiredInThisProcess());
+ assertTrue(goodLockWasLocked.get());
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
index 12434ef..b5c30ae 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
@@ -19,6 +19,10 @@
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -28,8 +32,8 @@
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.CreateMode;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -118,13 +122,13 @@
@Override
public Void call() throws Exception
{
- Assert.assertTrue(lockLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(lockLatch.await(10, TimeUnit.SECONDS));
Collection<String> nodes = lock.getParticipantNodes();
- Assert.assertEquals(nodes.size(), 1);
+ assertEquals(nodes.size(), 1);
Revoker.attemptRevoke(client, nodes.iterator().next());
InterProcessMutex l2 = new InterProcessMutex(client, LOCK_PATH);
- Assert.assertTrue(l2.acquire(5, TimeUnit.SECONDS));
+ assertTrue(l2.acquire(5, TimeUnit.SECONDS));
l2.release();
return null;
}
@@ -168,16 +172,16 @@
// Get a persistent lock
lock.acquire(10, TimeUnit.SECONDS);
- Assert.assertTrue(lock.isAcquiredInThisProcess());
+ assertTrue(lock.isAcquiredInThisProcess());
// Kill the session, check that lock node still exists
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertNotNull(client.checkExists().forPath(LOCK_PATH));
+ assertNotNull(client.checkExists().forPath(LOCK_PATH));
// Release the lock and verify that the actual lock node created no longer exists
String actualLockPath = lock.getLockPath();
lock.release();
- Assert.assertNull(client.checkExists().forPath(actualLockPath));
+ assertNull(client.checkExists().forPath(actualLockPath));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java
index 6e3b6ed..3a25e28 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java
@@ -19,6 +19,11 @@
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -32,8 +37,8 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.KeeperException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -67,9 +72,9 @@
InterProcessLock lock = makeLock(client);
try ( Locker locker = new Locker(lock, timing.milliseconds(), TimeUnit.MILLISECONDS) )
{
- Assert.assertTrue(lock.isAcquiredInThisProcess());
+ assertTrue(lock.isAcquiredInThisProcess());
}
- Assert.assertFalse(lock.isAcquiredInThisProcess());
+ assertFalse(lock.isAcquiredInThisProcess());
}
finally
{
@@ -121,7 +126,7 @@
timing.sleepABit();
server.stop();
- Assert.assertTrue(timing.forWaiting().awaitLatch(latch));
+ assertTrue(timing.forWaiting().awaitLatch(latch));
server.restart();
}
}
@@ -144,7 +149,7 @@
for ( int i = 0; i < 2; ++i )
{
- Assert.assertEquals(service.take().get(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), result);
+ assertEquals(service.take().get(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS), result);
}
}
finally
@@ -197,9 +202,9 @@
}
);
- Assert.assertTrue(timing.acquireSemaphore(semaphore, 1));
+ assertTrue(timing.acquireSemaphore(semaphore, 1));
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
- Assert.assertTrue(timing.forSessionSleep().acquireSemaphore(semaphore, 1));
+ assertTrue(timing.forSessionSleep().acquireSemaphore(semaphore, 1));
}
finally
{
@@ -266,7 +271,7 @@
new Timing().sleepABit();
- Assert.assertNull(client.checkExists().forPath(LOCK_BASE_PATH));
+ assertNull(client.checkExists().forPath(LOCK_BASE_PATH));
}
finally
{
@@ -334,7 +339,7 @@
mutex.acquire();
try
{
- Assert.assertTrue(hasLock.compareAndSet(false, true));
+ assertTrue(hasLock.compareAndSet(false, true));
if ( isFirst.compareAndSet(true, false) )
{
semaphore.release(THREAD_QTY - 1);
@@ -389,11 +394,11 @@
@Override
public Object call() throws Exception
{
- Assert.assertTrue(countLatchForBar.await(10, TimeUnit.SECONDS));
+ assertTrue(countLatchForBar.await(10, TimeUnit.SECONDS));
try
{
mutex.acquire(10, TimeUnit.SECONDS);
- Assert.fail();
+ fail();
}
catch ( Exception e )
{
@@ -409,7 +414,7 @@
);
foo(mutex);
- Assert.assertFalse(mutex.isAcquiredInThisProcess());
+ assertFalse(mutex.isAcquiredInThisProcess());
}
finally
{
@@ -426,7 +431,7 @@
{
InterProcessLock mutex = makeLock(client);
foo(mutex);
- Assert.assertFalse(mutex.isAcquiredInThisProcess());
+ assertFalse(mutex.isAcquiredInThisProcess());
}
finally
{
@@ -437,32 +442,32 @@
private void foo(InterProcessLock mutex) throws Exception
{
mutex.acquire(10, TimeUnit.SECONDS);
- Assert.assertTrue(mutex.isAcquiredInThisProcess());
+ assertTrue(mutex.isAcquiredInThisProcess());
bar(mutex);
- Assert.assertTrue(mutex.isAcquiredInThisProcess());
+ assertTrue(mutex.isAcquiredInThisProcess());
mutex.release();
}
private void bar(InterProcessLock mutex) throws Exception
{
mutex.acquire(10, TimeUnit.SECONDS);
- Assert.assertTrue(mutex.isAcquiredInThisProcess());
+ assertTrue(mutex.isAcquiredInThisProcess());
if ( countLatchForBar != null )
{
countLatchForBar.countDown();
waitLatchForBar.await(10, TimeUnit.SECONDS);
}
snafu(mutex);
- Assert.assertTrue(mutex.isAcquiredInThisProcess());
+ assertTrue(mutex.isAcquiredInThisProcess());
mutex.release();
}
private void snafu(InterProcessLock mutex) throws Exception
{
mutex.acquire(10, TimeUnit.SECONDS);
- Assert.assertTrue(mutex.isAcquiredInThisProcess());
+ assertTrue(mutex.isAcquiredInThisProcess());
mutex.release();
- Assert.assertTrue(mutex.isAcquiredInThisProcess());
+ assertTrue(mutex.isAcquiredInThisProcess());
}
@Test
@@ -536,13 +541,13 @@
while ( !mutexForClient1.isAcquiredInThisProcess() && !mutexForClient2.isAcquiredInThisProcess() )
{
Thread.sleep(1000);
- Assert.assertFalse(future1.isDone() && future2.isDone());
+ assertFalse(future1.isDone() && future2.isDone());
}
- Assert.assertTrue(mutexForClient1.isAcquiredInThisProcess() != mutexForClient2.isAcquiredInThisProcess());
+ assertTrue(mutexForClient1.isAcquiredInThisProcess() != mutexForClient2.isAcquiredInThisProcess());
Thread.sleep(1000);
- Assert.assertTrue(mutexForClient1.isAcquiredInThisProcess() || mutexForClient2.isAcquiredInThisProcess());
- Assert.assertTrue(mutexForClient1.isAcquiredInThisProcess() != mutexForClient2.isAcquiredInThisProcess());
+ assertTrue(mutexForClient1.isAcquiredInThisProcess() || mutexForClient2.isAcquiredInThisProcess());
+ assertTrue(mutexForClient1.isAcquiredInThisProcess() != mutexForClient2.isAcquiredInThisProcess());
Exception exception = exceptionRef.get();
if ( exception != null )
@@ -553,14 +558,14 @@
if ( mutexForClient1.isAcquiredInThisProcess() )
{
latchForClient1.countDown();
- Assert.assertTrue(acquiredLatchForClient2.await(10, TimeUnit.SECONDS));
- Assert.assertTrue(mutexForClient2.isAcquiredInThisProcess());
+ assertTrue(acquiredLatchForClient2.await(10, TimeUnit.SECONDS));
+ assertTrue(mutexForClient2.isAcquiredInThisProcess());
}
else
{
latchForClient2.countDown();
- Assert.assertTrue(acquiredLatchForClient1.await(10, TimeUnit.SECONDS));
- Assert.assertTrue(mutexForClient1.isAcquiredInThisProcess());
+ assertTrue(acquiredLatchForClient1.await(10, TimeUnit.SECONDS));
+ assertTrue(mutexForClient1.isAcquiredInThisProcess());
}
future1.get();
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
index 48e4805..a601241 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
@@ -19,14 +19,19 @@
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
import java.util.List;
import java.util.Random;
@@ -92,7 +97,7 @@
@Override
public Void call() throws Exception
{
- Assert.assertTrue(readLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(readLatch.await(10, TimeUnit.SECONDS));
latch.countDown(); // must be before as there can only be one writer
lock.writeLock().acquire();
try
@@ -109,13 +114,13 @@
);
}
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
Collection<String> readers = lock.readLock().getParticipantNodes();
Collection<String> writers = lock.writeLock().getParticipantNodes();
- Assert.assertEquals(readers.size(), READERS);
- Assert.assertEquals(writers.size(), WRITERS);
+ assertEquals(readers.size(), READERS);
+ assertEquals(writers.size(), WRITERS);
exitLatch.countDown();
for ( int i = 0; i < (READERS + WRITERS); ++i )
@@ -139,7 +144,7 @@
InterProcessReadWriteLock lock = new InterProcessReadWriteLock(client, "/lock");
lock.readLock().acquire();
- Assert.assertFalse(lock.writeLock().acquire(5, TimeUnit.SECONDS));
+ assertFalse(lock.writeLock().acquire(5, TimeUnit.SECONDS));
lock.readLock().release();
}
@@ -193,8 +198,8 @@
@Override
public Object call() throws Exception
{
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
- Assert.assertFalse(lock.readLock().acquire(5, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertFalse(lock.readLock().acquire(5, TimeUnit.SECONDS));
return null;
}
}
@@ -220,7 +225,7 @@
InterProcessReadWriteLock lock = new InterProcessReadWriteLock(client, "/lock");
lock.writeLock().acquire();
- Assert.assertTrue(lock.readLock().acquire(5, TimeUnit.SECONDS));
+ assertTrue(lock.readLock().acquire(5, TimeUnit.SECONDS));
lock.writeLock().release();
lock.readLock().release();
@@ -291,9 +296,9 @@
System.out.println("Writes: " + writeCount.get() + " - Reads: " + readCount.get() + " - Max Reads: " + maxConcurrentCount.get());
- Assert.assertTrue(writeCount.get() > 0);
- Assert.assertTrue(readCount.get() > 0);
- Assert.assertTrue(maxConcurrentCount.get() > 1);
+ assertTrue(writeCount.get() > 0);
+ assertTrue(readCount.get() > 0);
+ assertTrue(maxConcurrentCount.get() > 1);
}
@Test
@@ -315,11 +320,11 @@
lock.writeLock().acquire();
List<String> children = client.getChildren().forPath("/lock");
- Assert.assertEquals(1, children.size());
+ assertEquals(1, children.size());
byte dataInZk[] = client.getData().forPath("/lock/" + children.get(0));
- Assert.assertNotNull(dataInZk);
- Assert.assertEquals(new byte[]{1, 2, 3, 4}, dataInZk);
+ assertNotNull(dataInZk);
+ assertArrayEquals(new byte[]{1, 2, 3, 4}, dataInZk);
lock.writeLock().release();
}
@@ -333,7 +338,7 @@
{
try
{
- Assert.assertTrue(lock.acquire(10, TimeUnit.SECONDS));
+ assertTrue(lock.acquire(10, TimeUnit.SECONDS));
int localConcurrentCount;
synchronized(this)
{
@@ -344,7 +349,7 @@
}
}
- Assert.assertTrue(localConcurrentCount <= maxAllowed, "" + localConcurrentCount);
+ assertTrue(localConcurrentCount <= maxAllowed, "" + localConcurrentCount);
Thread.sleep(random.nextInt(9) + 1);
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
index ce9f8fa..edd649b 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
@@ -19,6 +19,11 @@
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import org.apache.curator.framework.CuratorFramework;
@@ -28,7 +33,6 @@
import org.apache.curator.framework.recipes.shared.SharedCount;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
-import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.Timing;
@@ -36,8 +40,8 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collection;
import java.util.List;
import java.util.Random;
@@ -128,7 +132,7 @@
{
executor.execute(runner);
}
- Assert.assertTrue(timing.awaitLatch(isReadyLatch));
+ assertTrue(timing.awaitLatch(isReadyLatch));
timing.sleepABit();
final CountDownLatch lostLatch = new CountDownLatch(1);
@@ -150,20 +154,20 @@
});
server.stop();
- Assert.assertTrue(timing.multiple(1.25).awaitLatch(lostLatch));
+ assertTrue(timing.multiple(1.25).awaitLatch(lostLatch));
InterProcessSemaphoreV2.debugAcquireLatch.countDown(); // the waiting semaphore proceeds to getChildren - which should fail
- Assert.assertTrue(timing.awaitLatch(InterProcessSemaphoreV2.debugFailedGetChildrenLatch)); // wait until getChildren fails
+ assertTrue(timing.awaitLatch(InterProcessSemaphoreV2.debugFailedGetChildrenLatch)); // wait until getChildren fails
server.restart();
- Assert.assertTrue(timing.awaitLatch(restartedLatch));
+ assertTrue(timing.awaitLatch(restartedLatch));
for ( int i = 0; i < NUM_CLIENTS; ++i )
{
// acquires should continue as normal after server restart
Boolean polled = acquiredQueue.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
if ( (polled == null) || !polled )
{
- Assert.fail("Semaphores not reacquired after restart");
+ fail("Semaphores not reacquired after restart");
}
}
}
@@ -200,10 +204,10 @@
public Object call() throws Exception
{
Lease lease = semaphore.acquire(timing.seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
latch1.countDown();
lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
latch2.countDown();
return null;
}
@@ -216,12 +220,12 @@
@Override
public Object call() throws Exception
{
- Assert.assertTrue(latch1.await(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertTrue(latch1.await(timing.forWaiting().seconds(), TimeUnit.SECONDS));
timing.sleepABit(); // make sure second acquire is waiting
- Assert.assertTrue(count.trySetCount(2));
+ assertTrue(count.trySetCount(2));
//Make sure second acquire takes less than full waiting time:
timing.sleepABit();
- Assert.assertTrue(latch2.await(0, TimeUnit.SECONDS));
+ assertTrue(latch2.await(0, TimeUnit.SECONDS));
return null;
}
}
@@ -258,16 +262,16 @@
semaphore2 = new InterProcessSemaphoreV2(client2, "/test", 1);
Lease lease = semaphore2.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
lease.close();
lease = semaphore1.acquire(10, TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
client1.close(); // should release any held leases
client1 = null;
- Assert.assertNotNull(semaphore2.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertNotNull(semaphore2.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
}
finally
{
@@ -324,10 +328,10 @@
thisQty = (available.get() > 1) ? (random.nextInt(available.get()) + 1) : 1;
available.addAndGet(-1 * thisQty);
- Assert.assertTrue(available.get() >= 0);
+ assertTrue(available.get() >= 0);
}
Collection<Lease> leases = semaphore.acquire(thisQty, timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(leases);
+ assertNotNull(leases);
try
{
synchronized(counter)
@@ -373,9 +377,9 @@
synchronized(counter)
{
- Assert.assertTrue(counter.currentCount == 0);
- Assert.assertTrue(counter.maxCount > 0);
- Assert.assertTrue(counter.maxCount <= SESSION_MAX);
+ assertTrue(counter.currentCount == 0);
+ assertTrue(counter.maxCount > 0);
+ assertTrue(counter.maxCount <= SESSION_MAX);
System.out.println(counter.maxCount);
}
}
@@ -407,7 +411,7 @@
{
InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", MAX);
Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
uses.incrementAndGet();
try
{
@@ -444,8 +448,8 @@
f.get();
}
- Assert.assertEquals(uses.get(), CLIENT_QTY);
- Assert.assertEquals(maxLeases.get(), MAX);
+ assertEquals(uses.get(), CLIENT_QTY);
+ assertEquals(maxLeases.get(), MAX);
}
@Test
@@ -524,9 +528,9 @@
timing.sleepABit();
synchronized(counter)
{
- Assert.assertTrue(counter.currentCount == 0);
- Assert.assertTrue(counter.maxCount > 0);
- Assert.assertTrue(counter.maxCount <= MAX_LEASES);
+ assertTrue(counter.currentCount == 0);
+ assertTrue(counter.maxCount > 0);
+ assertTrue(counter.maxCount <= MAX_LEASES);
System.out.println(counter.maxCount);
}
}
@@ -572,7 +576,7 @@
);
}
service.shutdown();
- Assert.assertTrue(service.awaitTermination(10, TimeUnit.SECONDS));
+ assertTrue(service.awaitTermination(10, TimeUnit.SECONDS));
}
finally
{
@@ -589,8 +593,8 @@
try
{
InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", 1);
- Assert.assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
- Assert.assertNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
}
finally
{
@@ -613,16 +617,16 @@
{
InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", MAX_LEASES);
Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
leases.add(lease);
}
InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", MAX_LEASES);
Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNull(lease);
+ assertNull(lease);
leases.remove(0).close();
- Assert.assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
}
finally
{
@@ -651,7 +655,7 @@
leases.add(semaphore.acquire());
}
- Assert.assertEquals(semaphore.getParticipantNodes().size(), LEASES);
+ assertEquals(semaphore.getParticipantNodes().size(), LEASES);
}
finally
{
@@ -674,9 +678,9 @@
{
final InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", 1);
Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
final List<String> childNodes = client.getChildren().forPath("/test/leases");
- Assert.assertEquals(childNodes.size(), 1);
+ assertEquals(childNodes.size(), 1);
final CountDownLatch nodeCreatedLatch = new CountDownLatch(1);
client.getChildren().usingWatcher(new CuratorWatcher()
@@ -710,7 +714,7 @@
newNode = c;
}
}
- Assert.assertNotNull(newNode);
+ assertNotNull(newNode);
// delete the ephemeral node to trigger a retry
client.delete().forPath("/test/leases/" + newNode);
@@ -718,12 +722,12 @@
// release first lease so second one can be acquired
lease.close();
lease = leaseFuture.get();
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
lease.close();
- Assert.assertEquals(client.getChildren().forPath("/test/leases").size(), 0);
+ assertEquals(client.getChildren().forPath("/test/leases").size(), 0);
// no more lease exist. must be possible to acquire a new one
- Assert.assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
}
finally
{
@@ -749,7 +753,7 @@
// Acquire exclusive semaphore
Lease lease = s1.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(lease);
+ assertNotNull(lease);
// Queue up another semaphore on the same path
Future<Object> handle = Executors.newSingleThreadExecutor().submit(new Callable<Object>() {
@@ -762,18 +766,18 @@
});
// Wait until second lease is created and the wait is started for it to become active
- Assert.assertTrue(timing.awaitLatch(debugWaitLatch));
+ assertTrue(timing.awaitLatch(debugWaitLatch));
// Interrupt the wait
handle.cancel(true);
// Assert that the second lease is gone
timing.sleepABit();
- Assert.assertEquals(client.getChildren().forPath("/test/leases").size(), 1);
+ assertEquals(client.getChildren().forPath("/test/leases").size(), 1);
// Assert that after closing the first (current) semaphore, we can acquire a new one
s1.returnLease(lease);
- Assert.assertNotNull(s3.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertNotNull(s3.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreCluster.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreCluster.java
index 3470eff..01bd332 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreCluster.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreCluster.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.ensemble.EnsembleProvider;
import org.apache.curator.framework.CuratorFramework;
@@ -32,8 +35,9 @@
import org.apache.curator.test.Timing;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@@ -47,7 +51,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestInterProcessSemaphoreCluster extends BaseClassForTests
{
@Test
@@ -168,22 +172,22 @@
);
}
- Assert.assertTrue(timing.acquireSemaphore(acquiredSemaphore));
- Assert.assertEquals(1, acquireCount.get());
+ assertTrue(timing.acquireSemaphore(acquiredSemaphore));
+ assertEquals(1, acquireCount.get());
cluster.close();
timing.awaitLatch(suspendedLatch);
timing.forWaiting().sleepABit();
- Assert.assertEquals(0, acquireCount.get());
+ assertEquals(0, acquireCount.get());
cluster = createAndStartCluster(3);
connectionString.set(cluster.getConnectString());
timing.forWaiting().sleepABit();
- Assert.assertTrue(timing.acquireSemaphore(acquiredSemaphore));
+ assertTrue(timing.acquireSemaphore(acquiredSemaphore));
timing.forWaiting().sleepABit();
- Assert.assertEquals(1, acquireCount.get());
+ assertEquals(1, acquireCount.get());
}
finally
{
@@ -232,7 +236,7 @@
timing.forWaiting().sleepABit();
- Assert.assertNotNull(SemaphoreClient.getActiveClient());
+ assertNotNull(SemaphoreClient.getActiveClient());
final CountDownLatch latch = new CountDownLatch(1);
CuratorFramework client = CuratorFrameworkFactory.newClient(cluster.getConnectString(), timing.session(), timing.connection(), new ExponentialBackoffRetry(100, 3));
@@ -271,7 +275,7 @@
{
break; // checking that the op count isn't increasing
}
- Assert.assertTrue((System.currentTimeMillis() - startTicks) < timing.forWaiting().milliseconds());
+ assertTrue((System.currentTimeMillis() - startTicks) < timing.forWaiting().milliseconds());
}
int thisOpCount = opCount.get();
@@ -289,7 +293,7 @@
{
break; // checking that semaphore has started working again
}
- Assert.assertTrue((System.currentTimeMillis() - startTicks) < timing.forWaiting().milliseconds());
+ assertTrue((System.currentTimeMillis() - startTicks) < timing.forWaiting().milliseconds());
}
}
finally
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreMutex.java
index 90bd7da..d81d793 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreMutex.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphoreMutex.java
@@ -19,26 +19,30 @@
package org.apache.curator.framework.recipes.locks;
import org.apache.curator.framework.CuratorFramework;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
public class TestInterProcessSemaphoreMutex extends TestInterProcessMutexBase
{
private static final String LOCK_PATH = LOCK_BASE_PATH + "/our-lock";
@Override
- @Test(enabled = false)
+ @Test
+ @Disabled
public void testReentrant()
{
}
@Override
- @Test(enabled = false)
+ @Test
+ @Disabled
public void testReentrant2Threads()
{
}
@Override
- @Test(enabled = false)
+ @Test
+ @Disabled
public void testReentrantSingleLock()
{
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java
index 3676d6f..f110a97 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java
@@ -19,6 +19,9 @@
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
@@ -30,8 +33,8 @@
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Collections;
import java.util.List;
@@ -60,18 +63,18 @@
try
{
client.create().forPath("/foo");
- Assert.assertNotNull(client.checkExists().forPath("/foo"));
- Assert.assertEquals(ZooDefs.Perms.ALL, client.getACL().forPath("/foo").get(0).getPerms());
- Assert.assertEquals("ip", client.getACL().forPath("/foo").get(0).getId().getScheme());
- Assert.assertEquals("127.0.0.1", client.getACL().forPath("/foo").get(0).getId().getId());
+ assertNotNull(client.checkExists().forPath("/foo"));
+ assertEquals(ZooDefs.Perms.ALL, client.getACL().forPath("/foo").get(0).getPerms());
+ assertEquals("ip", client.getACL().forPath("/foo").get(0).getId().getScheme());
+ assertEquals("127.0.0.1", client.getACL().forPath("/foo").get(0).getId().getId());
InterProcessReadWriteLock lock = new InterProcessReadWriteLock(client, "/bar");
InterProcessMutex writeLock = lock.writeLock();
writeLock.acquire();
- Assert.assertNotNull(client.checkExists().forPath("/bar"));
- Assert.assertEquals(ZooDefs.Perms.ALL, client.getACL().forPath("/bar").get(0).getPerms());
- Assert.assertEquals("ip", client.getACL().forPath("/bar").get(0).getId().getScheme());
- Assert.assertEquals("127.0.0.1", client.getACL().forPath("/bar").get(0).getId().getId());
+ assertNotNull(client.checkExists().forPath("/bar"));
+ assertEquals(ZooDefs.Perms.ALL, client.getACL().forPath("/bar").get(0).getPerms());
+ assertEquals("ip", client.getACL().forPath("/bar").get(0).getId().getScheme());
+ assertEquals("127.0.0.1", client.getACL().forPath("/bar").get(0).getId().getId());
}
finally
{
@@ -86,8 +89,8 @@
try
{
client.create().creatingParentsIfNeeded().forPath("/parent/foo");
- Assert.assertEquals(ZooDefs.Perms.CREATE | ZooDefs.Perms.READ, client.getACL().forPath("/parent").get(0).getPerms());
- Assert.assertEquals(ZooDefs.Perms.ALL, client.getACL().forPath("/parent/foo").get(0).getPerms());
+ assertEquals(ZooDefs.Perms.CREATE | ZooDefs.Perms.READ, client.getACL().forPath("/parent").get(0).getPerms());
+ assertEquals(ZooDefs.Perms.ALL, client.getACL().forPath("/parent/foo").get(0).getPerms());
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockCleanlinessWithFaults.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockCleanlinessWithFaults.java
index dc14c11..d73e73c 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockCleanlinessWithFaults.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockCleanlinessWithFaults.java
@@ -18,15 +18,17 @@
*/
package org.apache.curator.framework.recipes.locks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.test.BaseClassForTests;
-import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.KeeperException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
public class TestLockCleanlinessWithFaults extends BaseClassForTests
@@ -43,7 +45,7 @@
client.start();
client.create().creatingParentsIfNeeded().forPath(PATH);
- Assert.assertEquals(client.checkExists().forPath(PATH).getNumChildren(), 0);
+ assertEquals(client.checkExists().forPath(PATH).getNumChildren(), 0);
LockInternals internals = new LockInternals(client, new StandardLockInternalsDriver(), PATH, "lock-", 1)
{
@@ -56,7 +58,7 @@
try
{
internals.attemptLock(0, null, null);
- Assert.fail();
+ fail();
}
catch ( KeeperException.NoNodeException dummy )
{
@@ -64,7 +66,7 @@
}
// make sure no nodes are left lying around
- Assert.assertEquals(client.checkExists().forPath(PATH).getNumChildren(), 0);
+ assertEquals(client.checkExists().forPath(PATH).getNumChildren(), 0);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
index 4395b36..1416533 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.recipes.nodes;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import org.apache.curator.framework.CuratorFramework;
@@ -27,11 +31,12 @@
import org.apache.curator.test.Timing;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.Map;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestGroupMember extends BaseClassForTests
{
// NOTE - don't need many tests as this class is just a wrapper around two existing recipes
@@ -48,7 +53,7 @@
client.start();
groupMember1 = new GroupMember(client, "/member", "1");
- Assert.assertTrue(groupMember1.getCurrentMembers().containsKey("1"));
+ assertTrue(groupMember1.getCurrentMembers().containsKey("1"));
groupMember1.start();
groupMember2 = new GroupMember(client, "/member", "2");
@@ -74,27 +79,27 @@
return new String(input);
}
});
- Assert.assertEquals(convertMembers1.size(), 2);
- Assert.assertEquals(convertMembers2.size(), 2);
- Assert.assertEquals(convertMembers1, convertMembers2);
- Assert.assertTrue(convertMembers1.containsKey("1"));
- Assert.assertTrue(convertMembers1.containsKey("2"));
+ assertEquals(convertMembers1.size(), 2);
+ assertEquals(convertMembers2.size(), 2);
+ assertEquals(convertMembers1, convertMembers2);
+ assertTrue(convertMembers1.containsKey("1"));
+ assertTrue(convertMembers1.containsKey("2"));
groupMember2.close();
timing.sleepABit();
currentMembers1 = groupMember1.getCurrentMembers();
- Assert.assertEquals(currentMembers1.size(), 1);
- Assert.assertTrue(currentMembers1.containsKey("1"));
- Assert.assertFalse(currentMembers1.containsKey("2"));
+ assertEquals(currentMembers1.size(), 1);
+ assertTrue(currentMembers1.containsKey("1"));
+ assertFalse(currentMembers1.containsKey("2"));
groupMember1.setThisData("something".getBytes());
timing.sleepABit();
currentMembers1 = groupMember1.getCurrentMembers();
- Assert.assertTrue(currentMembers1.containsKey("1"));
- Assert.assertEquals(currentMembers1.get("1"), "something".getBytes());
+ assertTrue(currentMembers1.containsKey("1"));
+ assertArrayEquals(currentMembers1.get("1"), "something".getBytes());
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
index 7acde06..7e4835d 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
@@ -18,6 +18,13 @@
*/
package org.apache.curator.framework.recipes.nodes;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
@@ -41,11 +48,10 @@
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Stat;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
@@ -56,8 +62,6 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import static org.testng.Assert.*;
-
@SuppressWarnings("deprecation")
public class TestPersistentEphemeralNode extends BaseClassForTests
{
@@ -70,7 +74,7 @@
private final Timing2 timing = new Timing2();
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -126,14 +130,14 @@
client.getConnectionStateListenable().addListener(listener);
timing.sleepABit();
server.restart();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
timing.sleepABit();
- Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
server.stop();
timing.sleepABit();
server.restart();
timing.sleepABit();
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
}
}
finally
@@ -174,11 +178,11 @@
server.restart();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
timing.sleepABit();
- Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
}
finally
{
@@ -187,31 +191,39 @@
}
}
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullCurator() throws Exception
+ @Test
+ public void testNullCurator()
{
- new PersistentEphemeralNode(null, PersistentEphemeralNode.Mode.EPHEMERAL, PATH, new byte[0]);
+ assertThrows(NullPointerException.class, ()-> {
+ new PersistentEphemeralNode(null, PersistentEphemeralNode.Mode.EPHEMERAL, PATH, new byte[0]);
+ });
}
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testNullPath() throws Exception
+ @Test
+ public void testNullPath()
{
- CuratorFramework curator = newCurator();
- new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL, null, new byte[0]);
+ assertThrows(IllegalArgumentException.class, ()-> {
+ CuratorFramework curator = newCurator();
+ new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL, null, new byte[0]);
+ });
}
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullData() throws Exception
+ @Test
+ public void testNullData()
{
- CuratorFramework curator = newCurator();
- new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL, PATH, null);
+ assertThrows(NullPointerException.class, ()-> {
+ CuratorFramework curator = newCurator();
+ new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL, PATH, null);
+ });
}
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullMode() throws Exception
+ @Test
+ public void testNullMode()
{
- CuratorFramework curator = newCurator();
- new PersistentEphemeralNode(curator, null, PATH, new byte[0]);
+ assertThrows(NullPointerException.class, ()->{
+ CuratorFramework curator = newCurator();
+ new PersistentEphemeralNode(curator, null, PATH, new byte[0]);
+ });
}
@Test
@@ -236,9 +248,9 @@
node = new PersistentEphemeralNode(client, mode, PATH, "a".getBytes());
node.debugWaitMsForBackgroundBeforeClose.set(timing.forSleepingABit().milliseconds());
node.start();
- Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertTrue(node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS));
- Assert.assertEquals(client.getData().forPath(node.getActualPath()), "a".getBytes());
+ assertArrayEquals(client.getData().forPath(node.getActualPath()), "a".getBytes());
final Semaphore semaphore = new Semaphore(0);
Watcher watcher = new Watcher()
@@ -251,15 +263,15 @@
};
client.checkExists().usingWatcher(watcher).forPath(node.getActualPath());
node.setData("b".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(node.getActualPath(), node.getActualPath());
- Assert.assertEquals(client.getData().usingWatcher(watcher).forPath(node.getActualPath()), "b".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertEquals(node.getActualPath(), node.getActualPath());
+ assertArrayEquals(client.getData().usingWatcher(watcher).forPath(node.getActualPath()), "b".getBytes());
node.setData("c".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
- Assert.assertEquals(node.getActualPath(), node.getActualPath());
- Assert.assertEquals(client.getData().usingWatcher(watcher).forPath(node.getActualPath()), "c".getBytes());
+ assertTrue(timing.acquireSemaphore(semaphore));
+ assertEquals(node.getActualPath(), node.getActualPath());
+ assertArrayEquals(client.getData().usingWatcher(watcher).forPath(node.getActualPath()), "c".getBytes());
node.close();
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
}
finally
{
@@ -395,7 +407,7 @@
{
Trigger deletionTrigger = Trigger.deletedOrSetData();
Stat stat = observer.checkExists().usingWatcher(deletionTrigger).forPath(path);
- Assert.assertNotNull(stat, "node should exist: " + path);
+ assertNotNull(stat, "node should exist: " + path);
node.debugCreateNodeLatch = new CountDownLatch(1);
// Kill the session, thus cleaning up the node...
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java
index 6771eec..6a411af 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java
@@ -19,17 +19,19 @@
package org.apache.curator.framework.recipes.nodes;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
-import org.apache.curator.test.TestingServer;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
@@ -72,14 +74,14 @@
client.getConnectionStateListenable().addListener(listener);
timing.sleepABit();
server.restart();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
+ assertTrue(timing.awaitLatch(connectedLatch));
timing.sleepABit();
- Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
server.restart();
timing.sleepABit();
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
timing.sleepABit();
- Assert.assertEquals(lastState.get(), ConnectionState.RECONNECTED);
+ assertEquals(lastState.get(), ConnectionState.RECONNECTED);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java
index b157000..620c9cc 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java
@@ -18,6 +18,12 @@
*/
package org.apache.curator.framework.recipes.nodes;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
@@ -26,8 +32,7 @@
import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.CreateMode;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -51,7 +56,7 @@
try
{
pen.setData(ALT_TEST_DATA);
- Assert.fail("IllegalStateException should have been thrown");
+ fail("IllegalStateException should have been thrown");
}
catch ( IllegalStateException dummy )
{
@@ -79,14 +84,14 @@
pen = new PersistentNode(client, CreateMode.PERSISTENT, false, "/test", TEST_DATA);
pen.debugWaitMsForBackgroundBeforeClose.set(timing.forSleepingABit().milliseconds());
pen.start();
- Assert.assertTrue(pen.waitForInitialCreate(timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(pen.waitForInitialCreate(timing.milliseconds(), TimeUnit.MILLISECONDS));
client.close(); // cause session to end - force checks that node is persistent
client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
client.start();
byte[] bytes = client.getData().forPath("/test");
- Assert.assertEquals(bytes, TEST_DATA);
+ assertArrayEquals(bytes, TEST_DATA);
}
finally
{
@@ -108,7 +113,7 @@
pen.start();
pen.close();
timing.sleepABit();
- Assert.assertNull(client.checkExists().forPath("/test/one/two"));
+ assertNull(client.checkExists().forPath("/test/one/two"));
}
finally
{
@@ -132,7 +137,7 @@
pen.start();
pen.close();
timing.sleepABit();
- Assert.assertNull(client.checkExists().forPath("/test/one/two"));
+ assertNull(client.checkExists().forPath("/test/one/two"));
}
finally
{
@@ -156,14 +161,14 @@
pen.start();
List<String> children = client.getChildren().forPath("/test/one");
System.out.println("children before restart: "+children);
- Assert.assertEquals(1, children.size());
+ assertEquals(1, children.size());
server.stop();
timing.sleepABit();
server.restart();
timing.sleepABit();
List<String> childrenAfter = client.getChildren().forPath("/test/one");
System.out.println("children after restart: "+childrenAfter);
- Assert.assertEquals(children, childrenAfter, "unexpected znodes: "+childrenAfter);
+ assertEquals(children, childrenAfter, "unexpected znodes: "+childrenAfter);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index b95df11..040bb05 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.framework.recipes.nodes;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
@@ -27,11 +32,11 @@
import org.apache.curator.test.Timing;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.ZKPaths;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -42,12 +47,12 @@
private final Timing timing = new Timing();
private final long ttlMs = timing.multiple(.10).milliseconds(); // a small number
- @BeforeClass
+ @BeforeAll
public static void setUpClass() {
System.setProperty("zookeeper.extendedTypesEnabled", "true");
}
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -55,7 +60,7 @@
super.setup();
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -73,18 +78,18 @@
try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", ttlMs, new byte[0]))
{
node.start();
- Assert.assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
+ assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
for ( int i = 0; i < 5; ++i )
{
Thread.sleep(ttlMs + (ttlMs / 2)); // sleep a bit more than the TTL
- Assert.assertNotNull(client.checkExists().forPath("/test"));
+ assertNotNull(client.checkExists().forPath("/test"));
}
}
- Assert.assertNotNull(client.checkExists().forPath("/test"));
+ assertNotNull(client.checkExists().forPath("/test"));
timing.sleepABit();
- Assert.assertNull(client.checkExists().forPath("/test"));
+ assertNull(client.checkExists().forPath("/test"));
}
}
@@ -98,7 +103,7 @@
try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", ttlMs, new byte[0]))
{
node.start();
- Assert.assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
+ assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
for ( int i = 0; i < 5; ++i )
{
@@ -107,7 +112,7 @@
}
timing.sleepABit();
- Assert.assertNotNull(client.checkExists().forPath("/test"));
+ assertNotNull(client.checkExists().forPath("/test"));
}
}
}
@@ -138,23 +143,23 @@
cache.getListenable().addListener(listener);
node.start();
- Assert.assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
+ assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
cache.start(BUILD_INITIAL_CACHE);
- Assert.assertEquals(changes.availablePermits(), 0);
+ assertEquals(changes.availablePermits(), 0);
timing.sleepABit();
- Assert.assertEquals(changes.availablePermits(), 0);
+ assertEquals(changes.availablePermits(), 0);
client.setData().forPath("/test", "changed".getBytes());
- Assert.assertTrue(timing.acquireSemaphore(changes));
+ assertTrue(timing.acquireSemaphore(changes));
timing.sleepABit();
- Assert.assertEquals(changes.availablePermits(), 0);
+ assertEquals(changes.availablePermits(), 0);
}
}
timing.sleepABit();
- Assert.assertNull(client.checkExists().forPath("/test"));
+ assertNull(client.checkExists().forPath("/test"));
}
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java
index 80b4861..9547d41 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.recipes.queue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.CuratorFrameworkState;
@@ -28,8 +32,8 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
@@ -180,7 +184,7 @@
for ( int count : counts )
{
- Assert.assertTrue(count <= (MAX_ITEMS * CLIENT_QTY), counts.toString());
+ assertTrue(count <= (MAX_ITEMS * CLIENT_QTY), counts.toString());
}
}
finally
@@ -235,16 +239,16 @@
};
queue.getPutListenerContainer().addListener(listener);
- Assert.assertTrue(queue.put("1", timing.milliseconds(), TimeUnit.MILLISECONDS)); // should end up in consumer
- Assert.assertTrue(queue.put("2", timing.milliseconds(), TimeUnit.MILLISECONDS)); // should sit blocking in DistributedQueue
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(queue.put("1", timing.milliseconds(), TimeUnit.MILLISECONDS)); // should end up in consumer
+ assertTrue(queue.put("2", timing.milliseconds(), TimeUnit.MILLISECONDS)); // should sit blocking in DistributedQueue
+ assertTrue(timing.awaitLatch(latch));
timing.sleepABit();
- Assert.assertFalse(queue.put("3", timing.multiple(.5).milliseconds(), TimeUnit.MILLISECONDS));
+ assertFalse(queue.put("3", timing.multiple(.5).milliseconds(), TimeUnit.MILLISECONDS));
semaphore.release(100);
- Assert.assertTrue(queue.put("3", timing.milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertTrue(queue.put("4", timing.milliseconds(), TimeUnit.MILLISECONDS));
- Assert.assertTrue(queue.put("5", timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(queue.put("3", timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(queue.put("4", timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(queue.put("5", timing.milliseconds(), TimeUnit.MILLISECONDS));
for ( int i = 0; i < 5; ++i )
{
@@ -256,7 +260,7 @@
}
timing.sleepABit();
- Assert.assertEquals(messages, Arrays.asList("1", "2", "3", "4", "5"));
+ assertEquals(messages, Arrays.asList("1", "2", "3", "4", "5"));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java
index a76f449..f130a30 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.framework.recipes.queue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -25,10 +30,8 @@
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.Timing;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -54,14 +57,14 @@
queue.put(1L, System.currentTimeMillis() + Integer.MAX_VALUE); // never come out
Long value = consumer.take(1, TimeUnit.SECONDS);
- Assert.assertNull(value);
+ assertNull(value);
queue.put(2L, System.currentTimeMillis());
value = consumer.take(timing.seconds(), TimeUnit.SECONDS);
- Assert.assertEquals(value, Long.valueOf(2));
+ assertEquals(value, Long.valueOf(2));
value = consumer.take(1, TimeUnit.SECONDS);
- Assert.assertNull(value);
+ assertNull(value);
}
finally
{
@@ -85,10 +88,10 @@
queue.put(1L, System.currentTimeMillis() + 1000);
Thread.sleep(100);
- Assert.assertEquals(consumer.size(), 0); // delay hasn't been reached
+ assertEquals(consumer.size(), 0); // delay hasn't been reached
Long value = consumer.take(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertEquals(value, Long.valueOf(1));
+ assertEquals(value, Long.valueOf(1));
}
finally
{
@@ -123,8 +126,8 @@
for ( int i = 0; i < QTY; ++i )
{
Long value = consumer.take(timing.forWaiting().seconds(), TimeUnit.SECONDS);
- Assert.assertNotNull(value);
- Assert.assertTrue(value >= lastValue);
+ assertNotNull(value);
+ assertTrue(value >= lastValue);
lastValue = value;
}
}
@@ -188,8 +191,8 @@
for ( int i = 0; i < QTY; ++i )
{
Long value = consumer.take(DELAY_MS * 2, TimeUnit.MILLISECONDS);
- Assert.assertNotNull(value);
- Assert.assertEquals(value, new Long(lastValue + 1));
+ assertNotNull(value);
+ assertEquals(value, new Long(lastValue + 1));
lastValue = value;
}
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
index 24f74a1..c2a81ab 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.recipes.queue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
@@ -26,9 +28,8 @@
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.retry.RetryOneTime;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -70,8 +71,8 @@
queue.put(new TestQueueItem("test"), "id");
- Assert.assertTrue(consumingLatch.await(10, TimeUnit.SECONDS)); // wait until consumer has it
- Assert.assertEquals(queue.remove("id"), 0);
+ assertTrue(consumingLatch.await(10, TimeUnit.SECONDS)); // wait until consumer has it
+ assertEquals(queue.remove("id"), 0);
waitLatch.countDown();
}
@@ -108,14 +109,14 @@
int iteration = 0;
while ( consumer.size() < ITEM_QTY )
{
- Assert.assertTrue(++iteration < ITEM_QTY);
+ assertTrue(++iteration < ITEM_QTY);
Thread.sleep(1000);
}
int i = 0;
for ( TestQueueItem item : consumer.getItems() )
{
- Assert.assertEquals(item.str, ids.get(i++));
+ assertEquals(item.str, ids.get(i++));
}
}
finally
@@ -156,13 +157,13 @@
queue.put(new TestQueueItem("test"), "id");
- Assert.assertTrue(consumingLatch.await(10, TimeUnit.SECONDS)); // wait until consumer has it
+ assertTrue(consumingLatch.await(10, TimeUnit.SECONDS)); // wait until consumer has it
// Sleep one more second
Thread.sleep(1000);
- Assert.assertTrue(queue.debugIsQueued("id"));
+ assertTrue(queue.debugIsQueued("id"));
}
finally
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedPriorityQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedPriorityQueue.java
index 6c5ac7d..59b1227 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedPriorityQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedPriorityQueue.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.framework.recipes.queue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -26,9 +31,8 @@
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.Timing;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -58,7 +62,7 @@
queue.put(i, 10 + i);
}
- Assert.assertEquals(consumer.take(1, TimeUnit.SECONDS), new Integer(0));
+ assertEquals(consumer.take(1, TimeUnit.SECONDS), new Integer(0));
queue.put(1000, 1); // lower priority
int count = 0;
@@ -66,7 +70,7 @@
{
++count;
}
- Assert.assertTrue(Math.abs(minItemsBeforeRefresh - count) < minItemsBeforeRefresh, String.format("Diff: %d - min: %d", Math.abs(minItemsBeforeRefresh - count), minItemsBeforeRefresh)); // allows for some slack - testing that within a slop value the newly inserted item with lower priority comes out
+ assertTrue(Math.abs(minItemsBeforeRefresh - count) < minItemsBeforeRefresh, String.format("Diff: %d - min: %d", Math.abs(minItemsBeforeRefresh - count), minItemsBeforeRefresh)); // allows for some slack - testing that within a slop value the newly inserted item with lower priority comes out
}
finally
{
@@ -106,12 +110,12 @@
queue.put(i, 10);
}
- Assert.assertEquals(blockingQueue.poll(timing.seconds(), TimeUnit.SECONDS), new Integer(0));
+ assertEquals(blockingQueue.poll(timing.seconds(), TimeUnit.SECONDS), new Integer(0));
timing.sleepABit();
queue.put(1000, 1); // lower priority
timing.sleepABit();
- Assert.assertEquals(blockingQueue.poll(timing.seconds(), TimeUnit.SECONDS), new Integer(1)); // is in consumer already
- Assert.assertEquals(blockingQueue.poll(timing.seconds(), TimeUnit.SECONDS), new Integer(1000));
+ assertEquals(blockingQueue.poll(timing.seconds(), TimeUnit.SECONDS), new Integer(1)); // is in consumer already
+ assertEquals(blockingQueue.poll(timing.seconds(), TimeUnit.SECONDS), new Integer(1000));
}
finally
{
@@ -197,7 +201,7 @@
nums.add(Integer.MIN_VALUE);
queue.put(Integer.MIN_VALUE, Integer.MIN_VALUE); // the queue background thread will be blocking with the first item - make sure it's the lowest value
- Assert.assertTrue(timing.awaitLatch(hasConsumedLatch));
+ assertTrue(timing.awaitLatch(hasConsumedLatch));
Random random = new Random();
for ( int i = 0; i < 100; ++i )
@@ -222,7 +226,7 @@
{
message.append(i).append("\t").append(DistributedPriorityQueue.priorityToString(i)).append("\n");
}
- Assert.fail(message.toString());
+ fail(message.toString());
}
finally
{
@@ -237,10 +241,10 @@
for ( int i = 0; i < qty; ++i )
{
Integer value = consumer.take(10, TimeUnit.SECONDS);
- Assert.assertNotNull(value);
+ assertNotNull(value);
if ( i > 0 )
{
- Assert.assertTrue(value >= previous, String.format("Value: (%d:%s) Previous: (%d:%s)", value, DistributedPriorityQueue.priorityToString(value), previous, DistributedPriorityQueue.priorityToString(previous)));
+ assertTrue(value >= previous, String.format("Value: (%d:%s) Previous: (%d:%s)", value, DistributedPriorityQueue.priorityToString(value), previous, DistributedPriorityQueue.priorityToString(previous)));
}
previous = value;
}
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
index 971b1ec..e9f6014 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.recipes.queue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.curator.test.BaseClassForTests;
@@ -34,9 +38,8 @@
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.Timing;
import org.apache.zookeeper.CreateMode;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -107,9 +110,9 @@
queue.put(new TestQueueItem("test"));
retryCounter.await(10, TimeUnit.SECONDS);
- Assert.assertEquals(retryCounter.getCount(), 0, "Queue item was not consumed. Retry counter is " + retryCounter.getCount());
- Assert.assertEquals(names.size(), 2);
- Assert.assertEquals(names.get(0).length(), names.get(1).length(), "name1: " + names.get(0) + " - " + "name2: " + names.get(1));
+ assertEquals(retryCounter.getCount(), 0, "Queue item was not consumed. Retry counter is " + retryCounter.getCount());
+ assertEquals(names.size(), 2);
+ assertEquals(names.get(0).length(), names.get(1).length(), "name1: " + names.get(0) + " - " + "name2: " + names.get(1));
}
finally
{
@@ -200,9 +203,9 @@
queue.put(Integer.toString(i));
}
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
- Assert.assertTrue(doubleUsed.size() == 0, doubleUsed.toString());
+ assertTrue(doubleUsed.size() == 0, doubleUsed.toString());
}
finally
{
@@ -250,17 +253,17 @@
int iteration = 0;
while ( consumer.size() < itemQty )
{
- Assert.assertTrue(++iteration < 10);
+ assertTrue(++iteration < 10);
Thread.sleep(1000);
}
int i = 0;
for ( TestQueueItem item : consumer.getItems() )
{
- Assert.assertEquals(item.str, Integer.toString(i++));
+ assertEquals(item.str, Integer.toString(i++));
}
- Assert.assertEquals(listenerCalls.get(), itemQty);
+ assertEquals(listenerCalls.get(), itemQty);
}
finally
{
@@ -304,8 +307,8 @@
TestQueueItem item = new TestQueueItem("1");
queue.put(item);
- Assert.assertTrue(timing.awaitLatch(latch.get()));
- Assert.assertEquals(count.get(), 2);
+ assertTrue(timing.awaitLatch(latch.get()));
+ assertEquals(count.get(), 2);
queue.setErrorMode(ErrorMode.DELETE);
@@ -315,8 +318,8 @@
item = new TestQueueItem("1");
queue.put(item);
- Assert.assertFalse(latch.get().await(5, TimeUnit.SECONDS)); // consumer should get called only once
- Assert.assertEquals(count.get(), 1);
+ assertFalse(latch.get().await(5, TimeUnit.SECONDS)); // consumer should get called only once
+ assertEquals(count.get(), 1);
}
finally
{
@@ -409,7 +412,7 @@
}
timing.awaitLatch(latch);
- Assert.assertTrue(duplicateMessages.size() == 0, duplicateMessages.toString());
+ assertTrue(duplicateMessages.size() == 0, duplicateMessages.toString());
}
finally
{
@@ -530,12 +533,12 @@
int i = 0;
for ( TestQueueItem item : takenItems )
{
- Assert.assertEquals(item.str, Integer.toString(i++));
+ assertEquals(item.str, Integer.toString(i++));
}
- Assert.assertNotNull(thrownItemFromConsumer1.get());
- Assert.assertTrue((takenItemsForConsumer2.contains(thrownItemFromConsumer1.get())));
- Assert.assertTrue(Sets.intersection(takenItemsForConsumer1, takenItemsForConsumer2).size() == 0);
+ assertNotNull(thrownItemFromConsumer1.get());
+ assertTrue((takenItemsForConsumer2.contains(thrownItemFromConsumer1.get())));
+ assertTrue(Sets.intersection(takenItemsForConsumer1, takenItemsForConsumer2).size() == 0);
}
finally
{
@@ -593,14 +596,14 @@
for ( int i = 0; i < itemQty; ++i )
{
TestQueueItem item = consumer.take();
- Assert.assertEquals(item.str, Integer.toString(i));
+ assertEquals(item.str, Integer.toString(i));
}
latch.countDown();
return null;
}
}
);
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
@@ -643,8 +646,8 @@
for ( int i = 0; i < itemQty; ++i )
{
TestQueueItem queueItem = consumer.take(1, TimeUnit.SECONDS);
- Assert.assertNotNull(queueItem);
- Assert.assertEquals(queueItem, new TestQueueItem(Integer.toString(i)));
+ assertNotNull(queueItem);
+ assertEquals(queueItem, new TestQueueItem(Integer.toString(i)));
}
}
finally
@@ -679,13 +682,13 @@
int iteration = 0;
while ( consumer.size() < itemQty )
{
- Assert.assertTrue(++iteration < 10);
+ assertTrue(++iteration < 10);
Thread.sleep(1000);
}
List<TestQueueItem> items = consumer.getItems();
- Assert.assertEquals(com.google.common.collect.Sets.<TestQueueItem>newHashSet(items).size(), items.size()); // check no duplicates
+ assertEquals(com.google.common.collect.Sets.<TestQueueItem>newHashSet(items).size(), items.size()); // check no duplicates
}
finally
{
@@ -736,10 +739,10 @@
queue.start();
queue.put(new TestQueueItem("1"));
- Assert.assertFalse(queue.flushPuts(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertFalse(queue.flushPuts(timing.forWaiting().seconds(), TimeUnit.SECONDS));
latch.countDown();
- Assert.assertTrue(queue.flushPuts(timing.forWaiting().seconds(), TimeUnit.SECONDS));
+ assertTrue(queue.flushPuts(timing.forWaiting().seconds(), TimeUnit.SECONDS));
}
finally
{
@@ -776,14 +779,14 @@
int iteration = 0;
while ( consumer.size() < itemQty )
{
- Assert.assertTrue(++iteration < 10);
+ assertTrue(++iteration < 10);
Thread.sleep(1000);
}
int i = 0;
for ( TestQueueItem item : consumer.getItems() )
{
- Assert.assertEquals(item.str, Integer.toString(i++));
+ assertEquals(item.str, Integer.toString(i++));
}
}
finally
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestQueueSharder.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestQueueSharder.java
index 7c4f298..8e25062 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestQueueSharder.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestQueueSharder.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.recipes.queue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Sets;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
import org.apache.curator.framework.CuratorFramework;
@@ -28,8 +31,8 @@
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.Timing;
import org.apache.curator.utils.CloseableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -79,13 +82,13 @@
for ( String path : sharder.getQueuePaths() )
{
int numChildren = client.checkExists().forPath(path).getNumChildren();
- Assert.assertTrue(numChildren > 0);
- Assert.assertTrue(numChildren >= (threshold * .1));
+ assertTrue(numChildren > 0);
+ assertTrue(numChildren >= (threshold * .1));
statistics.addValue(numChildren);
}
latch.countDown();
- Assert.assertTrue(statistics.getMean() >= (threshold * .9));
+ assertTrue(statistics.getMean() >= (threshold * .9));
}
finally
{
@@ -119,9 +122,9 @@
}
timing.sleepABit();
- Assert.assertTrue((sharder1.getShardQty() > 1) || (sharder2.getShardQty() > 1));
+ assertTrue((sharder1.getShardQty() > 1) || (sharder2.getShardQty() > 1));
timing.forWaiting().sleepABit();
- Assert.assertEquals(sharder1.getShardQty(), sharder2.getShardQty());
+ assertEquals(sharder1.getShardQty(), sharder2.getShardQty());
}
finally
{
@@ -160,17 +163,17 @@
sharder.getQueue().put("eight");
timing.sleepABit();
- Assert.assertTrue(sharder.getShardQty() > 1);
+ assertTrue(sharder.getShardQty() > 1);
Set<String> consumed = Sets.newHashSet();
for ( int i = 0; i < 8; ++i )
{
String s = consumer.take(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertNotNull(s);
+ assertNotNull(s);
consumed.add(s);
}
- Assert.assertEquals(consumed, Sets.newHashSet("one", "two", "three", "four", "five", "six", "seven", "eight"));
+ assertEquals(consumed, Sets.newHashSet("one", "two", "three", "four", "five", "six", "seven", "eight"));
int shardQty = sharder.getShardQty();
sharder.close();
@@ -179,7 +182,7 @@
sharder = new QueueSharder<String, DistributedQueue<String>>(client, distributedQueueAllocator, "/queues", "/leader", policies);
sharder.start();
- Assert.assertEquals(sharder.getShardQty(), shardQty);
+ assertEquals(sharder.getShardQty(), shardQty);
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestSimpleDistributedQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestSimpleDistributedQueue.java
index ec4c3d1..2b90449 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestSimpleDistributedQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestSimpleDistributedQueue.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.framework.recipes.queue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.TestingServer;
import org.apache.curator.test.Timing;
@@ -25,16 +29,13 @@
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.NoSuchElementException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
public class TestSimpleDistributedQueue extends BaseClassForTests
{
private static abstract class QueueUser implements Runnable
@@ -113,7 +114,7 @@
});
executor.shutdown();
- Assert.assertTrue(executor.awaitTermination((QueueUser.ITEM_COUNT * 2) * timing.milliseconds(), TimeUnit.MILLISECONDS));
+ assertTrue(executor.awaitTermination((QueueUser.ITEM_COUNT * 2) * timing.milliseconds(), TimeUnit.MILLISECONDS));
}
finally
{
@@ -139,7 +140,7 @@
queueHandles[i] = new SimpleDistributedQueue(clients[i], dir);
}
- Assert.assertNull(queueHandles[0].poll(3, TimeUnit.SECONDS));
+ assertNull(queueHandles[0].poll(3, TimeUnit.SECONDS));
}
finally
{
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
index 9b6be7d..cddefd5 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
@@ -19,6 +19,9 @@
package org.apache.curator.framework.recipes.shared;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.curator.framework.CuratorFramework;
@@ -34,8 +37,8 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.WatchedEvent;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
@@ -123,7 +126,7 @@
client.start();
client.checkExists().forPath("/"); // clear initial connect event
- Assert.assertTrue(startLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(startLatch.await(10, TimeUnit.SECONDS));
SharedCount count = new SharedCount(client, "/count", 10);
counts.add(count);
@@ -139,14 +142,14 @@
countList.add(next);
count.setCount(next);
- Assert.assertTrue(semaphore.tryAcquire(CLIENT_QTY, 10, TimeUnit.SECONDS));
+ assertTrue(semaphore.tryAcquire(CLIENT_QTY, 10, TimeUnit.SECONDS));
}
count.setCount(-1);
for ( Future<List<Integer>> future : futures )
{
List<Integer> thisCountList = future.get();
- Assert.assertEquals(thisCountList, countList);
+ assertEquals(thisCountList, countList);
}
}
finally
@@ -189,15 +192,15 @@
};
count.addListener(listener);
- Assert.assertTrue(count.trySetCount(1));
+ assertTrue(count.trySetCount(1));
timing.sleepABit();
- Assert.assertTrue(count.trySetCount(2));
+ assertTrue(count.trySetCount(2));
timing.sleepABit();
- Assert.assertTrue(count.trySetCount(10));
+ assertTrue(count.trySetCount(10));
timing.sleepABit();
- Assert.assertEquals(count.getCount(), 10);
+ assertEquals(count.getCount(), 10);
- Assert.assertTrue(new Timing().awaitLatch(setLatch));
+ assertTrue(new Timing().awaitLatch(setLatch));
}
finally
{
@@ -217,32 +220,32 @@
count.start();
VersionedValue<Integer> current = count.getVersionedValue();
- Assert.assertEquals(current.getVersion(), 0);
+ assertEquals(current.getVersion(), 0);
- Assert.assertTrue(count.trySetCount(current, 1));
+ assertTrue(count.trySetCount(current, 1));
current = count.getVersionedValue();
- Assert.assertEquals(current.getVersion(), 1);
- Assert.assertEquals(count.getCount(), 1);
+ assertEquals(current.getVersion(), 1);
+ assertEquals(count.getCount(), 1);
- Assert.assertTrue(count.trySetCount(current, 5));
+ assertTrue(count.trySetCount(current, 5));
current = count.getVersionedValue();
- Assert.assertEquals(current.getVersion(), 2);
- Assert.assertEquals(count.getCount(), 5);
+ assertEquals(current.getVersion(), 2);
+ assertEquals(count.getCount(), 5);
- Assert.assertTrue(count.trySetCount(current, 10));
+ assertTrue(count.trySetCount(current, 10));
current = count.getVersionedValue();
- Assert.assertEquals(current.getVersion(), 3);
- Assert.assertEquals(count.getCount(), 10);
+ assertEquals(current.getVersion(), 3);
+ assertEquals(count.getCount(), 10);
// Wrong value
- Assert.assertFalse(count.trySetCount(new VersionedValue<Integer>(3, 20), 7));
+ assertFalse(count.trySetCount(new VersionedValue<Integer>(3, 20), 7));
// Wrong version
- Assert.assertFalse(count.trySetCount(new VersionedValue<Integer>(10, 10), 7));
+ assertFalse(count.trySetCount(new VersionedValue<Integer>(10, 10), 7));
// Server changed
client.setData().forPath("/count", SharedCount.toBytes(88));
- Assert.assertFalse(count.trySetCount(current, 234));
+ assertFalse(count.trySetCount(current, 234));
}
finally
{
@@ -267,10 +270,10 @@
count2.start();
VersionedValue<Integer> versionedValue = count1.getVersionedValue();
- Assert.assertTrue(count1.trySetCount(versionedValue, 10));
+ assertTrue(count1.trySetCount(versionedValue, 10));
timing.sleepABit();
versionedValue = count2.getVersionedValue();
- Assert.assertTrue(count2.trySetCount(versionedValue, 20));
+ assertTrue(count2.trySetCount(versionedValue, 20));
timing.sleepABit();
final CountDownLatch setLatch = new CountDownLatch(2);
@@ -291,12 +294,12 @@
count1.addListener(listener);
VersionedValue<Integer> versionedValue1 = count1.getVersionedValue();
VersionedValue<Integer> versionedValue2 = count2.getVersionedValue();
- Assert.assertTrue(count2.trySetCount(versionedValue2, 30));
- Assert.assertFalse(count1.trySetCount(versionedValue1, 40));
+ assertTrue(count2.trySetCount(versionedValue2, 30));
+ assertFalse(count1.trySetCount(versionedValue1, 40));
versionedValue1 = count1.getVersionedValue();
- Assert.assertTrue(count1.trySetCount(versionedValue1, 40));
- Assert.assertTrue(timing.awaitLatch(setLatch));
+ assertTrue(count1.trySetCount(versionedValue1, 40));
+ assertTrue(timing.awaitLatch(setLatch));
}
finally
{
@@ -322,8 +325,8 @@
count1.start();
count2.start();
- Assert.assertEquals(count1.getCount(), 10);
- Assert.assertEquals(count2.getCount(), 10);
+ assertEquals(count1.getCount(), 10);
+ assertEquals(count2.getCount(), 10);
}
finally
{
@@ -360,7 +363,7 @@
{
server.stop();
// if watcher goes into 10second retry loop we won't get timely notification
- Assert.assertTrue(gotSuspendEvent.await(5, TimeUnit.SECONDS));
+ assertTrue(gotSuspendEvent.await(5, TimeUnit.SECONDS));
}
finally
{
@@ -405,14 +408,14 @@
try
{
sharedCount.setCount(11);
- Assert.assertTrue(gotChangeEvent.await(2, TimeUnit.SECONDS));
+ assertTrue(gotChangeEvent.await(2, TimeUnit.SECONDS));
server.stop();
- Assert.assertTrue(gotSuspendEvent.await(2, TimeUnit.SECONDS));
+ assertTrue(gotSuspendEvent.await(2, TimeUnit.SECONDS));
server.restart();
- Assert.assertTrue(getReconnectEvent.await(2, TimeUnit.SECONDS));
- Assert.assertEquals(numChangeEvents.get(), 1);
+ assertTrue(getReconnectEvent.await(2, TimeUnit.SECONDS));
+ assertEquals(numChangeEvents.get(), 1);
sharedCount.trySetCount(sharedCount.getVersionedValue(), 12);
@@ -428,7 +431,7 @@
// CURATOR-311: when a Curator client's state became RECONNECTED, countHasChanged method is called back
// because the Curator client calls readValueAndNotifyListenersInBackground in SharedValue#ConnectionStateListener#stateChanged.
- Assert.assertTrue(numChangeEvents.get() > 2);
+ assertTrue(numChangeEvents.get() > 2);
}
finally
{
@@ -489,24 +492,24 @@
try
{
sharedCount1.setCount(12);
- Assert.assertEquals(listener1.gotChangeEvent.awaitAdvanceInterruptibly(0, timing.seconds(), TimeUnit.SECONDS), 1);
- Assert.assertEquals(sharedCount1.getCount(), 12);
+ assertEquals(listener1.gotChangeEvent.awaitAdvanceInterruptibly(0, timing.seconds(), TimeUnit.SECONDS), 1);
+ assertEquals(sharedCount1.getCount(), 12);
- Assert.assertEquals(sharedCountWithFaultyWatcher.getCount(), 10);
+ assertEquals(sharedCountWithFaultyWatcher.getCount(), 10);
// new counter with faultyWatcher start
sharedCountWithFaultyWatcher.start();
for (int i = 0; i < 10; i++) {
sharedCount1.setCount(13 + i);
- Assert.assertEquals(sharedCount1.getCount(), 13 + i);
+ assertEquals(sharedCount1.getCount(), 13 + i);
server.restart();
- Assert.assertEquals(listener2.getReconnectEvent.awaitAdvanceInterruptibly(i, timing.forWaiting().seconds(), TimeUnit.SECONDS), i + 1);
+ assertEquals(listener2.getReconnectEvent.awaitAdvanceInterruptibly(i, timing.forWaiting().seconds(), TimeUnit.SECONDS), i + 1);
// CURATOR-311 introduces to Curator's client reading server's shared count value
// when client's state gets ConnectionState.RECONNECTED. Following tests ensures that.
- Assert.assertEquals(listener2.gotChangeEvent.awaitAdvanceInterruptibly(i, timing.forWaiting().seconds(), TimeUnit.SECONDS), i + 1);
- Assert.assertEquals(sharedCountWithFaultyWatcher.getCount(), 13 + i);
+ assertEquals(listener2.gotChangeEvent.awaitAdvanceInterruptibly(i, timing.forWaiting().seconds(), TimeUnit.SECONDS), i + 1);
+ assertEquals(sharedCountWithFaultyWatcher.getCount(), 13 + i);
}
}
finally
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestPersistentWatcher.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestPersistentWatcher.java
index 1cf7eb0..d21f2be 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestPersistentWatcher.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestPersistentWatcher.java
@@ -19,6 +19,9 @@
package org.apache.curator.framework.recipes.watch;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.state.ConnectionState;
@@ -26,13 +29,14 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
-@Test(groups = CuratorTestBase.zk36Group)
+@Tag(CuratorTestBase.zk36Group)
public class TestPersistentWatcher extends CuratorTestBase
{
@Test
@@ -73,22 +77,22 @@
persistentWatcher.getListenable().addListener(events::add);
client.create().creatingParentsIfNeeded().forPath("/top/main/a");
- Assert.assertEquals(timing.takeFromQueue(events).getPath(), "/top/main");
+ assertEquals(timing.takeFromQueue(events).getPath(), "/top/main");
if ( recursive )
{
- Assert.assertEquals(timing.takeFromQueue(events).getPath(), "/top/main/a");
+ assertEquals(timing.takeFromQueue(events).getPath(), "/top/main/a");
}
else
{
- Assert.assertEquals(timing.takeFromQueue(events).getPath(), "/top/main"); // child added
+ assertEquals(timing.takeFromQueue(events).getPath(), "/top/main"); // child added
}
server.stop();
- Assert.assertEquals(timing.takeFromQueue(events).getState(), Watcher.Event.KeeperState.Disconnected);
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertEquals(timing.takeFromQueue(events).getState(), Watcher.Event.KeeperState.Disconnected);
+ assertTrue(timing.awaitLatch(lostLatch));
server.restart();
- Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+ assertTrue(timing.awaitLatch(reconnectedLatch));
timing.sleepABit(); // time to allow watcher to get reset
events.clear();
@@ -96,10 +100,10 @@
if ( recursive )
{
client.setData().forPath("/top/main/a", "foo".getBytes());
- Assert.assertEquals(timing.takeFromQueue(events).getType(), Watcher.Event.EventType.NodeDataChanged);
+ assertEquals(timing.takeFromQueue(events).getType(), Watcher.Event.EventType.NodeDataChanged);
}
client.setData().forPath("/top/main", "bar".getBytes());
- Assert.assertEquals(timing.takeFromQueue(events).getPath(), "/top/main");
+ assertEquals(timing.takeFromQueue(events).getPath(), "/top/main");
}
}
}
diff --git a/curator-test-zk35/pom.xml b/curator-test-zk35/pom.xml
index 5e683b5..2abfe90 100644
--- a/curator-test-zk35/pom.xml
+++ b/curator-test-zk35/pom.xml
@@ -131,8 +131,33 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-math</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-yaml</artifactId>
+ <version>${jackson-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
diff --git a/curator-test-zk35/src/test/java/org/apache/curator/framework/TestCompatibility.java b/curator-test-zk35/src/test/java/org/apache/curator/framework/TestCompatibility.java
index 5112d41..89f2d29 100644
--- a/curator-test-zk35/src/test/java/org/apache/curator/framework/TestCompatibility.java
+++ b/curator-test-zk35/src/test/java/org/apache/curator/framework/TestCompatibility.java
@@ -18,32 +18,36 @@
*/
package org.apache.curator.framework;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.x.async.AsyncCuratorFramework;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class TestCompatibility extends CuratorTestBase
{
- @Test(expectedExceptions = IllegalStateException.class)
- public void testPersistentWatchesNotAvailable() throws Exception
+ @Test
+ public void testPersistentWatchesNotAvailable()
{
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
- client.watchers().add().forPath("/foo");
- }
+ assertThrows(IllegalStateException.class, ()-> {
+ try (CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1))) {
+ client.start();
+ client.watchers().add().forPath("/foo");
+ }
+ });
}
- @Test(expectedExceptions = IllegalStateException.class)
+ @Test
public void testPersistentWatchesNotAvailableAsync()
{
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
+ assertThrows(IllegalStateException.class, ()->{
+ try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
+ {
+ client.start();
- AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
- async.addWatch().forPath("/foo");
- }
+ AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
+ async.addWatch().forPath("/foo");
+ }
+ });
}
}
diff --git a/curator-test-zk35/src/test/java/org/apache/curator/zk35/TestIs35.java b/curator-test-zk35/src/test/java/org/apache/curator/zk35/TestIs35.java
index 4292bd0..53bcf1b 100644
--- a/curator-test-zk35/src/test/java/org/apache/curator/zk35/TestIs35.java
+++ b/curator-test-zk35/src/test/java/org/apache/curator/zk35/TestIs35.java
@@ -18,18 +18,19 @@
*/
package org.apache.curator.zk35;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.curator.utils.Compatibility;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class TestIs35
{
@Test
public void testIsZk35()
{
- Assert.assertFalse(Compatibility.hasGetReachableOrOneMethod());
- Assert.assertTrue(Compatibility.hasAddrField());
- Assert.assertFalse(Compatibility.hasPersistentWatchers());
+ assertFalse(Compatibility.hasGetReachableOrOneMethod());
+ assertTrue(Compatibility.hasAddrField());
+ assertFalse(Compatibility.hasPersistentWatchers());
}
}
diff --git a/curator-test/pom.xml b/curator-test/pom.xml
index b1d9500..6547998 100644
--- a/curator-test/pom.xml
+++ b/curator-test/pom.xml
@@ -56,12 +56,11 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>provided</scope>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
@@ -107,6 +106,16 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <threadCount>1</threadCount>
+ <reuseForks>false</reuseForks>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java b/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java
index eb568e9..1ed3500 100644
--- a/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java
+++ b/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java
@@ -19,15 +19,10 @@
package org.apache.curator.test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.IInvokedMethod;
-import org.testng.IInvokedMethodListener2;
-import org.testng.ITestContext;
-import org.testng.ITestResult;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeSuite;
import java.io.IOException;
import java.net.BindException;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -81,39 +76,7 @@
INTERNAL_PROPERTY_VALIDATE_NAMESPACE_WATCHER_MAP_EMPTY = s;
}
- @BeforeSuite(alwaysRun = true)
- public void beforeSuite(ITestContext context)
- {
- IInvokedMethodListener2 methodListener2 = new IInvokedMethodListener2()
- {
- @Override
- public void beforeInvocation(IInvokedMethod method, ITestResult testResult)
- {
- method.getTestMethod().setRetryAnalyzer(BaseClassForTests.this::retry);
- }
-
- @Override
- public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context)
- {
- beforeInvocation(method, testResult);
- }
-
- @Override
- public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context)
- {
- // NOP
- }
-
- @Override
- public void afterInvocation(IInvokedMethod method, ITestResult testResult)
- {
- // NOP
- }
- };
- context.getSuite().addListener(methodListener2);
- }
-
- @BeforeMethod(alwaysRun = true)
+ @BeforeEach
public void setup() throws Exception
{
if ( INTERNAL_PROPERTY_DONT_LOG_CONNECTION_ISSUES != null )
@@ -177,7 +140,7 @@
}
}
- @AfterMethod(alwaysRun = true)
+ @AfterEach
public void teardown() throws Exception
{
System.clearProperty(INTERNAL_PROPERTY_VALIDATE_NAMESPACE_WATCHER_MAP_EMPTY);
@@ -203,25 +166,4 @@
}
}
}
-
- private boolean retry(ITestResult result)
- {
- if ( result.isSuccess() || isRetrying.get() )
- {
- isRetrying.set(false);
- return false;
- }
-
- result.setStatus(ITestResult.SKIP);
- if ( result.getThrowable() != null )
- {
- log.error("Retrying 1 time", result.getThrowable());
- }
- else
- {
- log.error("Retrying 1 time");
- }
- isRetrying.set(true);
- return true;
- }
}
diff --git a/curator-test/src/test/java/org/apache/curator/test/TestQuorumConfigBuilder.java b/curator-test/src/test/java/org/apache/curator/test/TestQuorumConfigBuilder.java
index cfb89c5..3737f82 100644
--- a/curator-test/src/test/java/org/apache/curator/test/TestQuorumConfigBuilder.java
+++ b/curator-test/src/test/java/org/apache/curator/test/TestQuorumConfigBuilder.java
@@ -20,10 +20,10 @@
package org.apache.curator.test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
-import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
/**
* Test QuorumConfigBuilder
diff --git a/curator-x-async/pom.xml b/curator-x-async/pom.xml
index 2d6527e..3571438 100644
--- a/curator-x-async/pom.xml
+++ b/curator-x-async/pom.xml
@@ -38,8 +38,8 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
diff --git a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestAddWatch.java b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestAddWatch.java
index bdf006a..5a93431 100644
--- a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestAddWatch.java
+++ b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestAddWatch.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
@@ -27,8 +29,8 @@
import org.apache.zookeeper.AddWatchMode;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
public class TestAddWatch extends CuratorTestBase
@@ -52,7 +54,7 @@
client.create().forPath("/test/a/b/c");
client.create().forPath("/test/a/b/c/d");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
}
@@ -81,7 +83,7 @@
client.create().forPath("/test/a/b/c");
client.create().forPath("/test/a/b/c/d");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
}
}
diff --git a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java
index 395c4fd..d03ffca 100644
--- a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java
+++ b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java
@@ -18,6 +18,12 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Lists;
import org.apache.curator.framework.AuthInfo;
import org.apache.curator.framework.CuratorFramework;
@@ -41,10 +47,10 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
@@ -59,7 +65,7 @@
@SuppressWarnings("deprecation")
public class TestFramework extends BaseClassForTests
{
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -67,7 +73,7 @@
super.setup();
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -101,8 +107,8 @@
});
Integer code = rc.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.assertNotNull(code);
- Assert.assertEquals(code.intValue(), KeeperException.Code.OK.intValue());
+ assertNotNull(code);
+ assertEquals(code.intValue(), KeeperException.Code.OK.intValue());
}
finally
{
@@ -135,7 +141,7 @@
.thenRun(() -> async.create().forPath("/base/child"));
String path = queue.take();
- Assert.assertEquals(path, "/base");
+ assertEquals(path, "/base");
}
finally
{
@@ -174,7 +180,7 @@
}
catch ( ExecutionException e )
{
- Assert.fail("Auth failed");
+ fail("Auth failed");
}
client.close();
@@ -189,7 +195,7 @@
{
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.setData().forPath("/test", "test".getBytes()).toCompletableFuture().get();
- Assert.fail("Should have failed with auth exception");
+ fail("Should have failed with auth exception");
}
catch ( ExecutionException e )
{
@@ -238,7 +244,7 @@
}
catch ( ExecutionException e )
{
- Assert.fail("Auth failed");
+ fail("Auth failed");
}
client.close();
@@ -256,7 +262,7 @@
}
catch ( ExecutionException e )
{
- Assert.fail("Auth failed");
+ fail("Auth failed");
}
client.close();
@@ -271,7 +277,7 @@
{
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.setData().forPath("/test", "test".getBytes()).toCompletableFuture().get();
- Assert.fail("Should have failed with auth exception");
+ fail("Should have failed with auth exception");
}
catch ( ExecutionException e )
{
@@ -314,12 +320,12 @@
client.create().withACL(aclList).forPath("/test", "test".getBytes());
server.stop();
- Assert.assertTrue(timing.awaitLatch(lostLatch));
+ assertTrue(timing.awaitLatch(lostLatch));
try
{
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.checkExists().forPath("/").toCompletableFuture().get();
- Assert.fail("Connection should be down");
+ fail("Connection should be down");
}
catch ( ExecutionException e )
{
@@ -334,7 +340,7 @@
}
catch ( ExecutionException e )
{
- Assert.fail("Auth failed", e);
+ fail("Auth failed", e);
}
}
finally
@@ -354,11 +360,11 @@
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.create().withOptions(EnumSet.of(CreateOption.createParentsIfNeeded)).forPath("/one/two/three", "foo".getBytes()).toCompletableFuture().get();
byte[] data = async.getData().forPath("/one/two/three").toCompletableFuture().get();
- Assert.assertEquals(data, "foo".getBytes());
+ assertArrayEquals(data, "foo".getBytes());
async.create().withOptions(EnumSet.of(CreateOption.createParentsIfNeeded)).forPath("/one/two/another", "bar".getBytes());
data = async.getData().forPath("/one/two/another").toCompletableFuture().get();
- Assert.assertEquals(data, "bar".getBytes());
+ assertArrayEquals(data, "bar".getBytes());
}
finally
{
@@ -382,14 +388,14 @@
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.create().withOptions(EnumSet.of(CreateOption.createParentsAsContainers)).forPath("/one/two/three", "foo".getBytes()).toCompletableFuture().get();
byte[] data = async.getData().forPath("/one/two/three").toCompletableFuture().get();
- Assert.assertEquals(data, "foo".getBytes());
+ assertArrayEquals(data, "foo".getBytes());
async.delete().forPath("/one/two/three").toCompletableFuture().get();
new Timing().sleepABit();
- Assert.assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
new Timing().sleepABit();
- Assert.assertNull(async.checkExists().forPath("/one").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one").toCompletableFuture().get());
}
finally
{
@@ -408,8 +414,8 @@
String path = async.create().withOptions(Collections.singleton(CreateOption.doProtected)).forPath("/yo").toCompletableFuture().get();
String node = ZKPaths.getNodeFromPath(path);
// CURATOR-489: confirm that the node contains a valid UUID, eg '_c_53345f98-9423-4e0c-a7b5-9f819e3ec2e1-yo'
- Assert.assertTrue(ProtectedUtils.isProtectedZNode(node));
- Assert.assertEquals(ProtectedUtils.normalize(node), "yo");
+ assertTrue(ProtectedUtils.isProtectedZNode(node));
+ assertEquals(ProtectedUtils.normalize(node), "yo");
}
finally
{
@@ -436,17 +442,17 @@
client.start();
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertNull(client.checkExists().forPath("/one/two"));
async.create().withOptions(EnumSet.of(CreateOption.createParentsAsContainers)).forPath("/one/two/three").toCompletableFuture().get();
- Assert.assertNotNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
+ assertNotNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
async.delete().withOptions(EnumSet.of(DeleteOption.deletingChildrenIfNeeded)).forPath("/one").toCompletableFuture().get();
- Assert.assertNull(client.checkExists().forPath("/one"));
+ assertNull(client.checkExists().forPath("/one"));
- Assert.assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
async.checkExists().withOptions(EnumSet.of(ExistsOption.createParentsAsContainers)).forPath("/one/two/three").toCompletableFuture().get();
- Assert.assertNotNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
- Assert.assertNull(async.checkExists().forPath("/one/two/three").toCompletableFuture().get());
+ assertNotNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one/two/three").toCompletableFuture().get());
}
finally
{
@@ -463,11 +469,11 @@
client.start();
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
- Assert.assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
async.checkExists().withOptions(EnumSet.of(ExistsOption.createParentsAsContainers)).forPath("/one/two/three").toCompletableFuture().get();
- Assert.assertNotNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
- Assert.assertNull(async.checkExists().forPath("/one/two/three").toCompletableFuture().get());
- Assert.assertNull(async.checkExists().withOptions(EnumSet.of(ExistsOption.createParentsAsContainers)).forPath("/one/two/three").toCompletableFuture().get());
+ assertNotNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one/two/three").toCompletableFuture().get());
+ assertNull(async.checkExists().withOptions(EnumSet.of(ExistsOption.createParentsAsContainers)).forPath("/one/two/three").toCompletableFuture().get());
}
finally
{
@@ -483,17 +489,17 @@
try
{
client.create().forPath("/head");
- Assert.assertNotNull(client.checkExists().forPath("/head"));
+ assertNotNull(client.checkExists().forPath("/head"));
final CountDownLatch latch = new CountDownLatch(1);
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.sync().forPath("/head").handle((v, e) -> {
- Assert.assertNull(v);
- Assert.assertNull(e);
+ assertNull(v);
+ assertNull(e);
latch.countDown();
return null;
});
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
}
finally
{
@@ -512,14 +518,14 @@
CountDownLatch latch = new CountDownLatch(1);
async.create().forPath("/head").thenRun(() ->
async.delete().forPath("/head").handle((v, e) -> {
- Assert.assertNull(v);
- Assert.assertNull(e);
+ assertNull(v);
+ assertNull(e);
latch.countDown();
return null;
})
);
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
- Assert.assertNull(client.checkExists().forPath("/head"));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertNull(client.checkExists().forPath("/head"));
}
finally
{
@@ -539,7 +545,7 @@
{
if ( event.getType() == CuratorEventType.DELETE )
{
- Assert.assertEquals(event.getPath(), "/one/two");
+ assertEquals(event.getPath(), "/one/two");
((CountDownLatch)event.getContext()).countDown();
}
});
@@ -548,14 +554,14 @@
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.create().withOptions(EnumSet.of(CreateOption.createParentsIfNeeded)).forPath("/one/two/three/four").thenRun(() ->
async.delete().withOptions(EnumSet.of(DeleteOption.deletingChildrenIfNeeded)).forPath("/one/two").handle((v, e) -> {
- Assert.assertNull(v);
- Assert.assertNull(e);
+ assertNull(v);
+ assertNull(e);
latch.countDown();
return null;
})
);
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
- Assert.assertNull(client.checkExists().forPath("/one/two"));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertNull(client.checkExists().forPath("/one/two"));
}
finally
{
@@ -574,9 +580,9 @@
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
async.create().withOptions(EnumSet.of(CreateOption.createParentsIfNeeded)).forPath("/one/two/three/four/five/six", "foo".getBytes()).toCompletableFuture().get();
async.delete().withOptions(EnumSet.of(DeleteOption.guaranteed, DeleteOption.deletingChildrenIfNeeded)).forPath("/one/two/three/four/five").toCompletableFuture().get();
- Assert.assertNull(async.checkExists().forPath("/one/two/three/four/five").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one/two/three/four/five").toCompletableFuture().get());
async.delete().withOptions(EnumSet.of(DeleteOption.guaranteed, DeleteOption.deletingChildrenIfNeeded)).forPath("/one/two").toCompletableFuture().get();
- Assert.assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
+ assertNull(async.checkExists().forPath("/one/two").toCompletableFuture().get());
}
finally
{
@@ -600,9 +606,9 @@
}
});
- Assert.assertTrue(new Timing().acquireSemaphore(semaphore, 10));
+ assertTrue(new Timing().acquireSemaphore(semaphore, 10));
List<String> children = async.getChildren().forPath("/head").toCompletableFuture().get();
- Assert.assertEquals(children.size(), 10);
+ assertEquals(children.size(), 10);
}
finally
{
@@ -627,22 +633,22 @@
CountDownLatch backgroundLatch = new CountDownLatch(1);
AsyncStage<byte[]> stage = async.watched().getData().forPath("/test");
stage.event().handle((event, x) -> {
- Assert.assertEquals(event.getPath(), "/test");
+ assertEquals(event.getPath(), "/test");
watchedLatch.countDown();
return null;
});
stage.handle((d, x) -> {
- Assert.assertEquals(d, data1);
+ assertArrayEquals(d, data1);
backgroundLatch.countDown();
return null;
});
- Assert.assertTrue(backgroundLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(backgroundLatch.await(10, TimeUnit.SECONDS));
async.setData().forPath("/test", data2);
- Assert.assertTrue(watchedLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(watchedLatch.await(10, TimeUnit.SECONDS));
byte[] checkData = async.getData().forPath("/test").toCompletableFuture().get();
- Assert.assertEquals(checkData, data2);
+ assertArrayEquals(checkData, data2);
}
finally
{
diff --git a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java
index c00febd..c5bdf7c 100644
--- a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java
+++ b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java
@@ -18,6 +18,9 @@
*/
package org.apache.curator.framework.imps;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -33,10 +36,9 @@
import org.apache.curator.x.async.AsyncCuratorFramework;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.ACL;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -102,7 +104,7 @@
}
};
async.with(listener).create().forPath("/foo");
- Assert.assertTrue(new Timing().awaitLatch(errorLatch));
+ assertTrue(new Timing().awaitLatch(errorLatch));
}
finally
{
@@ -144,10 +146,10 @@
server.restart();
- Assert.assertTrue(timing.awaitLatch(connectedLatch));
- Assert.assertFalse(firstListenerAction.get());
+ assertTrue(timing.awaitLatch(connectedLatch));
+ assertFalse(firstListenerAction.get());
ConnectionState firstconnectionState = firstListenerState.get();
- Assert.assertEquals(firstconnectionState, ConnectionState.CONNECTED, "First listener state MUST BE CONNECTED but is " + firstconnectionState);
+ assertEquals(firstconnectionState, ConnectionState.CONNECTED, "First listener state MUST BE CONNECTED but is " + firstconnectionState);
}
finally
{
@@ -190,7 +192,7 @@
for ( long elapsed : times.subList(1, times.size()) ) // first one isn't a retry
{
- Assert.assertTrue(elapsed >= SLEEP, elapsed + ": " + times);
+ assertTrue(elapsed >= SLEEP, elapsed + ": " + times);
}
}
finally
@@ -223,7 +225,7 @@
return null;
});
// Check if the callback has been called with a correct return code
- Assert.assertTrue(timing.awaitLatch(latch), "Callback has not been called by curator !");
+ assertTrue(timing.awaitLatch(latch), "Callback has not been called by curator !");
}
}
@@ -280,7 +282,7 @@
timing.sleepABit();
// should not generate an exception
- Assert.assertFalse(hadIllegalStateException.get());
+ assertFalse(hadIllegalStateException.get());
}
finally
{
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java b/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java
index ae0df3b..1b587fb 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java
@@ -18,10 +18,10 @@
*/
package org.apache.curator.x.async;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.base.Throwables;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.compatibility.Timing2;
-import org.testng.Assert;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -61,11 +61,11 @@
{
throw (AssertionError)e.getCause();
}
- Assert.fail("get() failed", e);
+ fail("get() failed", e);
}
catch ( TimeoutException e )
{
- Assert.fail("get() timed out");
+ fail("get() timed out");
}
}
}
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/TestAsyncWrappers.java b/curator-x-async/src/test/java/org/apache/curator/x/async/TestAsyncWrappers.java
index 7ce7904..e720cba 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/TestAsyncWrappers.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/TestAsyncWrappers.java
@@ -18,12 +18,15 @@
*/
package org.apache.curator.x.async;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.curator.retry.RetryOneTime;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -38,7 +41,7 @@
InterProcessMutex lock = new InterProcessMutex(client, "/one/two");
complete(AsyncWrappers.lockAsync(lock), (__, e) -> {
- Assert.assertNull(e);
+ assertNull(e);
AsyncWrappers.release(lock);
});
}
@@ -57,7 +60,7 @@
AsyncWrappers.lockAsync(lock1).thenAccept(__ -> {
latch.countDown(); // don't release the lock
});
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
CountDownLatch latch2 = new CountDownLatch(1);
AsyncWrappers.lockAsync(lock2, timing.forSleepingABit().milliseconds(), TimeUnit.MILLISECONDS).exceptionally(e -> {
@@ -67,7 +70,7 @@
}
return null;
});
- Assert.assertTrue(timing.awaitLatch(latch2));
+ assertTrue(timing.awaitLatch(latch2));
}
}
}
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java b/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java
index f814146..3e3adb2 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java
@@ -18,6 +18,17 @@
*/
package org.apache.curator.x.async;
+import static java.util.EnumSet.of;
+import static org.apache.curator.x.async.api.CreateOption.compress;
+import static org.apache.curator.x.async.api.CreateOption.setDataIfExists;
+import static org.apache.zookeeper.CreateMode.EPHEMERAL_SEQUENTIAL;
+import static org.apache.zookeeper.CreateMode.PERSISTENT_SEQUENTIAL;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.transaction.CuratorOp;
@@ -26,26 +37,20 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.data.Stat;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.CountDownLatch;
-import static java.util.EnumSet.of;
-import static org.apache.curator.x.async.api.CreateOption.compress;
-import static org.apache.curator.x.async.api.CreateOption.setDataIfExists;
-import static org.apache.zookeeper.CreateMode.EPHEMERAL_SEQUENTIAL;
-import static org.apache.zookeeper.CreateMode.PERSISTENT_SEQUENTIAL;
-
public class TestBasicOperations extends CompletableBaseClassForTests
{
private AsyncCuratorFramework client;
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -56,7 +61,7 @@
this.client = AsyncCuratorFramework.wrap(client);
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -74,29 +79,29 @@
CuratorOp op2 = client.transactionOp().create().withMode(PERSISTENT_SEQUENTIAL).forPath("/test/node-");
complete(client.transaction().forOperations(Arrays.asList(op1, op2)));
- Assert.assertEquals(client.unwrap().getChildren().forPath("/test").size(), 2);
+ assertEquals(client.unwrap().getChildren().forPath("/test").size(), 2);
}
@Test
public void testCrud()
{
AsyncStage<String> createStage = client.create().forPath("/test", "one".getBytes());
- complete(createStage, (path, e) -> Assert.assertEquals(path, "/test"));
+ complete(createStage, (path, e) -> assertEquals(path, "/test"));
AsyncStage<byte[]> getStage = client.getData().forPath("/test");
- complete(getStage, (data, e) -> Assert.assertEquals(data, "one".getBytes()));
+ complete(getStage, (data, e) -> assertArrayEquals(data, "one".getBytes()));
CompletionStage<byte[]> combinedStage = client.setData().forPath("/test", "new".getBytes()).thenCompose(
__ -> client.getData().forPath("/test"));
- complete(combinedStage, (data, e) -> Assert.assertEquals(data, "new".getBytes()));
+ complete(combinedStage, (data, e) -> assertArrayEquals(data, "new".getBytes()));
CompletionStage<Void> combinedDelete = client.create().withMode(EPHEMERAL_SEQUENTIAL).forPath("/deleteme").thenCompose(
path -> client.delete().forPath(path));
- complete(combinedDelete, (v, e) -> Assert.assertNull(e));
+ complete(combinedDelete, (v, e) -> assertNull(e));
CompletionStage<byte[]> setDataIfStage = client.create().withOptions(of(compress, setDataIfExists)).forPath("/test", "last".getBytes())
.thenCompose(__ -> client.getData().decompressed().forPath("/test"));
- complete(setDataIfStage, (data, e) -> Assert.assertEquals(data, "last".getBytes()));
+ complete(setDataIfStage, (data, e) -> assertArrayEquals(data, "last".getBytes()));
}
@Test
@@ -104,12 +109,12 @@
{
CountDownLatch latch = new CountDownLatch(1);
client.getData().forPath("/woop").exceptionally(e -> {
- Assert.assertTrue(e instanceof KeeperException);
- Assert.assertEquals(((KeeperException)e).code(), KeeperException.Code.NONODE);
+ assertTrue(e instanceof KeeperException);
+ assertEquals(((KeeperException)e).code(), KeeperException.Code.NONODE);
latch.countDown();
return null;
});
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
@Test
@@ -117,12 +122,12 @@
{
CountDownLatch latch = new CountDownLatch(1);
client.watched().checkExists().forPath("/test").event().whenComplete((event, exception) -> {
- Assert.assertNull(exception);
- Assert.assertEquals(event.getType(), Watcher.Event.EventType.NodeCreated);
+ assertNull(exception);
+ assertEquals(event.getType(), Watcher.Event.EventType.NodeCreated);
latch.countDown();
});
client.create().forPath("/test");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
@Test
@@ -142,14 +147,14 @@
CountDownLatch latch = new CountDownLatch(1);
complete(stage.event(), (v, e) -> {
- Assert.assertTrue(e instanceof AsyncEventException);
- Assert.assertEquals(((AsyncEventException)e).getKeeperState(), Watcher.Event.KeeperState.Disconnected);
+ assertTrue(e instanceof AsyncEventException);
+ assertEquals(((AsyncEventException)e).getKeeperState(), Watcher.Event.KeeperState.Disconnected);
((AsyncEventException)e).reset().thenRun(latch::countDown);
});
server.restart();
client.create().forPath("/test");
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
@Test
@@ -157,36 +162,36 @@
{
CompletionStage<AsyncResult<String>> resultStage = AsyncResult.of(client.create().forPath("/first"));
complete(resultStage, (v, e) -> {
- Assert.assertNull(e);
- Assert.assertEquals(v.getRawValue(), "/first");
- Assert.assertNull(v.getRawException());
- Assert.assertEquals(v.getCode(), KeeperException.Code.OK);
+ assertNull(e);
+ assertEquals(v.getRawValue(), "/first");
+ assertNull(v.getRawException());
+ assertEquals(v.getCode(), KeeperException.Code.OK);
});
resultStage = AsyncResult.of(client.create().forPath("/foo/bar"));
complete(resultStage, (v, e) -> {
- Assert.assertNull(e);
- Assert.assertNull(v.getRawValue());
- Assert.assertNull(v.getRawException());
- Assert.assertEquals(v.getCode(), KeeperException.Code.NONODE);
+ assertNull(e);
+ assertNull(v.getRawValue());
+ assertNull(v.getRawException());
+ assertEquals(v.getCode(), KeeperException.Code.NONODE);
});
resultStage = AsyncResult.of(client.create().forPath("illegal path"));
complete(resultStage, (v, e) -> {
- Assert.assertNull(e);
- Assert.assertNull(v.getRawValue());
- Assert.assertNotNull(v.getRawException());
- Assert.assertTrue(v.getRawException() instanceof IllegalArgumentException);
- Assert.assertEquals(v.getCode(), KeeperException.Code.SYSTEMERROR);
+ assertNull(e);
+ assertNull(v.getRawValue());
+ assertNotNull(v.getRawException());
+ assertTrue(v.getRawException() instanceof IllegalArgumentException);
+ assertEquals(v.getCode(), KeeperException.Code.SYSTEMERROR);
});
server.stop();
resultStage = AsyncResult.of(client.create().forPath("/second"));
complete(resultStage, (v, e) -> {
- Assert.assertNull(e);
- Assert.assertNull(v.getRawValue());
- Assert.assertNull(v.getRawException());
- Assert.assertEquals(v.getCode(), KeeperException.Code.CONNECTIONLOSS);
+ assertNull(e);
+ assertNull(v.getRawValue());
+ assertNull(v.getRawException());
+ assertEquals(v.getCode(), KeeperException.Code.CONNECTIONLOSS);
});
}
@@ -197,6 +202,6 @@
Stat stat = new Stat();
complete(client.getData().storingStatIn(stat).forPath("/test"));
- Assert.assertEquals(stat.getDataLength(), "hey".length());
+ assertEquals(stat.getDataLength(), "hey".length());
}
}
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java b/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
index 6cc7fd1..00ef28b 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
@@ -18,6 +18,12 @@
*/
package org.apache.curator.x.async.migrations;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.base.Throwables;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -35,10 +41,10 @@
import org.apache.curator.x.async.modeled.ModeledFramework;
import org.apache.curator.x.async.modeled.ZPath;
import org.apache.zookeeper.KeeperException;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
@@ -69,7 +75,7 @@
private final AtomicReference<CountDownLatch> filterLatch = new AtomicReference<>();
private CountDownLatch filterIsSetLatch;
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -119,7 +125,7 @@
manager.debugCount = new AtomicInteger();
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
@@ -140,14 +146,14 @@
ModeledFramework<ModelV3> v3Client = ModeledFramework.wrap(client, v3Spec);
complete(v3Client.read(), (m, e) -> {
- Assert.assertEquals(m.getAge(), 30);
- Assert.assertEquals(m.getFirstName(), "One");
- Assert.assertEquals(m.getLastName(), "Two");
+ assertEquals(m.getAge(), 30);
+ assertEquals(m.getFirstName(), "One");
+ assertEquals(m.getLastName(), "Two");
});
int count = manager.debugCount.get();
complete(manager.migrate(migrationSet));
- Assert.assertEquals(manager.debugCount.get(), count); // second call should do nothing
+ assertEquals(manager.debugCount.get(), count); // second call should do nothing
}
@Test
@@ -158,7 +164,7 @@
complete(manager.migrate(migrationSet));
ModeledFramework<ModelV1> v1Client = ModeledFramework.wrap(client, v1Spec);
- complete(v1Client.read(), (m, e) -> Assert.assertEquals(m.getName(), "Test"));
+ complete(v1Client.read(), (m, e) -> assertEquals(m.getName(), "Test"));
Migration m2 = () -> Collections.singletonList(v2op);
migrationSet = MigrationSet.build("1", Arrays.asList(m1, m2));
@@ -166,8 +172,8 @@
ModeledFramework<ModelV2> v2Client = ModeledFramework.wrap(client, v2Spec);
complete(v2Client.read(), (m, e) -> {
- Assert.assertEquals(m.getName(), "Test 2");
- Assert.assertEquals(m.getAge(), 10);
+ assertEquals(m.getName(), "Test 2");
+ assertEquals(m.getAge(), 10);
});
Migration m3 = () -> Collections.singletonList(v3op);
@@ -176,9 +182,9 @@
ModeledFramework<ModelV3> v3Client = ModeledFramework.wrap(client, v3Spec);
complete(v3Client.read(), (m, e) -> {
- Assert.assertEquals(m.getAge(), 30);
- Assert.assertEquals(m.getFirstName(), "One");
- Assert.assertEquals(m.getLastName(), "Two");
+ assertEquals(m.getAge(), 30);
+ assertEquals(m.getFirstName(), "One");
+ assertEquals(m.getLastName(), "Two");
});
}
@@ -195,8 +201,8 @@
MigrationSet migrationSet = MigrationSet.build("main", Collections.singletonList(initialMigration));
complete(manager.migrate(migrationSet));
- Assert.assertNotNull(client.unwrap().checkExists().forPath("/parent/three"));
- Assert.assertEquals(client.unwrap().getData().forPath("/main"), "hey".getBytes());
+ assertNotNull(client.unwrap().checkExists().forPath("/parent/three"));
+ assertArrayEquals(client.unwrap().getData().forPath("/main"), "hey".getBytes());
CuratorOp newOp1 = client.transactionOp().create().forPath("/new");
CuratorOp newOp2 = client.transactionOp().delete().forPath("/main"); // maybe this is no longer needed
@@ -205,7 +211,7 @@
migrationSet = MigrationSet.build("main", Arrays.asList(initialMigration, newMigration));
complete(manager.migrate(migrationSet));
- Assert.assertNull(client.unwrap().checkExists().forPath("/main"));
+ assertNull(client.unwrap().checkExists().forPath("/main"));
}
@Test
@@ -223,11 +229,11 @@
try
{
complete(manager.migrate(migrationSet));
- Assert.fail("Should throw");
+ fail("Should throw");
}
catch ( Throwable e )
{
- Assert.assertTrue(Throwables.getRootCause(e) instanceof MigrationException);
+ assertTrue(Throwables.getRootCause(e) instanceof MigrationException);
}
}
@@ -246,11 +252,11 @@
try
{
complete(manager.migrate(migrationSet));
- Assert.fail("Should throw");
+ fail("Should throw");
}
catch ( Throwable e )
{
- Assert.assertTrue(Throwables.getRootCause(e) instanceof MigrationException);
+ assertTrue(Throwables.getRootCause(e) instanceof MigrationException);
}
}
@@ -265,14 +271,14 @@
try
{
complete(manager.migrate(migrationSet));
- Assert.fail("Should throw");
+ fail("Should throw");
}
catch ( Throwable e )
{
- Assert.assertTrue(Throwables.getRootCause(e) instanceof KeeperException.NoNodeException);
+ assertTrue(Throwables.getRootCause(e) instanceof KeeperException.NoNodeException);
}
- Assert.assertNull(client.unwrap().checkExists().forPath("/test")); // should be all or nothing
+ assertNull(client.unwrap().checkExists().forPath("/test")); // should be all or nothing
}
@Test
@@ -285,14 +291,14 @@
try
{
complete(manager.migrate(migrationSet));
- Assert.fail("Should throw");
+ fail("Should throw");
}
catch ( Throwable e )
{
- Assert.assertTrue(Throwables.getRootCause(e) instanceof KeeperException.NoNodeException);
+ assertTrue(Throwables.getRootCause(e) instanceof KeeperException.NoNodeException);
}
- Assert.assertNull(client.unwrap().checkExists().forPath("/test"));
+ assertNull(client.unwrap().checkExists().forPath("/test"));
}
@Test
@@ -305,22 +311,22 @@
CountDownLatch latch = new CountDownLatch(1);
filterLatch.set(latch);
CompletionStage<Void> first = manager.migrate(migrationSet);
- Assert.assertTrue(timing.awaitLatch(filterIsSetLatch));
+ assertTrue(timing.awaitLatch(filterIsSetLatch));
MigrationManager manager2 = new MigrationManager(client, LOCK_PATH, META_DATA_PATH, executor, Duration.ofMillis(timing.forSleepingABit().milliseconds()));
try
{
complete(manager2.migrate(migrationSet));
- Assert.fail("Should throw");
+ fail("Should throw");
}
catch ( Throwable e )
{
- Assert.assertTrue(Throwables.getRootCause(e) instanceof AsyncWrappers.TimeoutException, "Should throw AsyncWrappers.TimeoutException, was: " + Throwables.getStackTraceAsString(Throwables.getRootCause(e)));
+ assertTrue(Throwables.getRootCause(e) instanceof AsyncWrappers.TimeoutException, "Should throw AsyncWrappers.TimeoutException, was: " + Throwables.getStackTraceAsString(Throwables.getRootCause(e)));
}
latch.countDown();
complete(first);
- Assert.assertEquals(client.unwrap().getData().forPath("/test/bar"), "first".getBytes());
+ assertArrayEquals(client.unwrap().getData().forPath("/test/bar"), "first".getBytes());
}
@Test
@@ -333,23 +339,23 @@
CountDownLatch latch = new CountDownLatch(1);
filterLatch.set(latch);
CompletionStage<Void> first = manager.migrate(migrationSet);
- Assert.assertTrue(timing.awaitLatch(filterIsSetLatch));
+ assertTrue(timing.awaitLatch(filterIsSetLatch));
CompletionStage<Void> second = manager.migrate(migrationSet);
try
{
second.toCompletableFuture().get(timing.forSleepingABit().milliseconds(), TimeUnit.MILLISECONDS);
- Assert.fail("Should throw");
+ fail("Should throw");
}
catch ( Throwable e )
{
- Assert.assertTrue(Throwables.getRootCause(e) instanceof TimeoutException, "Should throw TimeoutException, was: " + Throwables.getStackTraceAsString(Throwables.getRootCause(e)));
+ assertTrue(Throwables.getRootCause(e) instanceof TimeoutException, "Should throw TimeoutException, was: " + Throwables.getStackTraceAsString(Throwables.getRootCause(e)));
}
latch.countDown();
complete(first);
- Assert.assertEquals(client.unwrap().getData().forPath("/test/bar"), "first".getBytes());
+ assertArrayEquals(client.unwrap().getData().forPath("/test/bar"), "first".getBytes());
complete(second);
- Assert.assertEquals(manager.debugCount.get(), 1);
+ assertEquals(manager.debugCount.get(), 1);
}
}
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java
index 70f9c66..1dc9feb 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java
@@ -18,6 +18,11 @@
*/
package org.apache.curator.x.async.modeled;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Sets;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.test.Timing;
@@ -25,8 +30,9 @@
import org.apache.curator.x.async.modeled.cached.CachedModeledFramework;
import org.apache.curator.x.async.modeled.cached.ModeledCacheListener;
import org.apache.curator.x.async.modeled.models.TestModel;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
@@ -39,7 +45,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestCachedModeledFramework extends TestModeledFrameworkBase
{
@Test
@@ -56,7 +62,7 @@
try
{
client.child(model).set(model);
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
CountDownLatch latch = new CountDownLatch(1);
rawClient.getConnectionStateListenable().addListener((__, state) -> {
@@ -66,11 +72,11 @@
}
});
server.stop();
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
complete(client.child(model).read().whenComplete((value, e) -> {
- Assert.assertNotNull(value);
- Assert.assertNull(e);
+ assertNotNull(value);
+ assertNull(e);
}));
}
finally
@@ -93,10 +99,10 @@
client.start();
try
{
- Assert.assertFalse(timing.forSleepingABit().acquireSemaphore(semaphore));
+ assertFalse(timing.forSleepingABit().acquireSemaphore(semaphore));
client.child("2").set(model2); // set before cache is started
- Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ assertTrue(timing.acquireSemaphore(semaphore));
}
finally
{
@@ -124,7 +130,7 @@
complete(client.child("p").child("c2").set(child2));
complete(client.child("p").child("c1").child("g1").set(grandChild1));
complete(client.child("p").child("c2").child("g2").set(grandChild2));
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
complete(client.child("p").children(), (v, e) ->
{
@@ -132,23 +138,23 @@
client.child("p").child("c1").modelSpec().path(),
client.child("p").child("c2").modelSpec().path()
);
- Assert.assertEquals(v, paths);
+ assertEquals(v, paths);
});
complete(client.child("p").childrenAsZNodes(), (v, e) ->
{
Set<TestModel> cachedModels = toSet(v.stream(), ZNode::model);
- Assert.assertEquals(cachedModels, Sets.newHashSet(child1, child2));
+ assertEquals(cachedModels, Sets.newHashSet(child1, child2));
// verify that the same nodes are returned from the uncached method
complete(ModeledFramework.wrap(async, modelSpec).child("p").childrenAsZNodes(), (v2, e2) -> {
Set<TestModel> uncachedModels = toSet(v2.stream(), ZNode::model);
- Assert.assertEquals(cachedModels, uncachedModels);
+ assertEquals(cachedModels, uncachedModels);
});
});
- complete(client.child("p").child("c1").childrenAsZNodes(), (v, e) -> Assert.assertEquals(toSet(v.stream(), ZNode::model), Sets.newHashSet(grandChild1)));
- complete(client.child("p").child("c2").childrenAsZNodes(), (v, e) -> Assert.assertEquals(toSet(v.stream(), ZNode::model), Sets.newHashSet(grandChild2)));
+ complete(client.child("p").child("c1").childrenAsZNodes(), (v, e) -> assertEquals(toSet(v.stream(), ZNode::model), Sets.newHashSet(grandChild1)));
+ complete(client.child("p").child("c2").childrenAsZNodes(), (v, e) -> assertEquals(toSet(v.stream(), ZNode::model), Sets.newHashSet(grandChild2)));
}
}
@@ -164,13 +170,13 @@
client.start();
complete(client.child("m").set(model));
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
// call 2 times in a row to validate CURATOR-546
Optional<ZNode<TestModel>> optZNode = client.cache().currentData(modelSpec.path().child("m"));
- Assert.assertEquals(optZNode.orElseThrow(() -> new AssertionError("node is missing")).model(), model);
+ assertEquals(optZNode.orElseThrow(() -> new AssertionError("node is missing")).model(), model);
optZNode = client.cache().currentData(modelSpec.path().child("m"));
- Assert.assertEquals(optZNode.orElseThrow(() -> new AssertionError("node is missing")).model(), model);
+ assertEquals(optZNode.orElseThrow(() -> new AssertionError("node is missing")).model(), model);
}
}
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFramework.java b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFramework.java
index 7cbf964..0b64b1c 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFramework.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFramework.java
@@ -19,6 +19,11 @@
package org.apache.curator.x.async.modeled;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.collect.Sets;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -38,8 +43,8 @@
import org.apache.zookeeper.data.Id;
import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.server.auth.DigestAuthenticationProvider;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
@@ -56,13 +61,13 @@
TestModel rawModel2 = new TestModel("Wayne", "Rooney", "Old Trafford", 10, BigInteger.valueOf(1));
ModeledFramework<TestModel> client = ModeledFramework.wrap(async, modelSpec);
AsyncStage<String> stage = client.set(rawModel);
- Assert.assertNull(stage.event());
- complete(stage, (s, e) -> Assert.assertNotNull(s));
- complete(client.read(), (model, e) -> Assert.assertEquals(model, rawModel));
+ assertNull(stage.event());
+ complete(stage, (s, e) -> assertNotNull(s));
+ complete(client.read(), (model, e) -> assertEquals(model, rawModel));
complete(client.update(rawModel2));
- complete(client.read(), (model, e) -> Assert.assertEquals(model, rawModel2));
+ complete(client.read(), (model, e) -> assertEquals(model, rawModel2));
complete(client.delete());
- complete(client.checkExists(), (stat, e) -> Assert.assertNull(stat));
+ complete(client.checkExists(), (stat, e) -> assertNull(stat));
}
@Test
@@ -70,10 +75,10 @@
{
TestNewerModel rawNewModel = new TestNewerModel("John", "Galt", "1 Galt's Gulch", 42, BigInteger.valueOf(1), 100);
ModeledFramework<TestNewerModel> clientForNew = ModeledFramework.wrap(async, newModelSpec);
- complete(clientForNew.set(rawNewModel), (s, e) -> Assert.assertNotNull(s));
+ complete(clientForNew.set(rawNewModel), (s, e) -> assertNotNull(s));
ModeledFramework<TestModel> clientForOld = ModeledFramework.wrap(async, modelSpec);
- complete(clientForOld.read(), (model, e) -> Assert.assertTrue(rawNewModel.equalsOld(model)));
+ complete(clientForOld.read(), (model, e) -> assertTrue(rawNewModel.equalsOld(model)));
}
@Test
@@ -83,9 +88,9 @@
ModeledFramework<TestModel> client = ModeledFramework.builder(async, modelSpec).watched().build();
client.checkExists().event().whenComplete((event, ex) -> latch.countDown());
timing.sleepABit();
- Assert.assertEquals(latch.getCount(), 1);
+ assertEquals(latch.getCount(), 1);
client.set(new TestModel());
- Assert.assertTrue(timing.awaitLatch(latch));
+ assertTrue(timing.awaitLatch(latch));
}
@Test
@@ -98,7 +103,7 @@
complete(client.child("three").set(model));
Set<ZPath> expected = Sets.newHashSet(path.child("one"), path.child("two"), path.child("three"));
- complete(client.children(), (children, e) -> Assert.assertEquals(Sets.newHashSet(children), expected));
+ complete(client.children(), (children, e) -> assertEquals(Sets.newHashSet(children), expected));
}
@Test
@@ -108,7 +113,7 @@
}); // ignore error
ModeledFramework<TestModel> client = ModeledFramework.builder(async, modelSpec).watched().build();
- complete(client.read(), (model, e) -> Assert.assertTrue(e instanceof KeeperException.NoNodeException));
+ complete(client.read(), (model, e) -> assertTrue(e instanceof KeeperException.NoNodeException));
}
@Test
@@ -122,7 +127,7 @@
try
{
schemaClient.create().forPath(modelSpec.path().fullPath(), "asflasfas".getBytes());
- Assert.fail("Should've thrown SchemaViolation");
+ fail("Should've thrown SchemaViolation");
}
catch ( SchemaViolation dummy )
{
@@ -130,7 +135,7 @@
}
ModeledFramework<TestModel> modeledSchemaClient = ModeledFramework.wrap(AsyncCuratorFramework.wrap(schemaClient), modelSpec);
- complete(modeledSchemaClient.set(new TestModel("one", "two", "three", 4, BigInteger.ONE)), (dummy, e) -> Assert.assertNull(e));
+ complete(modeledSchemaClient.set(new TestModel("one", "two", "three", 4, BigInteger.ONE)), (dummy, e) -> assertNull(e));
}
}
@@ -144,17 +149,17 @@
VersionedModeledFramework<TestModel> versioned = client.versioned();
complete(versioned.read().whenComplete((v, e) -> {
- Assert.assertNull(e);
- Assert.assertTrue(v.version() > 0);
- }).thenCompose(versioned::set), (s, e) -> Assert.assertNull(e)); // version is correct should succeed
+ assertNull(e);
+ assertTrue(v.version() > 0);
+ }).thenCompose(versioned::set), (s, e) -> assertNull(e)); // version is correct should succeed
Versioned<TestModel> badVersion = Versioned.from(model, 100000);
- complete(versioned.set(badVersion), (v, e) -> Assert.assertTrue(e instanceof KeeperException.BadVersionException));
+ complete(versioned.set(badVersion), (v, e) -> assertTrue(e instanceof KeeperException.BadVersionException));
final Stat stat = new Stat();
complete(client.read(stat));
// wrong version, needs to fail
- complete(client.delete(stat.getVersion() + 1), (v, e) -> Assert.assertTrue(e instanceof KeeperException.BadVersionException));
+ complete(client.delete(stat.getVersion() + 1), (v, e) -> assertTrue(e instanceof KeeperException.BadVersionException));
// correct version
complete(client.delete(stat.getVersion()));
}
@@ -166,13 +171,13 @@
ModelSpec<TestModel> aclModelSpec = ModelSpec.builder(modelSpec.path(), modelSpec.serializer()).withAclList(aclList).build();
ModeledFramework<TestModel> client = ModeledFramework.wrap(async, aclModelSpec);
complete(client.set(new TestModel("John", "Galt", "Galt's Gulch", 21, BigInteger.valueOf(1010101))));
- complete(client.update(new TestModel("John", "Galt", "Galt's Gulch", 54, BigInteger.valueOf(88))), (__, e) -> Assert.assertNotNull(e, "Should've gotten an auth failure"));
+ complete(client.update(new TestModel("John", "Galt", "Galt's Gulch", 54, BigInteger.valueOf(88))), (__, e) -> assertNotNull(e, "Should've gotten an auth failure"));
try (CuratorFramework authCurator = CuratorFrameworkFactory.builder().connectString(server.getConnectString()).retryPolicy(new RetryOneTime(1)).authorization("digest", "test:test".getBytes()).build())
{
authCurator.start();
ModeledFramework<TestModel> authClient = ModeledFramework.wrap(AsyncCuratorFramework.wrap(authCurator), aclModelSpec);
- complete(authClient.update(new TestModel("John", "Galt", "Galt's Gulch", 42, BigInteger.valueOf(66))), (__, e) -> Assert.assertNull(e, "Should've succeeded"));
+ complete(authClient.update(new TestModel("John", "Galt", "Galt's Gulch", 42, BigInteger.valueOf(66))), (__, e) -> assertNull(e, "Should've succeeded"));
}
}
}
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFrameworkBase.java b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFrameworkBase.java
index 61a4570..7465a2e 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFrameworkBase.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFrameworkBase.java
@@ -26,8 +26,8 @@
import org.apache.curator.x.async.CompletableBaseClassForTests;
import org.apache.curator.x.async.modeled.models.TestModel;
import org.apache.curator.x.async.modeled.models.TestNewerModel;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
public class TestModeledFrameworkBase extends CompletableBaseClassForTests
{
@@ -37,7 +37,7 @@
protected ModelSpec<TestNewerModel> newModelSpec;
protected AsyncCuratorFramework async;
- @BeforeMethod
+ @BeforeEach
@Override
public void setup() throws Exception
{
@@ -54,7 +54,7 @@
newModelSpec = ModelSpec.builder(path, newSerializer).build();
}
- @AfterMethod
+ @AfterEach
@Override
public void teardown() throws Exception
{
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
index d2c24da..e35354c 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
@@ -18,109 +18,114 @@
*/
package org.apache.curator.x.async.modeled;
+import static org.apache.curator.x.async.modeled.ZPath.parameter;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.curator.utils.ZKPaths;
import org.apache.curator.x.async.modeled.details.ZPathImpl;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import static org.apache.curator.x.async.modeled.ZPath.parameter;
+import org.junit.jupiter.api.Test;
public class TestZPath
{
@Test
public void testRoot()
{
- Assert.assertEquals(ZPath.root.nodeName(), ZKPaths.PATH_SEPARATOR);
- Assert.assertEquals(ZPath.root, ZPathImpl.root);
- Assert.assertTrue(ZPath.root.isRoot());
- Assert.assertEquals(ZPath.root.child("foo").parent(), ZPath.root);
- Assert.assertTrue(ZPath.root.child("foo").parent().isRoot());
+ assertEquals(ZPath.root.nodeName(), ZKPaths.PATH_SEPARATOR);
+ assertEquals(ZPath.root, ZPathImpl.root);
+ assertTrue(ZPath.root.isRoot());
+ assertEquals(ZPath.root.child("foo").parent(), ZPath.root);
+ assertTrue(ZPath.root.child("foo").parent().isRoot());
}
@Test
public void testBasic()
{
ZPath path = ZPath.root.child("one").child("two");
- Assert.assertFalse(path.isRoot());
- Assert.assertEquals(path, ZPath.root.child("one").child("two"));
- Assert.assertNotEquals(path, ZPath.root.child("onex").child("two"));
- Assert.assertEquals(path.nodeName(), "two");
- Assert.assertEquals(path.fullPath(), "/one/two");
- Assert.assertEquals(path.parent().fullPath(), "/one");
- Assert.assertEquals(path.fullPath(), "/one/two"); // call twice to test the internal cache
- Assert.assertEquals(path.parent().fullPath(), "/one"); // call twice to test the internal cache
+ assertFalse(path.isRoot());
+ assertEquals(path, ZPath.root.child("one").child("two"));
+ assertNotEquals(path, ZPath.root.child("onex").child("two"));
+ assertEquals(path.nodeName(), "two");
+ assertEquals(path.fullPath(), "/one/two");
+ assertEquals(path.parent().fullPath(), "/one");
+ assertEquals(path.fullPath(), "/one/two"); // call twice to test the internal cache
+ assertEquals(path.parent().fullPath(), "/one"); // call twice to test the internal cache
- Assert.assertTrue(path.startsWith(ZPath.root.child("one")));
- Assert.assertFalse(path.startsWith(ZPath.root.child("two")));
+ assertTrue(path.startsWith(ZPath.root.child("one")));
+ assertFalse(path.startsWith(ZPath.root.child("two")));
ZPath checkIdLike = ZPath.parse("/one/{two}/three");
- Assert.assertTrue(checkIdLike.isResolved());
+ assertTrue(checkIdLike.isResolved());
checkIdLike = ZPath.parse("/one/" + ZPath.parameter() + "/three");
- Assert.assertTrue(checkIdLike.isResolved());
+ assertTrue(checkIdLike.isResolved());
checkIdLike = ZPath.parse("/one/" + ZPath.parameter("others") + "/three");
- Assert.assertTrue(checkIdLike.isResolved());
+ assertTrue(checkIdLike.isResolved());
}
@Test
public void testParsing()
{
- Assert.assertEquals(ZPath.parse("/"), ZPath.root);
- Assert.assertEquals(ZPath.parse("/one/two/three"), ZPath.root.child("one").child("two").child("three"));
- Assert.assertEquals(ZPath.parse("/one/two/three"), ZPath.from("one", "two", "three"));
- Assert.assertEquals(ZPath.parseWithIds("/one/{id}/two/{id}"), ZPath.from("one", parameter(), "two", parameter()));
+ assertEquals(ZPath.parse("/"), ZPath.root);
+ assertEquals(ZPath.parse("/one/two/three"), ZPath.root.child("one").child("two").child("three"));
+ assertEquals(ZPath.parse("/one/two/three"), ZPath.from("one", "two", "three"));
+ assertEquals(ZPath.parseWithIds("/one/{id}/two/{id}"), ZPath.from("one", parameter(), "two", parameter()));
}
- @Test(expectedExceptions = IllegalStateException.class)
+ @Test
public void testUnresolvedPath()
{
- ZPath path = ZPath.from("one", parameter(), "two");
- path.fullPath();
+ assertThrows(IllegalStateException.class, ()->{
+ ZPath path = ZPath.from("one", parameter(), "two");
+ path.fullPath();
+ });
}
@Test
public void testResolvedPath()
{
ZPath path = ZPath.from("one", parameter(), "two", parameter());
- Assert.assertEquals(path.resolved("a", "b"), ZPath.from("one", "a", "two", "b"));
+ assertEquals(path.resolved("a", "b"), ZPath.from("one", "a", "two", "b"));
}
@Test
public void testSchema()
{
ZPath path = ZPath.from("one", parameter(), "two", parameter());
- Assert.assertEquals(path.toSchemaPathPattern().toString(), "/one/.*/two/.*");
+ assertEquals(path.toSchemaPathPattern().toString(), "/one/.*/two/.*");
path = ZPath.parse("/one/two/three");
- Assert.assertEquals(path.toSchemaPathPattern().toString(), "/one/two/three");
+ assertEquals(path.toSchemaPathPattern().toString(), "/one/two/three");
path = ZPath.parseWithIds("/one/{id}/three");
- Assert.assertEquals(path.toSchemaPathPattern().toString(), "/one/.*/three");
+ assertEquals(path.toSchemaPathPattern().toString(), "/one/.*/three");
path = ZPath.parseWithIds("/{id}/{id}/three");
- Assert.assertEquals(path.toSchemaPathPattern().toString(), "/.*/.*/three");
+ assertEquals(path.toSchemaPathPattern().toString(), "/.*/.*/three");
}
@Test
public void testCustomIds()
{
- Assert.assertEquals(ZPath.parseWithIds("/a/{a}/bee/{bee}/c/{c}").toString(), "/a/{a}/bee/{bee}/c/{c}");
- Assert.assertEquals(ZPath.from("a", parameter(), "b", parameter()).toString(), "/a/{id}/b/{id}");
- Assert.assertEquals(ZPath.from("a", parameter("foo"), "b", parameter("bar")).toString(), "/a/{foo}/b/{bar}");
+ assertEquals(ZPath.parseWithIds("/a/{a}/bee/{bee}/c/{c}").toString(), "/a/{a}/bee/{bee}/c/{c}");
+ assertEquals(ZPath.from("a", parameter(), "b", parameter()).toString(), "/a/{id}/b/{id}");
+ assertEquals(ZPath.from("a", parameter("foo"), "b", parameter("bar")).toString(), "/a/{foo}/b/{bar}");
}
@Test
public void testPartialResolution()
{
ZPath path = ZPath.parseWithIds("/one/{1}/two/{2}");
- Assert.assertFalse(path.parent().isResolved());
- Assert.assertFalse(path.parent().parent().isResolved());
- Assert.assertTrue(path.parent().parent().parent().isResolved());
- Assert.assertFalse(path.isResolved());
+ assertFalse(path.parent().isResolved());
+ assertFalse(path.parent().parent().isResolved());
+ assertTrue(path.parent().parent().parent().isResolved());
+ assertFalse(path.isResolved());
path = path.resolved("p1");
- Assert.assertFalse(path.isResolved());
- Assert.assertTrue(path.parent().isResolved());
- Assert.assertEquals(path.toString(), "/one/p1/two/{2}");
+ assertFalse(path.isResolved());
+ assertTrue(path.parent().isResolved());
+ assertEquals(path.toString(), "/one/p1/two/{2}");
path = path.resolved("p2");
- Assert.assertTrue(path.isResolved());
- Assert.assertEquals(path.toString(), "/one/p1/two/p2");
+ assertTrue(path.isResolved());
+ assertEquals(path.toString(), "/one/p1/two/p2");
}
}
diff --git a/curator-x-discovery-server/pom.xml b/curator-x-discovery-server/pom.xml
index bcf25dc..6ea4c06 100644
--- a/curator-x-discovery-server/pom.xml
+++ b/curator-x-discovery-server/pom.xml
@@ -62,8 +62,8 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
diff --git a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestMapsWithJersey.java b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestMapsWithJersey.java
index 5dc16c8..997cefe 100644
--- a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestMapsWithJersey.java
+++ b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestMapsWithJersey.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.x.discovery.server.jetty_jersey;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -39,13 +40,12 @@
import org.apache.curator.x.discovery.server.entity.ServiceNames;
import org.apache.curator.x.discovery.server.mocks.MockServiceDiscovery;
import org.apache.curator.x.discovery.strategies.RandomStrategy;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import java.util.Map;
@@ -53,6 +53,7 @@
public class TestMapsWithJersey
{
+ private static final String HOST = "127.0.0.1";
private Server server;
private JsonServiceNamesMarshaller serviceNamesMarshaller;
private JsonServiceInstanceMarshaller<Map<String, String>> serviceInstanceMarshaller;
@@ -60,7 +61,7 @@
private MapDiscoveryContext context;
private int port;
- @BeforeMethod
+ @BeforeEach
public void setup() throws Exception
{
context = new MapDiscoveryContext(new MockServiceDiscovery<Map<String, String>>(), new RandomStrategy<Map<String, String>>(), 1000);
@@ -98,7 +99,7 @@
server.start();
}
- @AfterMethod
+ @AfterEach
public void teardown() throws Exception
{
server.stop();
@@ -132,22 +133,22 @@
}
};
Client client = Client.create(config);
- WebResource resource = client.resource("http://localhost:" + port);
+ WebResource resource = client.resource("http://" + HOST + ":" + port);
resource.path("/v1/service/test/" + service.getId()).type(MediaType.APPLICATION_JSON_TYPE).put(service);
ServiceNames names = resource.path("/v1/service").get(ServiceNames.class);
- Assert.assertEquals(names.getNames(), Lists.newArrayList("test"));
+ assertEquals(names.getNames(), Lists.newArrayList("test"));
GenericType<ServiceInstances<Map<String, String>>> type = new GenericType<ServiceInstances<Map<String, String>>>(){};
ServiceInstances<Map<String, String>> instances = resource.path("/v1/service/test").get(type);
- Assert.assertEquals(instances.getServices().size(), 1);
- Assert.assertEquals(instances.getServices().get(0), service);
- Assert.assertEquals(instances.getServices().get(0).getPayload(), payload);
+ assertEquals(instances.getServices().size(), 1);
+ assertEquals(instances.getServices().get(0), service);
+ assertEquals(instances.getServices().get(0).getPayload(), payload);
// Retrieve a single instance
GenericType<ServiceInstance<Map<String, String>>> singleInstanceType = new GenericType<ServiceInstance<Map<String, String>>>(){};
ServiceInstance<Map<String, String>> instance = resource.path("/v1/service/test/" + service.getId()).get(singleInstanceType);
- Assert.assertEquals(instance, service);
+ assertEquals(instance, service);
}
}
diff --git a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestObjectPayloadWithJersey.java b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestObjectPayloadWithJersey.java
index 80f2e4a..5ef1983 100644
--- a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestObjectPayloadWithJersey.java
+++ b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestObjectPayloadWithJersey.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.x.discovery.server.jetty_jersey;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.sun.jersey.api.client.Client;
@@ -37,19 +38,19 @@
import org.apache.curator.x.discovery.server.entity.ServiceNames;
import org.apache.curator.x.discovery.server.mocks.MockServiceDiscovery;
import org.apache.curator.x.discovery.strategies.RandomStrategy;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import java.util.Set;
public class TestObjectPayloadWithJersey
{
+ private static final String HOST = "127.0.0.1";
private Server server;
private JsonServiceNamesMarshaller serviceNamesMarshaller;
private JsonServiceInstanceMarshaller<ServiceDetails> serviceInstanceMarshaller;
@@ -57,7 +58,7 @@
private ServiceDetailsDiscoveryContext context;
private int port;
- @BeforeMethod
+ @BeforeEach
public void setup() throws Exception
{
context = new ServiceDetailsDiscoveryContext(new MockServiceDiscovery<ServiceDetails>(), new RandomStrategy<ServiceDetails>(), 1000);
@@ -95,7 +96,7 @@
server.start();
}
- @AfterMethod
+ @AfterEach
public void teardown() throws Exception
{
server.stop();
@@ -130,22 +131,22 @@
}
};
Client client = Client.create(config);
- WebResource resource = client.resource("http://localhost:" + port);
+ WebResource resource = client.resource("http://" + HOST + ":" + port);
resource.path("/v1/service/test/" + service.getId()).type(MediaType.APPLICATION_JSON_TYPE).put(service);
ServiceNames names = resource.path("/v1/service").get(ServiceNames.class);
- Assert.assertEquals(names.getNames(), Lists.newArrayList("test"));
+ assertEquals(names.getNames(), Lists.newArrayList("test"));
GenericType<ServiceInstances<ServiceDetails>> type = new GenericType<ServiceInstances<ServiceDetails>>(){};
ServiceInstances<ServiceDetails> instances = resource.path("/v1/service/test").get(type);
- Assert.assertEquals(instances.getServices().size(), 1);
- Assert.assertEquals(instances.getServices().get(0), service);
- Assert.assertEquals(instances.getServices().get(0).getPayload(), payload);
+ assertEquals(instances.getServices().size(), 1);
+ assertEquals(instances.getServices().get(0), service);
+ assertEquals(instances.getServices().get(0).getPayload(), payload);
// Retrieve a single instance
GenericType<ServiceInstance<ServiceDetails>> singleInstanceType = new GenericType<ServiceInstance<ServiceDetails>>(){};
ServiceInstance<ServiceDetails> instance = resource.path("/v1/service/test/" + service.getId()).get(singleInstanceType);
- Assert.assertEquals(instance, service);
+ assertEquals(instance, service);
}
}
diff --git a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestStringsWithJersey.java b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestStringsWithJersey.java
index 8cf43cc..3efbc00 100644
--- a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestStringsWithJersey.java
+++ b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_jersey/TestStringsWithJersey.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.x.discovery.server.jetty_jersey;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.sun.jersey.api.client.Client;
@@ -38,19 +39,19 @@
import org.apache.curator.x.discovery.server.entity.ServiceNames;
import org.apache.curator.x.discovery.server.mocks.MockServiceDiscovery;
import org.apache.curator.x.discovery.strategies.RandomStrategy;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import java.util.Set;
public class TestStringsWithJersey
{
+ private static final String HOST = "127.0.0.1";
private Server server;
private JsonServiceNamesMarshaller serviceNamesMarshaller;
private JsonServiceInstanceMarshaller<String> serviceInstanceMarshaller;
@@ -58,7 +59,7 @@
private StringDiscoveryContext context;
private int port;
- @BeforeMethod
+ @BeforeEach
public void setup() throws Exception
{
context = new StringDiscoveryContext(new MockServiceDiscovery<String>(), new RandomStrategy<String>(), 1000);
@@ -96,7 +97,7 @@
server.start();
}
- @AfterMethod
+ @AfterEach
public void teardown() throws Exception
{
server.stop();
@@ -126,21 +127,21 @@
}
};
Client client = Client.create(config);
- WebResource resource = client.resource("http://localhost:" + port);
+ WebResource resource = client.resource("http://" + HOST + ":" + port);
resource.path("/v1/service/test/" + service.getId()).type(MediaType.APPLICATION_JSON_TYPE).put(service);
ServiceNames names = resource.path("/v1/service").get(ServiceNames.class);
- Assert.assertEquals(names.getNames(), Lists.newArrayList("test"));
+ assertEquals(names.getNames(), Lists.newArrayList("test"));
GenericType<ServiceInstances<String>> type = new GenericType<ServiceInstances<String>>(){};
ServiceInstances<String> instances = resource.path("/v1/service/test").get(type);
- Assert.assertEquals(instances.getServices().size(), 1);
- Assert.assertEquals(instances.getServices().get(0), service);
+ assertEquals(instances.getServices().size(), 1);
+ assertEquals(instances.getServices().get(0), service);
// Retrieve a single instance
GenericType<ServiceInstance<String>> singleInstanceType = new GenericType<ServiceInstance<String>>(){};
ServiceInstance<String> instance = resource.path("/v1/service/test/" + service.getId()).get(singleInstanceType);
- Assert.assertEquals(instance, service);
+ assertEquals(instance, service);
}
@Test
@@ -160,8 +161,8 @@
}
};
Client client = Client.create(config);
- WebResource resource = client.resource("http://localhost:" + port);
+ WebResource resource = client.resource("http://" + HOST + ":" + port);
ServiceNames names = resource.path("/v1/service").get(ServiceNames.class);
- Assert.assertEquals(names.getNames(), Lists.<String>newArrayList());
+ assertEquals(names.getNames(), Lists.<String>newArrayList());
}
}
diff --git a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_resteasy/TestStringsWithRestEasy.java b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_resteasy/TestStringsWithRestEasy.java
index 13f1e14..a6682db 100644
--- a/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_resteasy/TestStringsWithRestEasy.java
+++ b/curator-x-discovery-server/src/test/java/org/apache/curator/x/discovery/server/jetty_resteasy/TestStringsWithRestEasy.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.x.discovery.server.jetty_resteasy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Lists;
import com.google.common.io.ByteSource;
import com.google.common.io.CharStreams;
@@ -29,13 +30,12 @@
import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import javax.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -50,10 +50,11 @@
@SuppressWarnings("unchecked")
public class TestStringsWithRestEasy
{
+ private static final String HOST = "127.0.0.1";
private Server server;
private int port;
- @BeforeMethod
+ @BeforeEach
public void setup() throws Exception
{
RestEasyApplication.singletonsRef.set(new RestEasySingletons());
@@ -71,7 +72,7 @@
server.start();
}
- @AfterMethod
+ @AfterEach
public void teardown() throws Exception
{
server.stop();
@@ -92,31 +93,31 @@
ByteArrayOutputStream out = new ByteArrayOutputStream();
restEasySingletons.serviceInstanceMarshallerSingleton.writeTo(service, null, null, null, null, null, out);
- getJson("http://localhost:" + port + "/v1/service/test/" + service.getId(), new String(out.toByteArray()));
+ getJson("http://" + HOST + ":" + port + "/v1/service/test/" + service.getId(), new String(out.toByteArray()));
- String json = getJson("http://localhost:" + port + "/v1/service", null);
+ String json = getJson("http://" + HOST + ":" + port + "/v1/service", null);
ServiceNames names = restEasySingletons.serviceNamesMarshallerSingleton.readFrom(ServiceNames.class, null, null, MediaType.APPLICATION_JSON_TYPE, null, new ByteArrayInputStream(json.getBytes()));
- Assert.assertEquals(names.getNames(), Lists.newArrayList("test"));
+ assertEquals(names.getNames(), Lists.newArrayList("test"));
- json = getJson("http://localhost:" + port + "/v1/service/test", null);
+ json = getJson("http://" + HOST + ":" + port + "/v1/service/test", null);
ServiceInstances<String> instances = restEasySingletons.serviceInstancesMarshallerSingleton.readFrom(null, null, null, null, null, new ByteArrayInputStream(json.getBytes()));
- Assert.assertEquals(instances.getServices().size(), 1);
- Assert.assertEquals(instances.getServices().get(0), service);
+ assertEquals(instances.getServices().size(), 1);
+ assertEquals(instances.getServices().get(0), service);
// Retrieve single instance
- json = getJson("http://localhost:" + port + "/v1/service/test/" + service.getId(), null);
+ json = getJson("http://" + HOST + ":" + port + "/v1/service/test/" + service.getId(), null);
ServiceInstance<String> instance = restEasySingletons.serviceInstanceMarshallerSingleton.readFrom(null, null, null, null, null, new ByteArrayInputStream(json.getBytes()));
- Assert.assertEquals(instance, service);
+ assertEquals(instance, service);
}
@Test
public void testEmptyServiceNames() throws Exception
{
- String json = getJson("http://localhost:" + port + "/v1/service", null);
+ String json = getJson("http://" + HOST + ":" + port + "/v1/service", null);
ServiceNames names = RestEasyApplication.singletonsRef.get().serviceNamesMarshallerSingleton.readFrom(ServiceNames.class, null, null, MediaType.APPLICATION_JSON_TYPE, null, new ByteArrayInputStream(json.getBytes()));
- Assert.assertEquals(names.getNames(), Lists.<String>newArrayList());
+ assertEquals(names.getNames(), Lists.<String>newArrayList());
}
private String getJson(String urlStr, String body) throws IOException
diff --git a/curator-x-discovery/pom.xml b/curator-x-discovery/pom.xml
index 0fad922..b4e369e 100644
--- a/curator-x-discovery/pom.xml
+++ b/curator-x-discovery/pom.xml
@@ -63,8 +63,8 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/ServiceCacheLeakTester.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/ServiceCacheLeakTester.java
index 3d357f6..14a05fe 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/ServiceCacheLeakTester.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/ServiceCacheLeakTester.java
@@ -25,9 +25,9 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.x.discovery.strategies.RandomStrategy;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class ServiceCacheLeakTester
{
public static void main(String[] args) throws Exception
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestJsonInstanceSerializer.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestJsonInstanceSerializer.java
index 0ed6c3d..0d9515e 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestJsonInstanceSerializer.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestJsonInstanceSerializer.java
@@ -18,14 +18,15 @@
*/
package org.apache.curator.x.discovery;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.apache.curator.x.discovery.details.JsonInstanceSerializer;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class TestJsonInstanceSerializer
{
@@ -37,15 +38,15 @@
byte[] bytes = serializer.serialize(instance);
ServiceInstance<String> rhs = serializer.deserialize(bytes);
- Assert.assertEquals(instance, rhs);
- Assert.assertEquals(instance.getId(), rhs.getId());
- Assert.assertEquals(instance.getName(), rhs.getName());
- Assert.assertEquals(instance.getPayload(), rhs.getPayload());
- Assert.assertEquals(instance.getAddress(), rhs.getAddress());
- Assert.assertEquals(instance.getPort(), rhs.getPort());
- Assert.assertEquals(instance.getSslPort(), rhs.getSslPort());
- Assert.assertEquals(instance.getUriSpec(), rhs.getUriSpec());
- Assert.assertEquals(instance.isEnabled(), rhs.isEnabled());
+ assertEquals(instance, rhs);
+ assertEquals(instance.getId(), rhs.getId());
+ assertEquals(instance.getName(), rhs.getName());
+ assertEquals(instance.getPayload(), rhs.getPayload());
+ assertEquals(instance.getAddress(), rhs.getAddress());
+ assertEquals(instance.getPort(), rhs.getPort());
+ assertEquals(instance.getSslPort(), rhs.getSslPort());
+ assertEquals(instance.getUriSpec(), rhs.getUriSpec());
+ assertEquals(instance.isEnabled(), rhs.isEnabled());
}
@Test
@@ -58,7 +59,7 @@
try
{
doubleSerializer.deserialize(bytes);
- Assert.fail();
+ fail();
}
catch ( ClassCastException e )
{
@@ -74,15 +75,15 @@
byte[] bytes = serializer.serialize(instance);
ServiceInstance<Void> rhs = serializer.deserialize(bytes);
- Assert.assertEquals(instance, rhs);
- Assert.assertEquals(instance.getId(), rhs.getId());
- Assert.assertEquals(instance.getName(), rhs.getName());
- Assert.assertEquals(instance.getPayload(), rhs.getPayload());
- Assert.assertEquals(instance.getAddress(), rhs.getAddress());
- Assert.assertEquals(instance.getPort(), rhs.getPort());
- Assert.assertEquals(instance.getSslPort(), rhs.getSslPort());
- Assert.assertEquals(instance.getUriSpec(), rhs.getUriSpec());
- Assert.assertEquals(instance.isEnabled(), rhs.isEnabled());
+ assertEquals(instance, rhs);
+ assertEquals(instance.getId(), rhs.getId());
+ assertEquals(instance.getName(), rhs.getName());
+ assertEquals(instance.getPayload(), rhs.getPayload());
+ assertEquals(instance.getAddress(), rhs.getAddress());
+ assertEquals(instance.getPort(), rhs.getPort());
+ assertEquals(instance.getSslPort(), rhs.getSslPort());
+ assertEquals(instance.getUriSpec(), rhs.getUriSpec());
+ assertEquals(instance.isEnabled(), rhs.isEnabled());
}
@Test
@@ -92,7 +93,7 @@
byte[] bytes = "{}".getBytes("utf-8");
ServiceInstance<Void> instance = serializer.deserialize(bytes);
- Assert.assertTrue(instance.isEnabled(), "Instance that has no 'enabled' should be assumed enabled");
+ assertTrue(instance.isEnabled(), "Instance that has no 'enabled' should be assumed enabled");
}
@Test
@@ -106,15 +107,15 @@
byte[] bytes = serializer.serialize(instance);
ServiceInstance<Object> rhs = serializer.deserialize(bytes);
- Assert.assertEquals(instance, rhs);
- Assert.assertEquals(instance.getId(), rhs.getId());
- Assert.assertEquals(instance.getName(), rhs.getName());
- Assert.assertEquals(instance.getPayload(), rhs.getPayload());
- Assert.assertEquals(instance.getAddress(), rhs.getAddress());
- Assert.assertEquals(instance.getPort(), rhs.getPort());
- Assert.assertEquals(instance.getSslPort(), rhs.getSslPort());
- Assert.assertEquals(instance.getUriSpec(), rhs.getUriSpec());
- Assert.assertEquals(instance.isEnabled(), rhs.isEnabled());
+ assertEquals(instance, rhs);
+ assertEquals(instance.getId(), rhs.getId());
+ assertEquals(instance.getName(), rhs.getName());
+ assertEquals(instance.getPayload(), rhs.getPayload());
+ assertEquals(instance.getAddress(), rhs.getAddress());
+ assertEquals(instance.getPort(), rhs.getPort());
+ assertEquals(instance.getSslPort(), rhs.getSslPort());
+ assertEquals(instance.getUriSpec(), rhs.getUriSpec());
+ assertEquals(instance.isEnabled(), rhs.isEnabled());
}
@@ -129,15 +130,15 @@
byte[] bytes = serializer.serialize(instance);
ServiceInstance<Object> rhs = serializer.deserialize(bytes);
- Assert.assertEquals(instance, rhs);
- Assert.assertEquals(instance.getId(), rhs.getId());
- Assert.assertEquals(instance.getName(), rhs.getName());
- Assert.assertEquals(instance.getPayload(), rhs.getPayload());
- Assert.assertEquals(instance.getAddress(), rhs.getAddress());
- Assert.assertEquals(instance.getPort(), rhs.getPort());
- Assert.assertEquals(instance.getSslPort(), rhs.getSslPort());
- Assert.assertEquals(instance.getUriSpec(), rhs.getUriSpec());
- Assert.assertEquals(instance.isEnabled(), rhs.isEnabled());
+ assertEquals(instance, rhs);
+ assertEquals(instance.getId(), rhs.getId());
+ assertEquals(instance.getName(), rhs.getName());
+ assertEquals(instance.getPayload(), rhs.getPayload());
+ assertEquals(instance.getAddress(), rhs.getAddress());
+ assertEquals(instance.getPort(), rhs.getPort());
+ assertEquals(instance.getSslPort(), rhs.getSslPort());
+ assertEquals(instance.getUriSpec(), rhs.getUriSpec());
+ assertEquals(instance.isEnabled(), rhs.isEnabled());
}
@Test
@@ -150,15 +151,15 @@
byte[] bytes = serializer.serialize(instance);
ServiceInstance<Payload> rhs = serializer.deserialize(bytes);
- Assert.assertEquals(instance, rhs);
- Assert.assertEquals(instance.getId(), rhs.getId());
- Assert.assertEquals(instance.getName(), rhs.getName());
- Assert.assertEquals(instance.getPayload(), rhs.getPayload());
- Assert.assertEquals(instance.getAddress(), rhs.getAddress());
- Assert.assertEquals(instance.getPort(), rhs.getPort());
- Assert.assertEquals(instance.getSslPort(), rhs.getSslPort());
- Assert.assertEquals(instance.getUriSpec(), rhs.getUriSpec());
- Assert.assertEquals(instance.isEnabled(), rhs.isEnabled());
+ assertEquals(instance, rhs);
+ assertEquals(instance.getId(), rhs.getId());
+ assertEquals(instance.getName(), rhs.getName());
+ assertEquals(instance.getPayload(), rhs.getPayload());
+ assertEquals(instance.getAddress(), rhs.getAddress());
+ assertEquals(instance.getPort(), rhs.getPort());
+ assertEquals(instance.getSslPort(), rhs.getSslPort());
+ assertEquals(instance.getUriSpec(), rhs.getUriSpec());
+ assertEquals(instance.isEnabled(), rhs.isEnabled());
}
public static class Payload {
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestLocalIpFilter.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestLocalIpFilter.java
index 2e2efa0..9648c9b 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestLocalIpFilter.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestLocalIpFilter.java
@@ -18,9 +18,10 @@
*/
package org.apache.curator.x.discovery;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
@@ -47,7 +48,7 @@
);
List<InetAddress> allLocalIPs = Lists.newArrayList(ServiceInstanceBuilder.getAllLocalIPs());
- Assert.assertEquals(allLocalIPs.size(), 0);
+ assertEquals(allLocalIPs.size(), 0);
}
finally
{
@@ -55,6 +56,6 @@
}
List<InetAddress> allLocalIPs = Lists.newArrayList(ServiceInstanceBuilder.getAllLocalIPs());
- Assert.assertTrue(allLocalIPs.size() > 0);
+ assertTrue(allLocalIPs.size() > 0);
}
}
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java
index 6d24586..b1a3526 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java
@@ -19,6 +19,9 @@
package org.apache.curator.x.discovery;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -31,8 +34,9 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.utils.Compatibility;
import org.apache.curator.x.discovery.details.ServiceCacheListener;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.io.Closeable;
import java.util.Collection;
import java.util.Collections;
@@ -42,7 +46,7 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestServiceCache extends BaseClassForTests
{
@Test
@@ -86,13 +90,13 @@
discovery.registerService(instance2);
discovery.registerService(instance3);
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
ServiceCache<String> cache2 = discovery.serviceCacheBuilder().name("test").build();
closeables.add(cache2);
cache2.start();
- Assert.assertEquals(cache2.getInstances().size(), 3);
+ assertEquals(cache2.getInstances().size(), 3);
}
finally
{
@@ -131,17 +135,17 @@
ServiceInstance<String> foundInstance = null;
while ( foundInstance == null )
{
- Assert.assertTrue(count++ < 5);
+ assertTrue(count++ < 5);
foundInstance = serviceProvider.getInstance();
timing.sleepABit();
}
- Assert.assertEquals(foundInstance, instance);
+ assertEquals(foundInstance, instance);
ServiceInstance<String> instance2 = ServiceInstance.<String>builder().address("foo").payload("thing").name("test").port(10064).build();
discovery.registerService(instance2);
timing.sleepABit();
Collection<ServiceInstance<String>> allInstances = serviceProvider.getAllInstances();
- Assert.assertEquals(allInstances.size(), 2);
+ assertEquals(allInstances.size(), 2);
}
finally
{
@@ -190,10 +194,10 @@
instance = ServiceInstance.<String>builder().payload("changed").name("test").port(10064).id(instance.getId()).build();
discovery.updateService(instance);
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
- Assert.assertEquals(cache.getInstances().size(), 1);
- Assert.assertEquals(cache.getInstances().get(0).getPayload(), instance.getPayload());
+ assertEquals(cache.getInstances().size(), 1);
+ assertEquals(cache.getInstances().get(0).getPayload(), instance.getPayload());
}
finally
{
@@ -242,14 +246,14 @@
ServiceInstance<String> instance1 = ServiceInstance.<String>builder().payload("thing").name("test").port(10064).build();
ServiceInstance<String> instance2 = ServiceInstance.<String>builder().payload("thing").name("test").port(10065).build();
discovery.registerService(instance1);
- Assert.assertTrue(semaphore.tryAcquire(10, TimeUnit.SECONDS));
+ assertTrue(semaphore.tryAcquire(10, TimeUnit.SECONDS));
discovery.registerService(instance2);
- Assert.assertTrue(semaphore.tryAcquire(3, TimeUnit.SECONDS));
+ assertTrue(semaphore.tryAcquire(3, TimeUnit.SECONDS));
ServiceInstance<String> instance3 = ServiceInstance.<String>builder().payload("thing").name("another").port(10064).build();
discovery.registerService(instance3);
- Assert.assertFalse(semaphore.tryAcquire(3, TimeUnit.SECONDS)); // should not get called for a different service
+ assertFalse(semaphore.tryAcquire(3, TimeUnit.SECONDS)); // should not get called for a different service
}
finally
{
@@ -281,7 +285,7 @@
discovery.start();
ExecuteCalledWatchingExecutorService exec = new ExecuteCalledWatchingExecutorService(Executors.newSingleThreadExecutor());
- Assert.assertFalse(exec.isExecuteCalled());
+ assertFalse(exec.isExecuteCalled());
ServiceCache<String> cache = discovery.serviceCacheBuilder().name("test").executorService(exec).build();
closeables.add(cache);
@@ -305,9 +309,9 @@
ServiceInstance<String> instance1 = ServiceInstance.<String>builder().payload("thing").name("test").port(10064).build();
discovery.registerService(instance1);
- Assert.assertTrue(semaphore.tryAcquire(10, TimeUnit.SECONDS));
+ assertTrue(semaphore.tryAcquire(10, TimeUnit.SECONDS));
- Assert.assertTrue(exec.isExecuteCalled());
+ assertTrue(exec.isExecuteCalled());
}
finally
{
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestStrategies.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestStrategies.java
index 04bd052..1e85724 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestStrategies.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestStrategies.java
@@ -18,14 +18,16 @@
*/
package org.apache.curator.x.discovery;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.x.discovery.details.InstanceProvider;
import org.apache.curator.x.discovery.strategies.RandomStrategy;
import org.apache.curator.x.discovery.strategies.RoundRobinStrategy;
import org.apache.curator.x.discovery.strategies.StickyStrategy;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
public class TestStrategies
@@ -78,7 +80,7 @@
{
statistic.addValue(counts[i]);
}
- Assert.assertTrue(statistic.getStandardDeviation() <= (QTY * 2), "" + statistic.getStandardDeviation()); // meager check for even distribution
+ assertTrue(statistic.getStandardDeviation() <= (QTY * 2), "" + statistic.getStandardDeviation()); // meager check for even distribution
}
@Test
@@ -92,13 +94,13 @@
for ( int i = 0; i < QTY; ++i )
{
ServiceInstance<Void> instance = strategy.getInstance(instanceProvider);
- Assert.assertEquals(instance.getId(), Integer.toString(i));
+ assertEquals(instance.getId(), Integer.toString(i));
}
for ( int i = 0; i < (1234 * QTY); ++i )
{
ServiceInstance<Void> instance = strategy.getInstance(instanceProvider);
- Assert.assertEquals(instance.getId(), Integer.toString(i % QTY));
+ assertEquals(instance.getId(), Integer.toString(i % QTY));
}
}
@@ -114,18 +116,18 @@
int instanceNumber = strategy.getInstanceNumber();
for ( int i = 0; i < 1000; ++i )
{
- Assert.assertEquals(strategy.getInstance(instanceProvider), theInstance);
+ assertEquals(strategy.getInstance(instanceProvider), theInstance);
}
// assert what happens when an instance goes down
instanceProvider = new TestInstanceProvider(QTY, QTY);
- Assert.assertFalse(strategy.getInstance(instanceProvider).equals(theInstance));
- Assert.assertFalse(instanceNumber == strategy.getInstanceNumber());
+ assertFalse(strategy.getInstance(instanceProvider).equals(theInstance));
+ assertFalse(instanceNumber == strategy.getInstanceNumber());
theInstance = strategy.getInstance(instanceProvider);
for ( int i = 0; i < 1000; ++i )
{
- Assert.assertEquals(strategy.getInstance(instanceProvider), theInstance);
+ assertEquals(strategy.getInstance(instanceProvider), theInstance);
}
}
}
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestUriSpec.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestUriSpec.java
index 974e81c..3613df3 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestUriSpec.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestUriSpec.java
@@ -18,9 +18,9 @@
*/
package org.apache.curator.x.discovery;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Maps;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.Iterator;
import java.util.Map;
@@ -36,11 +36,11 @@
builder.name("foo");
builder.port(5);
ServiceInstance<Void> instance = builder.build();
- Assert.assertEquals(spec.build(instance), "http://foo.com");
+ assertEquals(spec.build(instance), "http://foo.com");
builder.sslPort(5);
instance = builder.build();
- Assert.assertEquals(spec.build(instance), "https://foo.com");
+ assertEquals(spec.build(instance), "https://foo.com");
}
@Test
@@ -60,7 +60,7 @@
Map<String, Object> m = Maps.newHashMap();
m.put("scheme", "test");
- Assert.assertEquals(spec.build(instance, m), "test://1.2.3.4:5:6/foo/bar/789/permanent");
+ assertEquals(spec.build(instance, m), "test://1.2.3.4:5:6/foo/bar/789/permanent");
}
@Test
@@ -79,7 +79,7 @@
Map<String, Object> m = Maps.newHashMap();
m.put("one", 1);
m.put("six", 6);
- Assert.assertEquals(spec.build(m), "1two-three-{four}-five6");
+ assertEquals(spec.build(m), "1two-three-{four}-five6");
}
@Test
@@ -97,7 +97,7 @@
private void checkPart(UriSpec.Part p, String value, boolean isVariable)
{
- Assert.assertEquals(p.getValue(), value);
- Assert.assertEquals(p.isVariable(), isVariable);
+ assertEquals(p.getValue(), value);
+ assertEquals(p.isVariable(), isVariable);
}
}
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestDownInstanceManager.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestDownInstanceManager.java
index 0b60655..73b2038 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestDownInstanceManager.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestDownInstanceManager.java
@@ -18,10 +18,11 @@
*/
package org.apache.curator.x.discovery.details;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.curator.x.discovery.DownInstancePolicy;
import org.apache.curator.x.discovery.ServiceInstance;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeUnit;
public class TestDownInstanceManager
@@ -36,12 +37,12 @@
ServiceInstance<Void> instance2 = ServiceInstance.<Void>builder().name("hey").id("2").build();
DownInstanceManager<Void> downInstanceManager = new DownInstanceManager<Void>(debugDownInstancePolicy);
- Assert.assertTrue(downInstanceManager.apply(instance1));
- Assert.assertTrue(downInstanceManager.apply(instance2));
+ assertTrue(downInstanceManager.apply(instance1));
+ assertTrue(downInstanceManager.apply(instance2));
downInstanceManager.add(instance1);
- Assert.assertFalse(downInstanceManager.apply(instance1));
- Assert.assertTrue(downInstanceManager.apply(instance2));
+ assertFalse(downInstanceManager.apply(instance1));
+ assertTrue(downInstanceManager.apply(instance2));
}
@Test
@@ -51,16 +52,16 @@
ServiceInstance<Void> instance2 = ServiceInstance.<Void>builder().name("hey").id("2").build();
DownInstanceManager<Void> downInstanceManager = new DownInstanceManager<Void>(debugMultiDownInstancePolicy);
- Assert.assertTrue(downInstanceManager.apply(instance1));
- Assert.assertTrue(downInstanceManager.apply(instance2));
+ assertTrue(downInstanceManager.apply(instance1));
+ assertTrue(downInstanceManager.apply(instance2));
downInstanceManager.add(instance1);
- Assert.assertTrue(downInstanceManager.apply(instance1));
- Assert.assertTrue(downInstanceManager.apply(instance2));
+ assertTrue(downInstanceManager.apply(instance1));
+ assertTrue(downInstanceManager.apply(instance2));
downInstanceManager.add(instance1);
- Assert.assertFalse(downInstanceManager.apply(instance1));
- Assert.assertTrue(downInstanceManager.apply(instance2));
+ assertFalse(downInstanceManager.apply(instance1));
+ assertTrue(downInstanceManager.apply(instance2));
}
@Test
@@ -72,12 +73,12 @@
DownInstanceManager<Void> downInstanceManager = new DownInstanceManager<Void>(debugDownInstancePolicy);
downInstanceManager.add(instance1);
- Assert.assertFalse(downInstanceManager.apply(instance1));
- Assert.assertTrue(downInstanceManager.apply(instance2));
+ assertFalse(downInstanceManager.apply(instance1));
+ assertTrue(downInstanceManager.apply(instance2));
Thread.sleep(debugDownInstancePolicy.getTimeoutMs());
- Assert.assertTrue(downInstanceManager.apply(instance1));
- Assert.assertTrue(downInstanceManager.apply(instance2));
+ assertTrue(downInstanceManager.apply(instance1));
+ assertTrue(downInstanceManager.apply(instance2));
}
}
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java
index 100e41d..1ceb9db 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java
@@ -19,14 +19,16 @@
package org.apache.curator.x.discovery.details;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.curator.x.discovery.ServiceType;
import org.apache.curator.x.discovery.TestJsonInstanceSerializer;
import org.apache.curator.x.discovery.UriSpec;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.net.URI;
import java.util.Date;
@@ -42,7 +44,7 @@
OldServiceInstance<TestJsonInstanceSerializer.Payload> oldInstance = new OldServiceInstance<TestJsonInstanceSerializer.Payload>("name", "id", "address", 10, 20, new TestJsonInstanceSerializer.Payload("test"), 0, ServiceType.DYNAMIC, new UriSpec("{a}/b/{c}"));
ObjectMapper mapper = new ObjectMapper();
byte[] oldBytes = mapper.writeValueAsBytes(oldInstance);
- Assert.assertEquals(bytes, oldBytes, String.format("%s vs %s", new String(bytes), new String(oldBytes)));
+ assertArrayEquals(bytes, oldBytes, String.format("%s vs %s", new String(bytes), new String(oldBytes)));
}
@Test
@@ -53,7 +55,7 @@
byte[] bytes = serializer.serialize(instance);
instance = serializer.deserialize(bytes);
- Assert.assertTrue(instance.isEnabled()); // passed false for enabled in the ctor but that is lost with compatibleSerializationMode
+ assertTrue(instance.isEnabled()); // passed false for enabled in the ctor but that is lost with compatibleSerializationMode
ObjectMapper mapper = new ObjectMapper();
JavaType type = mapper.getTypeFactory().constructType(OldServiceInstance.class);
@@ -61,15 +63,15 @@
TestJsonInstanceSerializer.Payload.class.cast(rawServiceInstance.getPayload()); // just to verify that it's the correct type
//noinspection unchecked
OldServiceInstance<TestJsonInstanceSerializer.Payload> check = (OldServiceInstance<TestJsonInstanceSerializer.Payload>)rawServiceInstance;
- Assert.assertEquals(check.getName(), instance.getName());
- Assert.assertEquals(check.getId(), instance.getId());
- Assert.assertEquals(check.getAddress(), instance.getAddress());
- Assert.assertEquals(check.getPort(), instance.getPort());
- Assert.assertEquals(check.getSslPort(), instance.getSslPort());
- Assert.assertEquals(check.getPayload(), instance.getPayload());
- Assert.assertEquals(check.getRegistrationTimeUTC(), instance.getRegistrationTimeUTC());
- Assert.assertEquals(check.getServiceType(), instance.getServiceType());
- Assert.assertEquals(check.getUriSpec(), instance.getUriSpec());
+ assertEquals(check.getName(), instance.getName());
+ assertEquals(check.getId(), instance.getId());
+ assertEquals(check.getAddress(), instance.getAddress());
+ assertEquals(check.getPort(), instance.getPort());
+ assertEquals(check.getSslPort(), instance.getSslPort());
+ assertEquals(check.getPayload(), instance.getPayload());
+ assertEquals(check.getRegistrationTimeUTC(), instance.getRegistrationTimeUTC());
+ assertEquals(check.getServiceType(), instance.getServiceType());
+ assertEquals(check.getUriSpec(), instance.getUriSpec());
}
@Test
@@ -81,16 +83,16 @@
JsonInstanceSerializer<TestJsonInstanceSerializer.Payload> serializer = new JsonInstanceSerializer<TestJsonInstanceSerializer.Payload>(TestJsonInstanceSerializer.Payload.class);
ServiceInstance<TestJsonInstanceSerializer.Payload> instance = serializer.deserialize(oldJson);
- Assert.assertEquals(oldInstance.getName(), instance.getName());
- Assert.assertEquals(oldInstance.getId(), instance.getId());
- Assert.assertEquals(oldInstance.getAddress(), instance.getAddress());
- Assert.assertEquals(oldInstance.getPort(), instance.getPort());
- Assert.assertEquals(oldInstance.getSslPort(), instance.getSslPort());
- Assert.assertEquals(oldInstance.getPayload(), instance.getPayload());
- Assert.assertEquals(oldInstance.getRegistrationTimeUTC(), instance.getRegistrationTimeUTC());
- Assert.assertEquals(oldInstance.getServiceType(), instance.getServiceType());
- Assert.assertEquals(oldInstance.getUriSpec(), instance.getUriSpec());
- Assert.assertTrue(instance.isEnabled());
+ assertEquals(oldInstance.getName(), instance.getName());
+ assertEquals(oldInstance.getId(), instance.getId());
+ assertEquals(oldInstance.getAddress(), instance.getAddress());
+ assertEquals(oldInstance.getPort(), instance.getPort());
+ assertEquals(oldInstance.getSslPort(), instance.getSslPort());
+ assertEquals(oldInstance.getPayload(), instance.getPayload());
+ assertEquals(oldInstance.getRegistrationTimeUTC(), instance.getRegistrationTimeUTC());
+ assertEquals(oldInstance.getServiceType(), instance.getServiceType());
+ assertEquals(oldInstance.getUriSpec(), instance.getUriSpec());
+ assertTrue(instance.isEnabled());
}
@Test
@@ -100,8 +102,8 @@
byte[] newInstanceBytes = new ObjectMapper().writeValueAsBytes(newInstance);
JsonInstanceSerializer<String> serializer = new JsonInstanceSerializer<String>(String.class);
ServiceInstance<String> instance = serializer.deserialize(newInstanceBytes);
- Assert.assertEquals(instance.getName(), "name");
- Assert.assertEquals(instance.getPayload(), "hey");
- Assert.assertEquals(instance.isEnabled(), false);
+ assertEquals(instance.getName(), "name");
+ assertEquals(instance.getPayload(), "hey");
+ assertEquals(instance.isEnabled(), false);
}
}
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceCacheRace.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceCacheRace.java
index 9604c19..b6fdbc0 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceCacheRace.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceCacheRace.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.x.discovery.details;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -32,16 +33,16 @@
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
import org.apache.curator.x.discovery.ServiceInstance;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.io.Closeable;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestServiceCacheRace extends BaseClassForTests
{
private final Timing timing = new Timing();
@@ -92,7 +93,7 @@
}
};
closeableExecutorService.submit(proc);
- Assert.assertTrue(timing.awaitLatch(cacheStartLatch)); // wait until ServiceCacheImpl's internal PathChildrenCache is started and primed
+ assertTrue(timing.awaitLatch(cacheStartLatch)); // wait until ServiceCacheImpl's internal PathChildrenCache is started and primed
final CountDownLatch cacheChangedLatch = new CountDownLatch(1);
ServiceCacheListener listener = new ServiceCacheListener()
@@ -112,11 +113,11 @@
cache.addListener(listener);
ServiceInstance<String> instance2 = ServiceInstance.<String>builder().payload("test").name("test").port(10065).build();
discovery.registerService(instance2); // cause ServiceCacheImpl's internal PathChildrenCache listener to get called which will clear the dataBytes
- Assert.assertTrue(timing.awaitLatch(cacheChangedLatch));
+ assertTrue(timing.awaitLatch(cacheChangedLatch));
cacheWaitLatch.countDown();
- Assert.assertTrue(timing.awaitLatch(startCompletedLatch));
+ assertTrue(timing.awaitLatch(startCompletedLatch));
}
finally
{
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java
index 7a23e16..f56acaa 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java
@@ -19,6 +19,9 @@
package org.apache.curator.x.discovery.details;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.curator.framework.CuratorFramework;
@@ -31,15 +34,16 @@
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
import org.apache.curator.x.discovery.ServiceInstance;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestServiceDiscovery extends BaseClassForTests
{
private static final Comparator<ServiceInstance<Void>> comparator = new Comparator<ServiceInstance<Void>>()
@@ -78,7 +82,7 @@
discovery.registerService(instance2);
timing.acquireSemaphore(semaphore, 2);
- Assert.assertEquals(discovery.queryForInstances("test").size(), 2);
+ assertEquals(discovery.queryForInstances("test").size(), 2);
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
server.stop();
@@ -86,7 +90,7 @@
server.restart();
timing.acquireSemaphore(semaphore, 2);
- Assert.assertEquals(discovery.queryForInstances("test").size(), 2);
+ assertEquals(discovery.queryForInstances("test").size(), 2);
}
finally
{
@@ -120,7 +124,7 @@
discovery.start();
timing.acquireSemaphore(semaphore);
- Assert.assertEquals(discovery.queryForInstances("test").size(), 1);
+ assertEquals(discovery.queryForInstances("test").size(), 1);
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
server.stop();
@@ -128,7 +132,7 @@
server.restart();
timing.acquireSemaphore(semaphore);
- Assert.assertEquals(discovery.queryForInstances("test").size(), 1);
+ assertEquals(discovery.queryForInstances("test").size(), 1);
}
finally
{
@@ -153,12 +157,12 @@
discovery = new ServiceDiscoveryImpl<String>(client, "/test", new JsonInstanceSerializer<String>(String.class), instance, false);
discovery.start();
- Assert.assertEquals(discovery.queryForInstances("test").size(), 1);
+ assertEquals(discovery.queryForInstances("test").size(), 1);
client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration();
Thread.sleep(timing.multiple(1.5).session());
- Assert.assertEquals(discovery.queryForInstances("test").size(), 1);
+ assertEquals(discovery.queryForInstances("test").size(), 1);
}
finally
{
@@ -193,7 +197,7 @@
discovery.registerService(s2_i1);
discovery.registerService(s2_i2);
- Assert.assertEquals(Sets.newHashSet(discovery.queryForNames()), Sets.newHashSet(SERVICE_ONE, SERVICE_TWO));
+ assertEquals(Sets.newHashSet(discovery.queryForNames()), Sets.newHashSet(SERVICE_ONE, SERVICE_TWO));
List<ServiceInstance<Void>> list = Lists.newArrayList();
list.add(s1_i1);
@@ -201,7 +205,7 @@
Collections.sort(list, comparator);
List<ServiceInstance<Void>> queriedInstances = Lists.newArrayList(discovery.queryForInstances(SERVICE_ONE));
Collections.sort(queriedInstances, comparator);
- Assert.assertEquals(queriedInstances, list, String.format("Not equal l: %s - d: %s", list, queriedInstances));
+ assertEquals(queriedInstances, list, String.format("Not equal l: %s - d: %s", list, queriedInstances));
list.clear();
@@ -210,7 +214,7 @@
Collections.sort(list, comparator);
queriedInstances = Lists.newArrayList(discovery.queryForInstances(SERVICE_TWO));
Collections.sort(queriedInstances, comparator);
- Assert.assertEquals(queriedInstances, list, String.format("Not equal 2: %s - d: %s", list, queriedInstances));
+ assertEquals(queriedInstances, list, String.format("Not equal 2: %s - d: %s", list, queriedInstances));
}
finally
{
@@ -233,11 +237,11 @@
discovery = ServiceDiscoveryBuilder.builder(String.class).basePath("/test").client(client).thisInstance(instance).build();
discovery.start();
- Assert.assertEquals(discovery.queryForNames(), Collections.singletonList("test"));
+ assertEquals(discovery.queryForNames(), Collections.singletonList("test"));
List<ServiceInstance<String>> list = Lists.newArrayList();
list.add(instance);
- Assert.assertEquals(discovery.queryForInstances("test"), list);
+ assertEquals(discovery.queryForInstances("test"), list);
}
finally
{
@@ -265,11 +269,11 @@
server.restart();
timing.sleepABit();
- Assert.assertEquals(discovery.queryForNames(), Collections.singletonList("test"));
+ assertEquals(discovery.queryForNames(), Collections.singletonList("test"));
List<ServiceInstance<String>> list = Lists.newArrayList();
list.add(instance);
- Assert.assertEquals(discovery.queryForInstances("test"), list);
+ assertEquals(discovery.queryForInstances("test"), list);
}
finally
{
@@ -320,7 +324,7 @@
discovery = ServiceDiscoveryBuilder.builder(String.class).basePath("/test").client(client).thisInstance(instance).serializer(slowSerializer).watchInstances(true).build();
discovery.start();
- Assert.assertFalse(discovery.queryForInstances(name).isEmpty(), "Service should start registered.");
+ assertFalse(discovery.queryForInstances(name).isEmpty(), "Service should start registered.");
server.stop();
server.restart();
@@ -330,7 +334,7 @@
new Timing().sleepABit(); // Wait for the rest of registration to finish.
- Assert.assertTrue(discovery.queryForInstances(name).isEmpty(), "Service should have unregistered.");
+ assertTrue(discovery.queryForInstances(name).isEmpty(), "Service should have unregistered.");
}
finally
{
@@ -354,7 +358,7 @@
discovery.start();
discovery.unregisterService(instance);
- Assert.assertEquals(((ServiceDiscoveryImpl)discovery).debugServicesQty(), 0);
+ assertEquals(((ServiceDiscoveryImpl)discovery).debugServicesQty(), 0);
}
finally
{
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscoveryBuilder.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscoveryBuilder.java
index fd0c438..d88b3c4 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscoveryBuilder.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscoveryBuilder.java
@@ -18,6 +18,10 @@
*/
package org.apache.curator.x.discovery.details;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
@@ -25,10 +29,10 @@
import org.apache.curator.test.compatibility.CuratorTestBase;
import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
import org.apache.curator.x.discovery.ServiceInstance;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestServiceDiscoveryBuilder extends BaseClassForTests
{
@Test
@@ -38,8 +42,8 @@
ServiceDiscoveryBuilder<Object> builder = ServiceDiscoveryBuilder.builder(Object.class).client(client);
ServiceDiscoveryImpl<?> discovery = (ServiceDiscoveryImpl<?>) builder.basePath("/path").build();
- Assert.assertNotNull(discovery.getSerializer(), "default serializer not set");
- Assert.assertTrue(discovery.getSerializer() instanceof JsonInstanceSerializer, "default serializer not JSON");
+ assertNotNull(discovery.getSerializer(), "default serializer not set");
+ assertTrue(discovery.getSerializer() instanceof JsonInstanceSerializer, "default serializer not JSON");
}
@Test
@@ -63,7 +67,7 @@
});
ServiceDiscoveryImpl<?> discovery = (ServiceDiscoveryImpl<?>) builder.basePath("/path").build();
- Assert.assertNotNull(discovery.getSerializer(), "default serializer not set");
- Assert.assertFalse(discovery.getSerializer() instanceof JsonInstanceSerializer, "set serializer is JSON");
+ assertNotNull(discovery.getSerializer(), "default serializer not set");
+ assertFalse(discovery.getSerializer() instanceof JsonInstanceSerializer, "set serializer is JSON");
}
}
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceProvider.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceProvider.java
index b743e07..033e8fa 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceProvider.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceProvider.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.x.discovery.details;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.Closeable;
import java.util.Collections;
import java.util.List;
@@ -32,12 +34,11 @@
import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.curator.x.discovery.ServiceProvider;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
import com.google.common.collect.Lists;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Test(groups = CuratorTestBase.zk35TestCompatibilityGroup)
+@Tag(CuratorTestBase.zk35TestCompatibilityGroup)
public class TestServiceProvider extends BaseClassForTests
{
@@ -60,11 +61,11 @@
closeables.add(provider);
provider.start();
- Assert.assertEquals(provider.getInstance(), instance);
+ assertEquals(provider.getInstance(), instance);
List<ServiceInstance<String>> list = Lists.newArrayList();
list.add(instance);
- Assert.assertEquals(provider.getAllInstances(), list);
+ assertEquals(provider.getAllInstances(), list);
}
finally
{
@@ -96,8 +97,8 @@
closeables.add(provider);
provider.start();
- Assert.assertEquals(provider.getInstance(), null);
- Assert.assertTrue(provider.getAllInstances().isEmpty(), "Disabled instance still appears available via service provider");
+ assertEquals(provider.getInstance(), null);
+ assertTrue(provider.getAllInstances().isEmpty(), "Disabled instance still appears available via service provider");
}
finally
{
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestWatchedInstances.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestWatchedInstances.java
index 2d03c47..6c4d29f 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestWatchedInstances.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestWatchedInstances.java
@@ -18,6 +18,8 @@
*/
package org.apache.curator.x.discovery.details;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -28,8 +30,8 @@
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
import org.apache.curator.x.discovery.ServiceInstance;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
import java.io.Closeable;
import java.util.Arrays;
import java.util.Collections;
@@ -59,11 +61,11 @@
closeables.add(discovery);
discovery.start();
- Assert.assertEquals(discovery.queryForNames(), Arrays.asList("test"));
+ assertEquals(discovery.queryForNames(), Arrays.asList("test"));
List<ServiceInstance<String>> list = Lists.newArrayList();
list.add(instance);
- Assert.assertEquals(discovery.queryForInstances("test"), list);
+ assertEquals(discovery.queryForInstances("test"), list);
ServiceDiscoveryImpl<String> discoveryImpl = (ServiceDiscoveryImpl<String>)discovery;
ServiceInstance<String> changedInstance = ServiceInstance.<String>builder()
@@ -79,8 +81,8 @@
timing.sleepABit();
ServiceInstance<String> registeredService = discoveryImpl.getRegisteredService(instance.getId());
- Assert.assertNotNull(registeredService);
- Assert.assertEquals(registeredService.getPayload(), "different");
+ assertNotNull(registeredService);
+ assertEquals(registeredService.getPayload(), "different");
}
finally
{
diff --git a/pom.xml b/pom.xml
index 942dac8..b3949fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,6 +52,11 @@
</organization>
<properties>
+ <!-- maven properties -->
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <dependency.locations.enabled>false</dependency.locations.enabled>
+
<currentStableVersion>5.1.0</currentStableVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -85,7 +90,7 @@
<guava-version>27.0.1-jre</guava-version>
<guava-listenablefuture-version>1.0</guava-listenablefuture-version>
<guava-failureaccess-version>1.0.1</guava-failureaccess-version>
- <testng-version>6.14.3</testng-version>
+ <junit-version>5.6.2</junit-version>
<swift-version>0.23.1</swift-version>
<maven-shade-plugin-version>3.2.1</maven-shade-plugin-version>
<slf4j-version>1.7.25</slf4j-version>
@@ -568,9 +573,15 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>${testng-version}</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>${junit-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junit-version}</version>
</dependency>
<dependency>
@@ -658,6 +669,12 @@
</plugin>
<plugin>
+ <groupId>org.commonjava.maven.plugins</groupId>
+ <artifactId>directory-maven-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+
+ <plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>${maven-license-plugin-version}</version>
@@ -691,6 +708,12 @@
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin-version}</version>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.1</version>
+ </plugin>
</plugins>
</pluginManagement>
@@ -745,10 +768,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <version>3.0.0-M5</version>
<configuration>
<threadCount>1</threadCount>
<reuseForks>false</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <rerunFailingTestsCount>2</rerunFailingTestsCount>
</configuration>
</plugin>
@@ -807,11 +832,30 @@
</executions>
</plugin>
+ <!-- Directory plugin to find parent root directory absolute path -->
+ <plugin>
+ <groupId>org.commonjava.maven.plugins</groupId>
+ <artifactId>directory-maven-plugin</artifactId>
+ <version>0.1</version>
+ <executions>
+ <execution>
+ <id>directories</id>
+ <goals>
+ <goal>highest-basedir</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <property>main.basedir</property>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<configuration>
- <header>src/etc/header.txt</header>
+ <header>${main.basedir}/src/etc/header.txt</header>
<excludes>
<exclude>**/*.confluence</exclude>
<exclude>**/*.confluence.vm</exclude>
@@ -996,6 +1040,12 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.1</version>
+ </plugin>
</plugins>
</build>