use of io.joynr.messaging.info.BounceProxyStatusInformation in project joynr by bmwcarit.
the class BounceProxyEhcacheAdapterTest method testUpdateChannelAssignment.
@Test
public void testUpdateChannelAssignment() {
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-456", bpInfo1);
bpRecord1 = cache.getBounceProxy("bp1.0");
assertEquals("bp1.0", bpRecord1.getBounceProxyId());
assertEquals(2, bpRecord1.getNumberOfAssignedChannels());
}
use of io.joynr.messaging.info.BounceProxyStatusInformation in project joynr by bmwcarit.
the class BounceProxyEhcacheAdapterTest method testUpdateBounceProxy.
@Test
public void testUpdateBounceProxy() {
ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("bp0.0", URI.create("http://www.joynr1.de/bp0.0/"));
long earliestAddTimestamp = System.currentTimeMillis();
cache.addBounceProxy(bpInfo);
long latestAddTimestamp = System.currentTimeMillis();
List<BounceProxyStatusInformation> list = cache.getBounceProxyStatusInformation();
assertEquals(1, list.size());
BounceProxyStatusInformation info = cache.getBounceProxy("bp0.0");
assertEquals("bp0.0", info.getBounceProxyId());
assertEquals(BounceProxyStatus.ALIVE, info.getStatus());
assertThat(info.getFreshness().getTime(), allOf(greaterThanOrEqualTo(earliestAddTimestamp), lessThanOrEqualTo(latestAddTimestamp)));
BounceProxyRecord updatedRecord = new BounceProxyRecord(bpInfo);
updatedRecord.setStatus(BounceProxyStatus.EXCLUDED);
long earliestUpdateTimestamp = System.currentTimeMillis();
cache.updateBounceProxy(updatedRecord);
long latestUpdateTimestamp = System.currentTimeMillis();
list = cache.getBounceProxyStatusInformation();
assertEquals(1, list.size());
BounceProxyStatusInformation updatedInfo = cache.getBounceProxy("bp0.0");
assertEquals("bp0.0", updatedInfo.getBounceProxyId());
assertEquals(BounceProxyStatus.EXCLUDED, updatedInfo.getStatus());
assertThat(updatedInfo.getFreshness().getTime(), allOf(greaterThanOrEqualTo(earliestUpdateTimestamp), lessThanOrEqualTo(latestUpdateTimestamp)));
}
use of io.joynr.messaging.info.BounceProxyStatusInformation in project joynr by bmwcarit.
the class BounceProxyEhcacheAdapterTest method testAddBounceProxy.
@Test
public void testAddBounceProxy() {
List<BounceProxyStatusInformation> list = cache.getBounceProxyStatusInformation();
assertEquals(0, list.size());
ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("bp0.0", URI.create("http://www.joynr1.de/bp0.0/"));
long earliestAddTimestamp = System.currentTimeMillis();
cache.addBounceProxy(bpInfo);
long latestAddTimestamp = System.currentTimeMillis();
list = cache.getBounceProxyStatusInformation();
assertEquals(1, list.size());
assertTrue(cache.containsBounceProxy("bp0.0"));
BounceProxyRecord bp0 = cache.getBounceProxy("bp0.0");
assertEquals("bp0.0", bp0.getBounceProxyId());
assertEquals(BounceProxyStatus.ALIVE, bp0.getStatus());
assertThat(bp0.getFreshness().getTime(), allOf(greaterThanOrEqualTo(earliestAddTimestamp), lessThanOrEqualTo(latestAddTimestamp)));
ControlledBounceProxyInformation bpInfo2 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1.0/"));
earliestAddTimestamp = System.currentTimeMillis();
cache.addBounceProxy(bpInfo2);
latestAddTimestamp = System.currentTimeMillis();
list = cache.getBounceProxyStatusInformation();
assertEquals(2, list.size());
assertTrue(cache.containsBounceProxy("bp0.0"));
assertTrue(cache.containsBounceProxy("bp1.0"));
BounceProxyRecord bp1 = cache.getBounceProxy("bp1.0");
assertEquals("bp1.0", bp1.getBounceProxyId());
assertEquals(BounceProxyStatus.ALIVE, bp1.getStatus());
assertThat(bp1.getFreshness().getTime(), allOf(greaterThanOrEqualTo(earliestAddTimestamp), lessThanOrEqualTo(latestAddTimestamp)));
}
use of io.joynr.messaging.info.BounceProxyStatusInformation in project joynr by bmwcarit.
the class DatabasesTest method testGetBounceProxyStatusInformation.
@Test
public void testGetBounceProxyStatusInformation() {
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
bounceProxyDb.addBounceProxy(bpInfo1);
List<BounceProxyStatusInformation> bpList = bounceProxyDb.getBounceProxyStatusInformation();
Assert.assertEquals(1, bpList.size());
BounceProxyStatusInformation bpInfo = bpList.get(0);
Assert.assertEquals("bp1.0", bpInfo.getBounceProxyId());
Assert.assertEquals(1000l, bpInfo.getFreshness().getTime());
Assert.assertEquals(BounceProxyStatus.ALIVE, bpInfo.getStatus());
}
use of io.joynr.messaging.info.BounceProxyStatusInformation in project joynr by bmwcarit.
the class BounceProxyDatabase method getBounceProxyStatusInformation.
@Override
public List<BounceProxyStatusInformation> getBounceProxyStatusInformation() {
logger.trace("getBounceProxyStatusInformation()");
List<BounceProxyStatusInformation> result = new LinkedList<BounceProxyStatusInformation>();
for (BounceProxyEntity bp : getBounceProxyEntityList()) {
result.add(bp.convertToBounceProxyRecord());
}
logger.debug("found {} bounce proxies", result.size());
return result;
}
Aggregations