Search in sources :

Example 36 with ControlledBounceProxyInformation

use of io.joynr.messaging.info.ControlledBounceProxyInformation 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 37 with ControlledBounceProxyInformation

use of io.joynr.messaging.info.ControlledBounceProxyInformation 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)

Example 38 with ControlledBounceProxyInformation

use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.

the class DatabasesTest method testGetAssignableBounceProxies.

@Test
public void testGetAssignableBounceProxies() {
    List<BounceProxyRecord> assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
    Assert.assertEquals(0, assignableBounceProxies.size());
    ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
    Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
    bounceProxyDb.addBounceProxy(bpInfo1);
    assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
    Assert.assertEquals(1, assignableBounceProxies.size());
    for (BounceProxyStatus status : BounceProxyStatus.values()) {
        BounceProxyRecord bpRecord = new BounceProxyRecord(bpInfo1);
        bpRecord.setStatus(status);
        Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(2000l);
        bounceProxyDb.updateBounceProxy(bpRecord);
        assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
        if (status.isAssignable()) {
            Assert.assertEquals(1, assignableBounceProxies.size());
        } else {
            Assert.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)

Example 39 with ControlledBounceProxyInformation

use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.

the class DatabasesTest method testUpdateChannelAssignmentForUnknownChannel.

@Test
public void testUpdateChannelAssignmentForUnknownChannel() {
    ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
    bounceProxyDb.addBounceProxy(bpInfo1);
    try {
        bounceProxyDb.updateChannelAssignment("channel-123", bpInfo1);
        Assert.fail();
    } catch (IllegalArgumentException e) {
    }
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 40 with ControlledBounceProxyInformation

use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.

the class DatabasesTest method testAddBounceProxies.

@Test
public void testAddBounceProxies() {
    ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
    Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
    bounceProxyDb.addBounceProxy(bpInfo1);
    List<BounceProxyRecord> assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
    Assert.assertEquals(1, assignableBounceProxies.size());
    Assert.assertTrue(bounceProxyDb.containsBounceProxy("bp1.0"));
    Assert.assertFalse(bounceProxyDb.containsBounceProxy("bp2.0"));
    BounceProxyRecord bpRecord1 = bounceProxyDb.getBounceProxy("bp1.0");
    Assert.assertEquals("bp1.0", bpRecord1.getBounceProxyId());
    Assert.assertEquals("http://www.joynr1.de/bp1/", bpRecord1.getInfo().getLocation().toString());
    Assert.assertEquals(0, bpRecord1.getNumberOfAssignedChannels());
    Assert.assertEquals(BounceProxyRecord.ASSIGNMENT_TIMESTAMP_NEVER, bpRecord1.getLastAssignedTimestamp());
    Assert.assertEquals(1000l, bpRecord1.getFreshness().getTime());
    Assert.assertEquals(BounceProxyStatus.ALIVE, bpRecord1.getStatus());
    ControlledBounceProxyInformation bpInfo2 = new ControlledBounceProxyInformation("bp2.0", URI.create("http://www.joynr2.de/bp2/"));
    Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(2000l);
    bounceProxyDb.addBounceProxy(bpInfo2);
    assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
    Assert.assertEquals(2, assignableBounceProxies.size());
    Assert.assertTrue(bounceProxyDb.containsBounceProxy("bp1.0"));
    Assert.assertTrue(bounceProxyDb.containsBounceProxy("bp2.0"));
    BounceProxyRecord bpRecord2 = bounceProxyDb.getBounceProxy("bp2.0");
    Assert.assertEquals("bp2.0", bpRecord2.getBounceProxyId());
    Assert.assertEquals("http://www.joynr2.de/bp2/", bpRecord2.getInfo().getLocation().toString());
    Assert.assertEquals(0, bpRecord2.getNumberOfAssignedChannels());
    Assert.assertEquals(BounceProxyRecord.ASSIGNMENT_TIMESTAMP_NEVER, bpRecord2.getLastAssignedTimestamp());
    Assert.assertEquals(2000l, bpRecord2.getFreshness().getTime());
    Assert.assertEquals(BounceProxyStatus.ALIVE, bpRecord2.getStatus());
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) 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