use of org.apache.curator.framework.api.ACLBackgroundPathAndBytesable in project heron by twitter.
the class CuratorStateManagerTest method testCreateNode.
/**
* test createNode method
* @throws Exception
*/
@Test
public void testCreateNode() throws Exception {
CuratorStateManager spyStateManager = spy(new CuratorStateManager());
CuratorFramework mockClient = mock(CuratorFramework.class);
CreateBuilder mockCreateBuilder = mock(CreateBuilder.class);
// Mockito doesn't support mock type-parametrized class, thus suppress the warning
@SuppressWarnings("rawtypes") ACLBackgroundPathAndBytesable mockPath = spy(ACLBackgroundPathAndBytesable.class);
final byte[] data = new byte[10];
doReturn(mockClient).when(spyStateManager).getCuratorClient();
doReturn(true).when(mockClient).blockUntilConnected(anyInt(), any(TimeUnit.class));
doReturn(mockCreateBuilder).when(mockClient).create();
doReturn(mockPath).when(mockCreateBuilder).withMode(any(CreateMode.class));
spyStateManager.initialize(config);
// Verify the node is created successfully
ListenableFuture<Boolean> result = spyStateManager.createNode(PATH, data, false);
verify(mockCreateBuilder).withMode(any(CreateMode.class));
verify(mockPath).forPath(PATH, data);
assertTrue(result.get());
}
use of org.apache.curator.framework.api.ACLBackgroundPathAndBytesable in project incubator-heron by apache.
the class CuratorStateManagerTest method testCreateNode.
/**
* test createNode method
* @throws Exception
*/
@Test
public void testCreateNode() throws Exception {
CuratorStateManager spyStateManager = spy(new CuratorStateManager());
CuratorFramework mockClient = mock(CuratorFramework.class);
CreateBuilder mockCreateBuilder = mock(CreateBuilder.class);
// Mockito doesn't support mock type-parametrized class, thus suppress the warning
@SuppressWarnings("rawtypes") ACLBackgroundPathAndBytesable mockPath = spy(ACLBackgroundPathAndBytesable.class);
final byte[] data = new byte[10];
doReturn(mockClient).when(spyStateManager).getCuratorClient();
doReturn(true).when(mockClient).blockUntilConnected(anyInt(), any(TimeUnit.class));
doReturn(mockCreateBuilder).when(mockClient).create();
doReturn(mockPath).when(mockCreateBuilder).withMode(any(CreateMode.class));
spyStateManager.initialize(config);
// Verify the node is created successfully
ListenableFuture<Boolean> result = spyStateManager.createNode(PATH, data, false);
verify(mockCreateBuilder).withMode(any(CreateMode.class));
verify(mockPath).forPath(PATH, data);
assertTrue(result.get());
}
use of org.apache.curator.framework.api.ACLBackgroundPathAndBytesable in project heron by twitter.
the class CuratorStateManagerTest method testCreateNode.
/**
* test createNode method
* @throws Exception
*/
@Test
public void testCreateNode() throws Exception {
CuratorStateManager spyStateManager = spy(new CuratorStateManager());
CuratorFramework mockClient = mock(CuratorFramework.class);
CreateBuilder mockCreateBuilder = mock(CreateBuilder.class);
// Mockito doesn't support mock type-parametrized class, thus suppress the warning
@SuppressWarnings("rawtypes") ACLBackgroundPathAndBytesable mockPath = spy(ACLBackgroundPathAndBytesable.class);
final byte[] data = new byte[10];
doReturn(mockClient).when(spyStateManager).getCuratorClient();
doReturn(true).when(mockClient).blockUntilConnected(anyInt(), any(TimeUnit.class));
doReturn(mockCreateBuilder).when(mockClient).create();
doReturn(mockPath).when(mockCreateBuilder).withMode(any(CreateMode.class));
spyStateManager.initialize(config);
// Verify the node is created successfully
ListenableFuture<Boolean> result = spyStateManager.createNode(PATH, data, false);
verify(mockCreateBuilder).withMode(any(CreateMode.class));
verify(mockPath).forPath(PATH, data);
assertTrue(result.get());
}
Aggregations