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();
}
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));
}
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));
}
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));
}
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();
}
Aggregations