Search in sources :

Example 21 with Bus

use of org.apache.cxf.Bus in project ddf by codice.

the class MetricsInInterceptorTest method testHandleMessageWithOneWayClientMessage.

/**
     * Test method for
     * {@link ddf.metrics.interceptor.MetricsInInterceptor#handleMessage(org.apache.cxf.message.Message)}
     * .
     *
     * @throws InterruptedException
     */
@Test
public void testHandleMessageWithOneWayClientMessage() {
    // Setup
    MetricsInInterceptor inInterceptor = new MetricsInInterceptor();
    Message mockMessage = mock(Message.class);
    Exchange ex = new ExchangeImpl();
    Bus mockBus = mock(Bus.class);
    ex.put(Bus.class, mockBus);
    ex.setOneWay(true);
    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 22 with Bus

use of org.apache.cxf.Bus 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 23 with Bus

use of org.apache.cxf.Bus 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 24 with Bus

use of org.apache.cxf.Bus 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 25 with Bus

use of org.apache.cxf.Bus 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

Bus (org.apache.cxf.Bus)57 Test (org.junit.Test)31 URL (java.net.URL)19 QName (javax.xml.namespace.QName)15 Service (javax.xml.ws.Service)12 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)11 Exchange (org.apache.cxf.message.Exchange)9 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)9 Message (org.apache.cxf.message.Message)9 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 ServiceIface (org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface)7 IOException (java.io.IOException)6 ActAsServiceIface (org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface)6 CamelContext (org.apache.camel.CamelContext)4 Message (org.apache.camel.Message)4 Greeter (org.apache.camel.hello_world_soap_http.Greeter)4 GreeterService (org.apache.camel.hello_world_soap_http.GreeterService)4