Search in sources :

Example 6 with BounceProxyRecord

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

Example 7 with BounceProxyRecord

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

Example 8 with BounceProxyRecord

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());
}
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 9 with BounceProxyRecord

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)));
}
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 10 with BounceProxyRecord

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)));
}
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)

Aggregations

BounceProxyRecord (io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord)30 ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)17 Test (org.junit.Test)16 LinkedList (java.util.LinkedList)6 BounceProxyInformation (io.joynr.messaging.info.BounceProxyInformation)4 BounceProxyStatusInformation (io.joynr.messaging.info.BounceProxyStatusInformation)4 Cache (net.sf.ehcache.Cache)3 Element (net.sf.ehcache.Element)3 BounceProxyEntity (io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity)2 BounceProxyStatus (io.joynr.messaging.info.BounceProxyStatus)2 Channel (io.joynr.messaging.info.Channel)1 PerformanceMeasures (io.joynr.messaging.info.PerformanceMeasures)1 List (java.util.List)1 EntityManager (javax.persistence.EntityManager)1 EntityTransaction (javax.persistence.EntityTransaction)1