Search in sources :

Example 11 with ControlledBounceProxyInformation

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());
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) URI(java.net.URI) Test(org.junit.Test)

Example 12 with ControlledBounceProxyInformation

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());
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) BounceProxyStatusInformation(io.joynr.messaging.info.BounceProxyStatusInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 13 with ControlledBounceProxyInformation

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)));
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) BounceProxyStatusInformation(io.joynr.messaging.info.BounceProxyStatusInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 14 with ControlledBounceProxyInformation

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)));
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) BounceProxyStatusInformation(io.joynr.messaging.info.BounceProxyStatusInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 15 with ControlledBounceProxyInformation

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());
}
Also used : Channel(io.joynr.messaging.info.Channel) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Aggregations

ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)47 Test (org.junit.Test)44 BounceProxyRecord (io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord)13 IsCreateChannelHttpRequest (io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest)5 JoynrProtocolException (io.joynr.messaging.bounceproxy.controller.exception.JoynrProtocolException)5 BounceProxyStatusInformation (io.joynr.messaging.info.BounceProxyStatusInformation)5 Channel (io.joynr.messaging.info.Channel)5 HttpResponse (org.apache.http.HttpResponse)5 HttpContext (org.apache.http.protocol.HttpContext)5 URI (java.net.URI)4 BounceProxyInformation (io.joynr.messaging.info.BounceProxyInformation)2 BounceProxyStatus (io.joynr.messaging.info.BounceProxyStatus)2 PerformanceMeasures (io.joynr.messaging.info.PerformanceMeasures)2 JoynrCommunicationException (io.joynr.exceptions.JoynrCommunicationException)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 IOException (java.io.IOException)1 EntityManager (javax.persistence.EntityManager)1 EntityTransaction (javax.persistence.EntityTransaction)1 Query (javax.persistence.Query)1 HttpException (org.apache.http.HttpException)1