use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class BounceProxyEhcacheAdapterTest method testUpdateChannelAssignmentForAlreadyAssignedChannel.
@Test
public void testUpdateChannelAssignmentForAlreadyAssignedChannel() {
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
cache.addBounceProxy(bpInfo1);
cache.updateChannelAssignment("channel-123", bpInfo1);
List<BounceProxyStatusInformation> assignableBounceProxies = cache.getBounceProxyStatusInformation();
assertEquals(1, assignableBounceProxies.size());
BounceProxyRecord bpRecord1 = cache.getBounceProxy("bp1.0");
assertEquals("bp1.0", bpRecord1.getBounceProxyId());
assertEquals(1, bpRecord1.getNumberOfAssignedChannels());
cache.updateChannelAssignment("channel-123", bpInfo1);
bpRecord1 = cache.getBounceProxy("bp1.0");
assertEquals("bp1.0", bpRecord1.getBounceProxyId());
assertEquals(1, bpRecord1.getNumberOfAssignedChannels());
}
use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class BounceProxyEhcacheAdapterTest method testGetAssignableBounceProxies.
@Test
public void testGetAssignableBounceProxies() {
List<BounceProxyRecord> assignableBounceProxies = cache.getAssignableBounceProxies();
assertEquals(0, assignableBounceProxies.size());
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
cache.addBounceProxy(bpInfo1);
assignableBounceProxies = cache.getAssignableBounceProxies();
assertEquals(1, assignableBounceProxies.size());
for (BounceProxyStatus status : BounceProxyStatus.values()) {
BounceProxyRecord bpRecord = new BounceProxyRecord(bpInfo1);
bpRecord.setStatus(status);
cache.updateBounceProxy(bpRecord);
assignableBounceProxies = cache.getAssignableBounceProxies();
if (status.isAssignable()) {
assertEquals(1, assignableBounceProxies.size());
} else {
assertEquals(0, assignableBounceProxies.size());
}
}
}
use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class DatabasesTest method testGetAssignableBounceProxies.
@Test
public void testGetAssignableBounceProxies() {
List<BounceProxyRecord> assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
Assert.assertEquals(0, assignableBounceProxies.size());
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
bounceProxyDb.addBounceProxy(bpInfo1);
assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
Assert.assertEquals(1, assignableBounceProxies.size());
for (BounceProxyStatus status : BounceProxyStatus.values()) {
BounceProxyRecord bpRecord = new BounceProxyRecord(bpInfo1);
bpRecord.setStatus(status);
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(2000l);
bounceProxyDb.updateBounceProxy(bpRecord);
assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
if (status.isAssignable()) {
Assert.assertEquals(1, assignableBounceProxies.size());
} else {
Assert.assertEquals(0, assignableBounceProxies.size());
}
}
}
use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class DatabasesTest method testUpdateChannelAssignmentForUnknownChannel.
@Test
public void testUpdateChannelAssignmentForUnknownChannel() {
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
bounceProxyDb.addBounceProxy(bpInfo1);
try {
bounceProxyDb.updateChannelAssignment("channel-123", bpInfo1);
Assert.fail();
} catch (IllegalArgumentException e) {
}
}
use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class DatabasesTest method testAddBounceProxies.
@Test
public void testAddBounceProxies() {
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
bounceProxyDb.addBounceProxy(bpInfo1);
List<BounceProxyRecord> assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
Assert.assertEquals(1, assignableBounceProxies.size());
Assert.assertTrue(bounceProxyDb.containsBounceProxy("bp1.0"));
Assert.assertFalse(bounceProxyDb.containsBounceProxy("bp2.0"));
BounceProxyRecord bpRecord1 = bounceProxyDb.getBounceProxy("bp1.0");
Assert.assertEquals("bp1.0", bpRecord1.getBounceProxyId());
Assert.assertEquals("http://www.joynr1.de/bp1/", bpRecord1.getInfo().getLocation().toString());
Assert.assertEquals(0, bpRecord1.getNumberOfAssignedChannels());
Assert.assertEquals(BounceProxyRecord.ASSIGNMENT_TIMESTAMP_NEVER, bpRecord1.getLastAssignedTimestamp());
Assert.assertEquals(1000l, bpRecord1.getFreshness().getTime());
Assert.assertEquals(BounceProxyStatus.ALIVE, bpRecord1.getStatus());
ControlledBounceProxyInformation bpInfo2 = new ControlledBounceProxyInformation("bp2.0", URI.create("http://www.joynr2.de/bp2/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(2000l);
bounceProxyDb.addBounceProxy(bpInfo2);
assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
Assert.assertEquals(2, assignableBounceProxies.size());
Assert.assertTrue(bounceProxyDb.containsBounceProxy("bp1.0"));
Assert.assertTrue(bounceProxyDb.containsBounceProxy("bp2.0"));
BounceProxyRecord bpRecord2 = bounceProxyDb.getBounceProxy("bp2.0");
Assert.assertEquals("bp2.0", bpRecord2.getBounceProxyId());
Assert.assertEquals("http://www.joynr2.de/bp2/", bpRecord2.getInfo().getLocation().toString());
Assert.assertEquals(0, bpRecord2.getNumberOfAssignedChannels());
Assert.assertEquals(BounceProxyRecord.ASSIGNMENT_TIMESTAMP_NEVER, bpRecord2.getLastAssignedTimestamp());
Assert.assertEquals(2000l, bpRecord2.getFreshness().getTime());
Assert.assertEquals(BounceProxyStatus.ALIVE, bpRecord2.getStatus());
}
Aggregations