Search in sources :

Example 1 with NodePath

use of org.talend.esb.servicelocator.client.internal.NodePath in project tesb-rt-se by Talend.

the class EndpointNodeTest method getExpiryTimeMissingNode.

@Test
public void getExpiryTimeMissingNode() throws Exception {
    NodePath expiryPath = endpointNode.child(TIMETOLIVE);
    expect(backend.nodeExists(expiryPath)).andReturn(false);
    replay(backend);
    Date answer = endpointNode.getExpiryTime();
    assertNull(answer);
    verify(backend);
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Date(java.util.Date) Test(org.junit.Test)

Example 2 with NodePath

use of org.talend.esb.servicelocator.client.internal.NodePath in project tesb-rt-se by Talend.

the class EndpointNodeTest method setLivePersistent.

@Test
public void setLivePersistent() throws Exception {
    NodePath livePath = endpointNode.child(LIVE);
    backend.ensurePathExists(livePath, CreateMode.PERSISTENT);
    backend.ensurePathDeleted(endpointNode.child(TIMETOLIVE), false);
    replay(backend);
    endpointNode.setLive(true);
    verify(backend);
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Test(org.junit.Test)

Example 3 with NodePath

use of org.talend.esb.servicelocator.client.internal.NodePath in project tesb-rt-se by Talend.

the class EndpointNodeTest method setExpiryTime.

@Test
public void setExpiryTime() throws Exception {
    final Date expiryTime = new Date();
    NodePath expiryPath = endpointNode.child(TIMETOLIVE);
    backend.ensurePathExists(eq(expiryPath), eq(CreateMode.PERSISTENT), anyObject(byte[].class));
    replay(backend);
    endpointNode.setExpiryTime(expiryTime, true);
    verify(backend);
}
Also used : Date(java.util.Date) NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Test(org.junit.Test)

Example 4 with NodePath

use of org.talend.esb.servicelocator.client.internal.NodePath in project tesb-rt-se by Talend.

the class EndpointNodeTest method ensureRemoved.

@Test
public void ensureRemoved() throws Exception {
    NodePath livePath = endpointNode.child(LIVE);
    NodePath expiryPath = endpointNode.child(TIMETOLIVE);
    backend.ensurePathDeleted(livePath, false);
    backend.ensurePathDeleted(expiryPath, false);
    backend.ensurePathDeleted(endpointNode, true);
    replay(backend);
    endpointNode.ensureRemoved();
    verify(backend);
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Test(org.junit.Test)

Example 5 with NodePath

use of org.talend.esb.servicelocator.client.internal.NodePath in project tesb-rt-se by Talend.

the class EndpointNodeTest method getExpiryTime.

@Test
public void getExpiryTime() throws Exception {
    final Date expected = new Date();
    NodePath expiryPath = endpointNode.child(TIMETOLIVE);
    expect(backend.nodeExists(expiryPath)).andReturn(true);
    expect(backend.getContent(expiryPath)).andReturn(getDateBytes(expected));
    replay(backend);
    Date answer = endpointNode.getExpiryTime();
    assertEquals(expected, answer);
    verify(backend);
}
Also used : Date(java.util.Date) NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Test(org.junit.Test)

Aggregations

NodePath (org.talend.esb.servicelocator.client.internal.NodePath)13 Test (org.junit.Test)9 Date (java.util.Date)4 CreateMode (org.apache.zookeeper.CreateMode)2