use of org.apache.cxf.message.Exchange 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));
}
use of org.apache.cxf.message.Exchange 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();
}
use of org.apache.cxf.message.Exchange in project ddf by codice.
the class MetricsOutInterceptorTest method testHandleMessageWithOneWayClientMessage.
/**
* Test method for
* {@link ddf.metrics.interceptor.MetricsOutInterceptor#handleMessage(org.apache.cxf.message.Message)}
* .
*
* @throws InterruptedException
*/
@Test
public void testHandleMessageWithOneWayClientMessage() {
// Setup
MetricsOutInterceptor outInterceptor = new MetricsOutInterceptor();
Message mockMessage = mock(Message.class);
Exchange ex = new ExchangeImpl();
Bus mockBus = mock(Bus.class);
InterceptorChain mockIc = mock(InterceptorChain.class);
ex.put(Bus.class, mockBus);
ex.setOneWay(true);
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);
when(mockMessage.getInterceptorChain()).thenReturn(mockIc);
// Perform test
outInterceptor.handleMessage(mockMessage);
// validate that LatencyTimeRecorder.beginHandling was called once
verify(mockMessage, times(1)).getInterceptorChain();
}
use of org.apache.cxf.message.Exchange in project ddf by codice.
the class MetricsOutInterceptorTest method testHandleMessageWithTwoWayClientMessageWithoutLatencyTimeRecorder.
/**
* Test method for
* {@link ddf.metrics.interceptor.MetricsOutInterceptor#handleMessage(org.apache.cxf.message.Message)}
* .
*
* @throws InterruptedException
*/
@Test
public void testHandleMessageWithTwoWayClientMessageWithoutLatencyTimeRecorder() {
// 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(true);
// Perform test
outInterceptor.handleMessage(mockMessage);
// validate that an instance of LatencyTimeRecorder was put onto the
// exchange
assertThat(ex.get(LatencyTimeRecorder.class), instanceOf(LatencyTimeRecorder.class));
}
use of org.apache.cxf.message.Exchange in project cxf by apache.
the class JAXRSUtilsTest method createMessage2.
private Message createMessage2() {
ProviderFactory factory = ServerProviderFactory.getInstance();
Message m = new MessageImpl();
m.put("org.apache.cxf.http.case_insensitive_queries", false);
Exchange e = new ExchangeImpl();
m.setExchange(e);
e.setInMessage(m);
Endpoint endpoint = EasyMock.createMock(Endpoint.class);
endpoint.getEndpointInfo();
EasyMock.expectLastCall().andReturn(null).anyTimes();
endpoint.get("org.apache.cxf.jaxrs.comparator");
EasyMock.expectLastCall().andReturn(null);
endpoint.size();
EasyMock.expectLastCall().andReturn(0).anyTimes();
endpoint.isEmpty();
EasyMock.expectLastCall().andReturn(true).anyTimes();
endpoint.get(ServerProviderFactory.class.getName());
EasyMock.expectLastCall().andReturn(factory).anyTimes();
EasyMock.replay(endpoint);
e.put(Endpoint.class, endpoint);
return m;
}
Aggregations