use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class MonitoringServiceImplTest method testUpdatePerformanceMeasures.
@Test
public void testUpdatePerformanceMeasures() {
Mockito.when(bpDirectoryMock.containsBounceProxy("X.Y")).thenReturn(true);
Mockito.when(bpDirectoryMock.getBounceProxy("X.Y")).thenReturn(new BounceProxyRecord(new ControlledBounceProxyInformation("X.Y", null)));
PerformanceMeasures performanceMeasures = new PerformanceMeasures();
performanceMeasures.addMeasure(Key.ACTIVE_LONGPOLL_COUNT, 5);
monitoringService.updatePerformanceMeasures("X.Y", performanceMeasures);
ArgumentCaptor<BounceProxyRecord> argument = ArgumentCaptor.forClass(BounceProxyRecord.class);
Mockito.verify(bpDirectoryMock).updateBounceProxy(argument.capture());
Assert.assertEquals("X.Y", argument.getValue().getBounceProxyId());
Assert.assertEquals(5, argument.getValue().getPerformanceMeasures().getMeasure(Key.ACTIVE_LONGPOLL_COUNT));
Assert.assertEquals(BounceProxyStatus.ACTIVE, argument.getValue().getStatus());
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class MonitoringServiceImplTest method testShutdownBounceProxy.
@Test
public void testShutdownBounceProxy() {
Mockito.when(bpDirectoryMock.containsBounceProxy("X.Y")).thenReturn(true);
Mockito.when(bpDirectoryMock.getBounceProxy("X.Y")).thenReturn(new BounceProxyRecord(new ControlledBounceProxyInformation("X.Y", null)));
monitoringService.updateStatus("X.Y", BounceProxyStatus.SHUTDOWN);
ArgumentCaptor<BounceProxyRecord> argument = ArgumentCaptor.forClass(BounceProxyRecord.class);
Mockito.verify(bpDirectoryMock).updateBounceProxy(argument.capture());
Assert.assertEquals("X.Y", argument.getValue().getBounceProxyId());
Assert.assertEquals(BounceProxyStatus.SHUTDOWN, argument.getValue().getStatus());
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord 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.bounceproxy.controller.directory.BounceProxyRecord 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.bounceproxy.controller.directory.BounceProxyRecord 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)));
}
Aggregations