}
@Test
public void testWithNamespace() throws Exception
{
CuratorFramework client = CuratorFrameworkFactory.builder().connectString(server.getConnectString()).retryPolicy(new RetryOneTime(1)).namespace("galt").build();
client.start();
try
{
Collection<CuratorTransactionResult> results =
client.inTransaction()
.create().forPath("/foo", "one".getBytes())
.and()
.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/test-", "one".getBytes())
.and()
.setData().forPath("/foo", "two".getBytes())
.and()
.create().forPath("/foo/bar")
.and()
.delete().forPath("/foo/bar")
.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);
CuratorTransactionResult ephemeralResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
Assert.assertNotNull(ephemeralResult);
Assert.assertNotEquals(ephemeralResult.getResultPath(), "/test-");
Assert.assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
}
finally
{
client.close();
}
}