Search in sources :

Example 1 with IsCreateChannelHttpRequest

use of io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest 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 IsCreateChannelHttpRequest

use of io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest 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 3 with IsCreateChannelHttpRequest

use of io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest 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)

Example 4 with IsCreateChannelHttpRequest

use of io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest in project joynr by bmwcarit.

the class RemoteBounceProxyFacadeTest method testBounceProxyReturnsUnexpectedBounceProxyId.

@Test
public void testBounceProxyReturnsUnexpectedBounceProxyId() throws Exception {
    setMockedHttpRequestHandlerResponse(HttpStatus.SC_CREATED, "http://www.joynX.de/channels", "A.B");
    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 5 with IsCreateChannelHttpRequest

use of io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest in project joynr by bmwcarit.

the class RemoteBounceProxyFacadeTest method testSuccessfulChannelCreation.

@Test
public void testSuccessfulChannelCreation() throws Exception {
    setMockedHttpRequestHandlerResponse(HttpStatus.SC_CREATED, "http://www.joynX.de/channels", "X.Y");
    ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("X.Y", URI.create(serverUrl));
    URI channelUri = bpFacade.createChannel(bpInfo, "channel-123", "trackingId-123");
    Mockito.verify(handler).handle(Mockito.argThat(new IsCreateChannelHttpRequest("channel-123", "trackingId-123")), Mockito.any(HttpResponse.class), Mockito.any(HttpContext.class));
    Assert.assertEquals("http://www.joynX.de/channels", channelUri.toString());
}
Also used : HttpContext(org.apache.http.protocol.HttpContext) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) IsCreateChannelHttpRequest(io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Aggregations

IsCreateChannelHttpRequest (io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest)5 ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)5 HttpResponse (org.apache.http.HttpResponse)5 HttpContext (org.apache.http.protocol.HttpContext)5 Test (org.junit.Test)5 JoynrProtocolException (io.joynr.messaging.bounceproxy.controller.exception.JoynrProtocolException)4 URI (java.net.URI)1