use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class RoundRobinAssignmentTest method createBounceProxyRecord.
private BounceProxyRecord createBounceProxyRecord(String bpId) {
ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation(bpId, null);
BounceProxyRecord record = new BounceProxyRecord(bpInfo);
return record;
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class RoundRobinAssignmentTest method testAssignmentToBounceProxyWithSmallestTimestamp.
@Test
public void testAssignmentToBounceProxyWithSmallestTimestamp() {
LinkedList<BounceProxyRecord> bpList = new LinkedList<BounceProxyRecord>();
bpList.add(createBounceProxyRecordWithChannels("X1.Y1", 2, 3));
bpList.add(createBounceProxyRecordWithChannels("X2.Y2", 3, 2));
bpList.add(createBounceProxyRecordWithChannels("X3.Y3", 1, 5));
Mockito.when(directoryMock.getAssignableBounceProxies()).thenReturn(bpList);
BounceProxyInformation bounceProxy = assignmentStrategy.calculateBounceProxy("channel-123");
Assert.assertEquals("X2.Y2", bounceProxy.getId());
Mockito.verify(directoryMock, Mockito.never()).updateChannelAssignment("channel-123", bounceProxy);
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class MonitoringServiceImplTest method testResetBounceProxy.
@Test
public void testResetBounceProxy() {
Mockito.when(bpDirectoryMock.containsBounceProxy("X.Y")).thenReturn(true);
Mockito.when(bpDirectoryMock.getBounceProxy("X.Y")).thenReturn(new BounceProxyRecord(new ControlledBounceProxyInformation("X.Y", null)));
monitoringService.update("X.Y", "http://www.joynX.de/bp", "http://joyn.some-internal-server.de/bpX");
ArgumentCaptor<BounceProxyRecord> argument = ArgumentCaptor.forClass(BounceProxyRecord.class);
Mockito.verify(bpDirectoryMock).updateBounceProxy(argument.capture());
Assert.assertEquals("X.Y", argument.getValue().getBounceProxyId());
Assert.assertEquals("http://www.joynX.de/bp", argument.getValue().getInfo().getLocation().toString());
Assert.assertEquals("http://joyn.some-internal-server.de/bpX", argument.getValue().getInfo().getLocationForBpc().toString());
Assert.assertEquals(BounceProxyStatus.ALIVE, argument.getValue().getStatus());
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord 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.bounceproxy.controller.directory.BounceProxyRecord 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());
}
}
}
Aggregations