use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class ChannelUrlUtilTest method testGetChannelUrlPathWithSameBaseUri.
@Test
public void testGetChannelUrlPathWithSameBaseUri() {
ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("X.Y", URI.create("http://www.joyn1.de/bp"));
URI result = ChannelUrlUtil.createChannelLocation(bpInfo, "channel-123", URI.create("http://www.joyn1.de/bp/channels/channel-123"));
Assert.assertEquals("http://www.joyn1.de/bp/channels/channel-123;jsessionid=.Y", result.toString());
}
use of io.joynr.messaging.info.ControlledBounceProxyInformation 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.ControlledBounceProxyInformation 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.ControlledBounceProxyInformation 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.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class DatabasesTest method testAddChannels.
@Test
public void testAddChannels() {
Assert.assertEquals(0, channelDb.getChannels().size());
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
bounceProxyDb.addBounceProxy(bpInfo1);
channelDb.addChannel(new Channel(bpInfo1, "channel1", URI.create("http://www.joyn1.de/bp1/channels/channel1")));
List<Channel> channels = channelDb.getChannels();
Assert.assertEquals(1, channels.size());
Channel channel = channels.get(0);
Assert.assertEquals("channel1", channel.getChannelId());
Assert.assertEquals("bp1.0", channel.getBounceProxy().getId());
Assert.assertEquals("http://www.joyn1.de/bp1/channels/channel1", channel.getLocation().toString());
Assert.assertEquals(channel.getChannelId(), channelDb.getChannel("channel1").getChannelId());
channelDb.addChannel(new Channel(bpInfo1, "channel1b", URI.create("http://www.joyn1.de/bp1/channels/channel1b")));
channels = channelDb.getChannels();
Assert.assertEquals(2, channels.size());
Channel channel1b = channelDb.getChannel("channel1b");
Assert.assertNotNull(channel1b);
Assert.assertEquals("channel1b", channel1b.getChannelId());
Assert.assertEquals("bp1.0", channel1b.getBounceProxy().getId());
Assert.assertEquals("http://www.joyn1.de/bp1/channels/channel1b", channel1b.getLocation().toString());
ControlledBounceProxyInformation bpInfo2 = new ControlledBounceProxyInformation("bp2.0", URI.create("http://www.joynr2.de/bp2/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(2000l);
bounceProxyDb.addBounceProxy(bpInfo2);
channelDb.addChannel(new Channel(bpInfo2, "channel2", URI.create("http://www.joyn1.de/bp1/channels/channel2")));
Assert.assertEquals(3, channelDb.getChannels().size());
}
Aggregations