use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.
the class AbstractMessageResponseTimeInterceptor method setOneWayMessage.
protected void setOneWayMessage(Exchange ex) {
MessageHandlingTimeRecorder mhtr = ex.get(MessageHandlingTimeRecorder.class);
if (null == mhtr) {
mhtr = new MessageHandlingTimeRecorder(ex);
} else {
mhtr.endHandling();
}
mhtr.setOneWay(true);
increaseCounter(ex, mhtr);
}
use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.
the class AbstractMessageResponseTimeInterceptor method beginHandlingMessage.
protected void beginHandlingMessage(Exchange ex) {
if (null == ex) {
return;
}
MessageHandlingTimeRecorder mhtr = ex.get(MessageHandlingTimeRecorder.class);
if (null != mhtr) {
mhtr.beginHandling();
} else {
mhtr = new MessageHandlingTimeRecorder(ex);
mhtr.beginHandling();
}
}
use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.
the class AbstractMessageResponseTimeInterceptor method endHandlingMessage.
protected void endHandlingMessage(Exchange ex) {
if (null == ex) {
return;
}
MessageHandlingTimeRecorder mhtr = ex.get(MessageHandlingTimeRecorder.class);
if (null != mhtr) {
mhtr.endHandling();
mhtr.setFaultMode(ex.get(FaultMode.class));
increaseCounter(ex, mhtr);
}
// else can't get the MessageHandling Infor
}
use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.
the class ResponseTimeMessageInInterceptorTest method testClientFaultMessageIn.
public void testClientFaultMessageIn(FaultMode faultMode) {
// need to increase the counter and is a client
setupCounterRepository(true, true);
setupExchangeForMessage();
setupOperationForMessage();
EasyMock.expect(message.getExchange()).andReturn(exchange);
EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
EasyMock.expect(exchange.isOneWay()).andReturn(false);
EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(true);
exchange.put(FaultMode.class, faultMode);
EasyMock.expectLastCall();
EasyMock.expect(message.get(FaultMode.class)).andReturn(faultMode).anyTimes();
EasyMock.expect(exchange.get(FaultMode.class)).andReturn(faultMode).anyTimes();
EasyMock.expect(exchange.getOutMessage()).andReturn(message);
MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
mhtr.endHandling();
EasyMock.expectLastCall();
mhtr.setFaultMode(faultMode);
EasyMock.expectLastCall();
EasyMock.replay(mhtr);
EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr);
EasyMock.replay(exchange);
EasyMock.replay(message);
rtmoi.handleFault(message);
EasyMock.verify(message);
EasyMock.verify(bus);
EasyMock.verify(exchange);
EasyMock.verify(mhtr);
}
use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.
the class ResponseTimeMessageOutInterceptorTest method testClientOneWayMessageOut.
@Test
public void testClientOneWayMessageOut() {
// need to increase the counter and is a client
setupCounterRepository(true, true);
setupExchangeForMessage();
setupOperationForMessage();
EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
EasyMock.expect(exchange.get(Exception.class)).andReturn(null);
EasyMock.expect(exchange.isOneWay()).andReturn(true).anyTimes();
MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr).anyTimes();
EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
InterceptorChain chain = EasyMock.createMock(InterceptorChain.class);
EasyMock.expect(message.getInterceptorChain()).andReturn(chain);
chain.add(EasyMock.isA(ResponseTimeMessageOutInterceptor.EndingInterceptor.class));
EasyMock.expectLastCall();
EasyMock.replay(exchange);
EasyMock.replay(message);
rtmoi.handleMessage(message);
rtmoi.getEndingInterceptor().handleMessage(message);
EasyMock.verify(message);
EasyMock.verify(bus);
EasyMock.verify(exchange);
}
Aggregations