Search in sources :

Example 1 with HttpExchange

use of javax.xml.ws.spi.http.HttpExchange in project cxf by apache.

the class JAXWSHttpSpiDestinationTest method testMessage.

@Test
public void testMessage() throws Exception {
    HttpExchange exchange = setUpExchange();
    control.replay();
    JAXWSHttpSpiDestination destination = new JAXWSHttpSpiDestination(bus, new DestinationRegistryImpl(), endpoint);
    destination.setMessageObserver(observer);
    destination.doService(new HttpServletRequestAdapter(exchange), new HttpServletResponseAdapter(exchange));
    control.verify();
}
Also used : HttpExchange(javax.xml.ws.spi.http.HttpExchange) DestinationRegistryImpl(org.apache.cxf.transport.http.DestinationRegistryImpl) Test(org.junit.Test)

Example 2 with HttpExchange

use of javax.xml.ws.spi.http.HttpExchange in project cxf by apache.

the class JAXWSHttpSpiDestinationTest method setUpExchange.

private HttpExchange setUpExchange() throws Exception {
    HttpExchange exchange = control.createMock(HttpExchange.class);
    expect(exchange.getHttpContext()).andReturn(context).anyTimes();
    expect(exchange.getQueryString()).andReturn(null);
    expect(exchange.getPathInfo()).andReturn(null);
    expect(exchange.getRequestURI()).andReturn(CONTEXT_PATH);
    expect(exchange.getContextPath()).andReturn(CONTEXT_PATH);
    Map<String, List<String>> reqHeaders = new HashMap<>();
    reqHeaders.put("Content-Type", Collections.singletonList("text/xml"));
    expect(exchange.getRequestHeaders()).andReturn(reqHeaders).anyTimes();
    OutputStream responseBody = control.createMock(OutputStream.class);
    responseBody.flush();
    EasyMock.expectLastCall();
    expect(exchange.getResponseBody()).andReturn(responseBody).anyTimes();
    observer.onMessage(isA(Message.class));
    EasyMock.expectLastCall();
    return exchange;
}
Also used : Message(org.apache.cxf.message.Message) HashMap(java.util.HashMap) OutputStream(java.io.OutputStream) HttpExchange(javax.xml.ws.spi.http.HttpExchange) List(java.util.List)

Aggregations

HttpExchange (javax.xml.ws.spi.http.HttpExchange)2 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Message (org.apache.cxf.message.Message)1 DestinationRegistryImpl (org.apache.cxf.transport.http.DestinationRegistryImpl)1 Test (org.junit.Test)1