Search in sources :

Example 1 with ControlledBounceProxyInformation

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

the class RemoteBounceProxyFacadeTest method testBounceProxyRejectsChannelCreation.

@Test
public void testBounceProxyRejectsChannelCreation() throws Exception {
    setMockedHttpRequestHandlerResponse(HttpStatus.SC_NO_CONTENT, "http://www.joynX.de/channels", "X.Y");
    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)

Example 2 with ControlledBounceProxyInformation

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

the class RemoteBounceProxyFacadeTest method testChannelCreationWhenServerIsUnreachable.

@Test
public void testChannelCreationWhenServerIsUnreachable() throws Exception {
    try {
        server.stop();
    } catch (Exception e) {
    // do nothing as we don't want tests to fail only because
    // stopping of the server did not work
    }
    server.awaitTermination(1000);
    try {
        ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("X.Y", URI.create(serverUrl));
        bpFacade.createChannel(bpInfo, "channel-123", "trackingId-123");
        Assert.fail();
    } catch (Exception e) {
        System.err.println(e);
    }
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) IOException(java.io.IOException) HttpException(org.apache.http.HttpException) JoynrProtocolException(io.joynr.messaging.bounceproxy.controller.exception.JoynrProtocolException) Test(org.junit.Test)

Example 3 with ControlledBounceProxyInformation

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

the class RemoteBounceProxyFacadeTest method testBounceProxyReturnsNoLocation.

@Test
public void testBounceProxyReturnsNoLocation() throws Exception {
    setMockedHttpRequestHandlerResponse(HttpStatus.SC_CREATED, null, "X.Y");
    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)

Example 4 with ControlledBounceProxyInformation

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

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

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