Search in sources :

Example 21 with ControlledBounceProxyInformation

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

the class InMemoryBounceProxyDirectoryTest method testGetAssignableBounceProxiesForDirectoryWithUnassignableOnes.

@Test
public void testGetAssignableBounceProxiesForDirectoryWithUnassignableOnes() {
    directory.addBounceProxy(new ControlledBounceProxyInformation("A1.B1", null));
    directory.addBounceProxy(new ControlledBounceProxyInformation("A2.B2", null));
    BounceProxyRecord bounceProxyRecord = directory.getBounceProxy("A2.B2");
    bounceProxyRecord.setStatus(BounceProxyStatus.EXCLUDED);
    directory.updateBounceProxy(bounceProxyRecord);
    directory.addBounceProxy(new ControlledBounceProxyInformation("A3.B3", null));
    List<BounceProxyRecord> bounceProxies = directory.getAssignableBounceProxies();
    Assert.assertThat(bounceProxies, Matchers.hasItem(hasId("A1.B1")));
    Assert.assertThat(bounceProxies, Matchers.hasItem(hasId("A3.B3")));
    assertEquals(2, bounceProxies.size());
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 22 with ControlledBounceProxyInformation

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

the class InMemoryBounceProxyDirectoryTest method testContainsBounceProxy.

@Test
public void testContainsBounceProxy() {
    directory.addBounceProxy(new ControlledBounceProxyInformation("X.Y", null));
    assertTrue(directory.containsBounceProxy("X.Y"));
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 23 with ControlledBounceProxyInformation

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

the class InMemoryBounceProxyDirectoryTest method testUpdateChannelAssignmentOnNonExistingBounceProxy.

@Test
public void testUpdateChannelAssignmentOnNonExistingBounceProxy() {
    directory.addBounceProxy(new ControlledBounceProxyInformation("A.B", null));
    try {
        directory.updateChannelAssignment("channel-123", new BounceProxyInformation("X.Y", null));
        Assert.fail();
    } catch (IllegalArgumentException e) {
    }
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) BounceProxyInformation(io.joynr.messaging.info.BounceProxyInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 24 with ControlledBounceProxyInformation

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

the class ChannelServiceImplTest method testCreateChannel.

@Test
public void testCreateChannel() throws JoynrProtocolException {
    ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("X.Y", URI.create("http://bpX.de"));
    Mockito.when(channelAssignmentStrategyMock.calculateBounceProxy("channel-123")).thenReturn(bpInfo);
    Mockito.when(bpMock.createChannel(bpInfo, "channel-123", "trackingId-xyz")).thenReturn(URI.create("http://bpX.de/channels/channel-123"));
    Channel channel = channelService.createChannel("channel-123", "trackingId-xyz");
    assertEquals("channel-123", channel.getChannelId());
    assertEquals("X.Y", channel.getBounceProxy().getId());
    assertEquals("http://bpX.de", channel.getBounceProxy().getLocation().toString());
    assertEquals("http://bpX.de/channels/channel-123", channel.getLocation().toString());
    Mockito.verify(channelDirectoryMock, Mockito.times(1)).addChannel(channel);
    Mockito.verify(bpDirectoryMock).updateChannelAssignment("channel-123", bpInfo);
}
Also used : Channel(io.joynr.messaging.info.Channel) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 25 with ControlledBounceProxyInformation

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

the class RemoteBounceProxyFacadeTest method testBounceProxyReturnsNoBounceProxyId.

@Test
public void testBounceProxyReturnsNoBounceProxyId() throws Exception {
    setMockedHttpRequestHandlerResponse(HttpStatus.SC_CREATED, "http://www.joynX.de/channels", null);
    ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("X.Y", URI.create(serverUrl));
    try {
        bpFacade.createChannel(bpInfo, "channel-123", "trackingId-123");
        Assert.fail();
    } catch (JoynrProtocolException e) {
    }
    Mockito.verify(handler).handle(Mockito.argThat(new IsCreateChannelHttpRequest("channel-123", "trackingId-123")), Mockito.any(HttpResponse.class), Mockito.any(HttpContext.class));
}
Also used : JoynrProtocolException(io.joynr.messaging.bounceproxy.controller.exception.JoynrProtocolException) HttpContext(org.apache.http.protocol.HttpContext) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) IsCreateChannelHttpRequest(io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest) HttpResponse(org.apache.http.HttpResponse) 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