Search in sources :

Example 16 with BounceProxyRecord

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

Example 17 with BounceProxyRecord

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

Example 18 with BounceProxyRecord

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

Example 19 with BounceProxyRecord

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

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