Search in sources :

Example 1 with BounceProxyStatusInformation

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());
}
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 2 with BounceProxyStatusInformation

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)));
}
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 3 with BounceProxyStatusInformation

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)));
}
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 4 with BounceProxyStatusInformation

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

Example 5 with BounceProxyStatusInformation

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;
}
Also used : BounceProxyEntity(io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity) BounceProxyStatusInformation(io.joynr.messaging.info.BounceProxyStatusInformation) LinkedList(java.util.LinkedList)

Aggregations

BounceProxyStatusInformation (io.joynr.messaging.info.BounceProxyStatusInformation)7 ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)5 Test (org.junit.Test)5 BounceProxyRecord (io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord)4 LinkedList (java.util.LinkedList)2 BounceProxyEntity (io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity)1 List (java.util.List)1 Cache (net.sf.ehcache.Cache)1 Element (net.sf.ehcache.Element)1