Moar unit tests

This commit is contained in:
cheddar 2013-04-26 18:46:07 -05:00
parent 8768406069
commit 74ff07ba3e
2 changed files with 18 additions and 18 deletions

View File

@ -73,13 +73,13 @@ public class AnnouncerTest extends CuratorTestBase
announcer.start();
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
Assert.assertNull(curator.checkExists().forPath(testPath2));
announcer.announce(testPath2, billy);
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
final CountDownLatch latch = new CountDownLatch(1);
curator.getCuratorListenable().addListener(
@ -88,21 +88,21 @@ public class AnnouncerTest extends CuratorTestBase
@Override
public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
{
if (event.getType() == CuratorEventType.DELETE && event.getPath().equals(testPath1)) {
if (event.getType() == CuratorEventType.CREATE && event.getPath().equals(testPath1)) {
latch.countDown();
}
}
}
);
curator.delete().forPath(testPath1);
timing.awaitLatch(latch);
Assert.assertTrue(timing.awaitLatch(latch));
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
announcer.unannounce(testPath1);
Assert.assertNull(curator.checkExists().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
announcer.stop();
@ -128,8 +128,8 @@ public class AnnouncerTest extends CuratorTestBase
announcer.announce(testPath1, billy);
announcer.announce(testPath2, billy);
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
final CountDownLatch latch = new CountDownLatch(1);
curator.getCuratorListenable().addListener(
@ -149,10 +149,10 @@ public class AnnouncerTest extends CuratorTestBase
);
KillSession.kill(curator.getZookeeperClient().getZooKeeper(), server.getConnectString());
timing.awaitLatch(latch);
Assert.assertTrue(timing.awaitLatch(latch));
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
announcer.stop();

View File

@ -52,7 +52,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
strategy.setNewContainerLatch(containerLatch);
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/container/billy", new byte[]{});
timing.awaitLatch(containerLatch);
Assert.assertTrue(timing.awaitLatch(containerLatch));
strategy.setNewContainerLatch(null);
final Iterable<Map<String, Integer>> inventory = manager.getInventory();
@ -63,7 +63,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/1", Ints.toByteArray(100));
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/bob", Ints.toByteArray(2287));
timing.awaitLatch(inventoryLatch);
Assert.assertTrue(timing.awaitLatch(inventoryLatch));
strategy.setNewInventoryLatch(null);
verifyInventory(manager);
@ -72,7 +72,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
strategy.setDeadInventoryLatch(deleteLatch);
curator.delete().forPath("/inventory/billy/1");
timing.awaitLatch(deleteLatch);
Assert.assertTrue(timing.awaitLatch(deleteLatch));
strategy.setDeadInventoryLatch(null);
Assert.assertEquals(1, manager.getInventoryValue("billy").size());
@ -82,7 +82,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
strategy.setNewInventoryLatch(inventoryLatch);
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/1", Ints.toByteArray(100));
timing.awaitLatch(inventoryLatch);
Assert.assertTrue(timing.awaitLatch(inventoryLatch));
strategy.setNewInventoryLatch(null);
verifyInventory(manager);
@ -104,7 +104,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
);
server.stop();
timing.awaitLatch(latch);
Assert.assertTrue(timing.awaitLatch(latch));
verifyInventory(manager);