Search in sources :

Example 6 with ExchangeImpl

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

the class MetricsInInterceptorTest method testHandleMessageWithTwoWayClientMessageWithLatencyTimeRecorder.

/**
     * Test method for
     * {@link ddf.metrics.interceptor.MetricsInInterceptor#handleMessage(org.apache.cxf.message.Message)}
     * .
     *
     * @throws InterruptedException
     */
@Test
public void testHandleMessageWithTwoWayClientMessageWithLatencyTimeRecorder() {
    // Setup
    MetricsInInterceptor inInterceptor = new MetricsInInterceptor();
    Message mockMessage = mock(Message.class);
    Exchange ex = new ExchangeImpl();
    Bus mockBus = mock(Bus.class);
    LatencyTimeRecorder mockLtr = mock(LatencyTimeRecorder.class);
    ex.put(Bus.class, mockBus);
    ex.put(LatencyTimeRecorder.class, mockLtr);
    when(mockBus.getId()).thenReturn("bus_id");
    when(mockMessage.getExchange()).thenReturn(ex);
    when(mockMessage.get(Message.REQUESTOR_ROLE)).thenReturn(true);
    // Perform test
    inInterceptor.handleMessage(mockMessage);
    // validate that LatencyTimeRecorder.beginHandling was called once
    verify(mockLtr, times(1)).endHandling();
}
Also used : Exchange(org.apache.cxf.message.Exchange) Bus(org.apache.cxf.Bus) Message(org.apache.cxf.message.Message) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 7 with ExchangeImpl

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

the class MetricsInInterceptorTest method testHandleMessageWithTwoWayClientMessageWithoutLatencyTimeRecorder.

/**
     * Test method for
     * {@link ddf.metrics.interceptor.MetricsInInterceptor#handleMessage(org.apache.cxf.message.Message)}
     * .
     *
     * @throws InterruptedException
     */
@Test
public void testHandleMessageWithTwoWayClientMessageWithoutLatencyTimeRecorder() {
    // Setup
    MetricsInInterceptor inInterceptor = new MetricsInInterceptor();
    Message mockMessage = mock(Message.class);
    Exchange ex = new ExchangeImpl();
    Bus mockBus = mock(Bus.class);
    ex.put(Bus.class, mockBus);
    when(mockBus.getId()).thenReturn("bus_id");
    when(mockMessage.getExchange()).thenReturn(ex);
    when(mockMessage.get(Message.REQUESTOR_ROLE)).thenReturn(true);
    // Perform test
    inInterceptor.handleMessage(mockMessage);
    // validate that there is not an instance of LatencyTimeRecorder on the
    // exchange
    assertNull(ex.get(LatencyTimeRecorder.class));
}
Also used : Exchange(org.apache.cxf.message.Exchange) Bus(org.apache.cxf.Bus) Message(org.apache.cxf.message.Message) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 8 with ExchangeImpl

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

the class MetricsOutInterceptorTest method testHandleMessageWithNonClientMessageWithoutLatencyTimeRecorder.

/**
     * Test method for
     * {@link ddf.metrics.interceptor.MetricsOutInterceptor#handleMessage(org.apache.cxf.message.Message)}
     * .
     *
     * @throws InterruptedException
     */
@Test
public void testHandleMessageWithNonClientMessageWithoutLatencyTimeRecorder() {
    // Setup
    MetricsOutInterceptor outInterceptor = new MetricsOutInterceptor();
    Message mockMessage = mock(Message.class);
    Exchange ex = new ExchangeImpl();
    Bus mockBus = mock(Bus.class);
    ex.put(Bus.class, mockBus);
    when(mockBus.getId()).thenReturn("bus_id");
    when(mockMessage.getExchange()).thenReturn(ex);
    when(mockMessage.get(Message.PARTIAL_RESPONSE_MESSAGE)).thenReturn("false");
    when(mockMessage.get(Message.REQUESTOR_ROLE)).thenReturn("false");
    // Perform test
    outInterceptor.handleMessage(mockMessage);
    // validate that there is not an instance of LatencyTimeRecorder on the
    // exchange
    assertNull(ex.get(LatencyTimeRecorder.class));
}
Also used : Exchange(org.apache.cxf.message.Exchange) Bus(org.apache.cxf.Bus) Message(org.apache.cxf.message.Message) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 9 with ExchangeImpl

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

the class MetricsOutInterceptorTest method testHandleMessageWithPartialResponseMessage.

/**
     * Test method for
     * {@link ddf.metrics.interceptor.MetricsOutInterceptor#handleMessage(org.apache.cxf.message.Message)}
     * .
     *
     * @throws InterruptedException
     */
@Test
public void testHandleMessageWithPartialResponseMessage() {
    // Setup
    MetricsOutInterceptor outInterceptor = new MetricsOutInterceptor();
    Message mockMessage = mock(Message.class);
    Exchange ex = new ExchangeImpl();
    when(mockMessage.getExchange()).thenReturn(ex);
    when(mockMessage.get(Message.PARTIAL_RESPONSE_MESSAGE)).thenReturn("true");
    // Perform test
    outInterceptor.handleMessage(mockMessage);
    // validate that there is not an instance of LatencyTimeRecorder on the
    // exchange
    assertNull(ex.get(LatencyTimeRecorder.class));
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 10 with ExchangeImpl

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

the class MetricsOutInterceptorTest method testHandleMessageWithTwoWayClientMessageWithLatencyTimeRecorder.

/**
     * Test method for
     * {@link ddf.metrics.interceptor.MetricsOutInterceptor#handleMessage(org.apache.cxf.message.Message)}
     * .
     *
     * @throws InterruptedException
     */
@Test
public void testHandleMessageWithTwoWayClientMessageWithLatencyTimeRecorder() {
    // Setup
    MetricsOutInterceptor outInterceptor = new MetricsOutInterceptor();
    Message mockMessage = mock(Message.class);
    Exchange ex = new ExchangeImpl();
    Bus mockBus = mock(Bus.class);
    LatencyTimeRecorder mockLtr = mock(LatencyTimeRecorder.class);
    ex.put(Bus.class, mockBus);
    ex.put(LatencyTimeRecorder.class, mockLtr);
    when(mockBus.getId()).thenReturn("bus_id");
    when(mockMessage.getExchange()).thenReturn(ex);
    when(mockMessage.get(Message.PARTIAL_RESPONSE_MESSAGE)).thenReturn("false");
    when(mockMessage.get(Message.REQUESTOR_ROLE)).thenReturn(true);
    // Perform test
    outInterceptor.handleMessage(mockMessage);
    // validate that LatencyTimeRecorder.beginHandling was called once
    verify(mockLtr, times(1)).beginHandling();
}
Also used : Exchange(org.apache.cxf.message.Exchange) Bus(org.apache.cxf.Bus) Message(org.apache.cxf.message.Message) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

ExchangeImpl (org.apache.cxf.message.ExchangeImpl)22 Message (org.apache.cxf.message.Message)17 Test (org.junit.Test)16 Exchange (org.apache.cxf.message.Exchange)14 Bus (org.apache.cxf.Bus)9 MessageImpl (org.apache.cxf.message.MessageImpl)7 HashMap (java.util.HashMap)6 List (java.util.List)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IOException (java.io.IOException)4 RuntimeCamelException (org.apache.camel.RuntimeCamelException)3 DefaultExchange (org.apache.camel.impl.DefaultExchange)3 MessageObserver (org.apache.cxf.transport.MessageObserver)3 WebServiceException (javax.xml.ws.WebServiceException)2 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 Conduit (org.apache.cxf.transport.Conduit)2 InputStream (java.io.InputStream)1