Search in sources :

Example 66 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class JaxrsTagsTest method setUp.

@Before
public void setUp() throws NoSuchMethodException, SecurityException {
    message = new MessageImpl();
    message.setExchange(new ExchangeImpl());
    message.put("org.apache.cxf.resource.method", getClass().getDeclaredMethod("getOperator"));
    tags = new JaxrsTags();
}
Also used : MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Before(org.junit.Before)

Example 67 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class HttpUtilsTest method doTestGetBaseAddress.

private void doTestGetBaseAddress(String baseURI, String expected) {
    Message m = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    m.setExchange(exchange);
    Destination dest = EasyMock.createMock(Destination.class);
    exchange.setDestination(dest);
    m.put(Message.BASE_PATH, baseURI);
    String address = HttpUtils.getBaseAddress(m);
    assertEquals(expected, address);
}
Also used : Exchange(org.apache.cxf.message.Exchange) Destination(org.apache.cxf.transport.Destination) AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination) Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 68 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class TestBase method setUp.

@Before
public void setUp() throws Exception {
    SortedSet<Phase> phases = new TreeSet<>();
    Phase phase1 = new Phase("phase1", 1);
    Phase phase2 = new Phase("phase2", 2);
    Phase phase3 = new Phase("phase3", 3);
    phases.add(phase1);
    phases.add(phase2);
    phases.add(phase3);
    chain = new PhaseInterceptorChain(phases);
    Exchange exchange = new ExchangeImpl();
    MessageImpl messageImpl = new MessageImpl();
    messageImpl.setInterceptorChain(chain);
    messageImpl.setExchange(exchange);
    xmlMessage = messageImpl;
}
Also used : Exchange(org.apache.cxf.message.Exchange) PhaseInterceptorChain(org.apache.cxf.phase.PhaseInterceptorChain) Phase(org.apache.cxf.phase.Phase) TreeSet(java.util.TreeSet) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Before(org.junit.Before)

Example 69 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class LoggingOutInterceptorTest method testFormatting.

@Test
public void testFormatting() throws Exception {
    control.replay();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(baos);
    LoggingOutInterceptor p = new LoggingOutInterceptor(pw);
    // p.setPrettyLogging(true);
    CachedOutputStream cos = new CachedOutputStream();
    String s = "<today><is><the><twenty> <second> <of> <january> <two> <thousand> <and> <nine></nine> " + "</and></thousand></two></january></of></second></twenty></the></is></today>";
    cos.write(s.getBytes());
    Message message = new MessageImpl();
    message.setExchange(new ExchangeImpl());
    message.put(Message.CONTENT_TYPE, "application/xml");
    Logger logger = LogUtils.getL7dLogger(this.getClass());
    LoggingOutInterceptor.LoggingCallback l = p.new LoggingCallback(logger, message, cos);
    l.onClose(cos);
    String str = baos.toString();
    // format has changed
    assertFalse(str.matches(s));
    assertTrue(str.contains("<today>"));
}
Also used : Message(org.apache.cxf.message.Message) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Logger(java.util.logging.Logger) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) PrintWriter(java.io.PrintWriter) CachedOutputStream(org.apache.cxf.io.CachedOutputStream) Test(org.junit.Test)

Example 70 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class AsyncResponseImplTest method testCancelBehavesTheSameWhenInvokedMultipleTimes.

/**
 * According to the spec, subsequent calls to cancel the same AsyncResponse should
 * have the same behavior as the first call.
 */
@Test
public void testCancelBehavesTheSameWhenInvokedMultipleTimes() {
    HttpServletRequest req = control.createMock(HttpServletRequest.class);
    HttpServletResponse resp = control.createMock(HttpServletResponse.class);
    AsyncContext asyncCtx = control.createMock(AsyncContext.class);
    Message msg = new MessageImpl();
    msg.setExchange(new ExchangeImpl());
    msg.put(ContinuationProvider.class.getName(), new Servlet3ContinuationProvider(req, resp, msg));
    req.startAsync();
    EasyMock.expectLastCall().andReturn(asyncCtx);
    control.replay();
    AsyncResponse impl = new AsyncResponseImpl(msg);
    // cancel the AsyncResponse for the first time
    assertTrue("Unexpectedly returned false when canceling the first time", impl.cancel());
    // check the state of the AsyncResponse
    assertTrue("AsyncResponse was canceled but is reporting that it was not canceled", impl.isCancelled());
    boolean isDone = impl.isDone();
    boolean isSuspended = impl.isSuspended();
    // cancel the AsyncResponse a second time
    assertTrue("Unexpectedly returned false when canceling the second time", impl.cancel());
    // verify that the state is the same as before the second cancel
    assertTrue("AsyncResponse was canceled (twice) but is reporting that it was not canceled", impl.isCancelled());
    assertEquals("AsynchResponse.isDone() returned a different response after canceling a second time", isDone, impl.isDone());
    assertEquals("AsynchResponse.isSuspended() returned a different response after canceling a second time", isSuspended, impl.isSuspended());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ContinuationProvider(org.apache.cxf.continuations.ContinuationProvider) Servlet3ContinuationProvider(org.apache.cxf.transport.http.Servlet3ContinuationProvider) Message(org.apache.cxf.message.Message) Servlet3ContinuationProvider(org.apache.cxf.transport.http.Servlet3ContinuationProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) AsyncContext(javax.servlet.AsyncContext) AsyncResponse(javax.ws.rs.container.AsyncResponse) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

ExchangeImpl (org.apache.cxf.message.ExchangeImpl)227 MessageImpl (org.apache.cxf.message.MessageImpl)189 Message (org.apache.cxf.message.Message)166 Exchange (org.apache.cxf.message.Exchange)159 Test (org.junit.Test)107 Endpoint (org.apache.cxf.endpoint.Endpoint)42 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)30 ByteArrayInputStream (java.io.ByteArrayInputStream)28 QName (javax.xml.namespace.QName)23 Bus (org.apache.cxf.Bus)23 HashMap (java.util.HashMap)22 List (java.util.List)22 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)20 SOAPMessage (javax.xml.soap.SOAPMessage)16 LogEvent (org.apache.cxf.ext.logging.event.LogEvent)16 ArrayList (java.util.ArrayList)15 IOException (java.io.IOException)14 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)14 Conduit (org.apache.cxf.transport.Conduit)14