Search in sources :

Example 6 with MessageHandlingTimeRecorder

use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.

the class ResponseTimeMessageOutInterceptorTest method testServerMessageOut.

@Test
public void testServerMessageOut() {
    // need to increase the counter and is not a client
    setupCounterRepository(true, false);
    setupExchangeForMessage();
    setupOperationForMessage();
    EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
    EasyMock.expect(message.getExchange()).andReturn(exchange);
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
    EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
    EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
    EasyMock.expect(exchange.get(Exception.class)).andReturn(null);
    EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
    MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
    mhtr.endHandling();
    EasyMock.expectLastCall();
    mhtr.setFaultMode(null);
    EasyMock.expectLastCall();
    EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr).anyTimes();
    EasyMock.replay(mhtr);
    EasyMock.replay(exchange);
    EasyMock.replay(message);
    rtmoi.handleMessage(message);
    EasyMock.verify(message);
    EasyMock.verify(bus);
    EasyMock.verify(exchange);
    EasyMock.verify(mhtr);
}
Also used : MessageHandlingTimeRecorder(org.apache.cxf.management.counters.MessageHandlingTimeRecorder) Test(org.junit.Test)

Example 7 with MessageHandlingTimeRecorder

use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.

the class ResponseTimeMessageInvokerInterceptorTest method testServerOneWayMessageIn.

@Test
public void testServerOneWayMessageIn() {
    // need to increase the counter and is not a client
    setupCounterRepository(true, false);
    setupExchangeForMessage();
    setupOperationForMessage();
    EasyMock.expect(message.getExchange()).andReturn(exchange);
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
    EasyMock.expect(exchange.getOutMessage()).andReturn(message);
    MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
    mhtr.setOneWay(true);
    EasyMock.expectLastCall();
    mhtr.endHandling();
    EasyMock.expectLastCall();
    EasyMock.replay(mhtr);
    EasyMock.expect(exchange.isOneWay()).andReturn(true);
    EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr);
    EasyMock.replay(exchange);
    EasyMock.replay(message);
    rtmii.handleMessage(message);
    EasyMock.verify(message);
    EasyMock.verify(bus);
    EasyMock.verify(exchange);
    EasyMock.verify(mhtr);
}
Also used : MessageHandlingTimeRecorder(org.apache.cxf.management.counters.MessageHandlingTimeRecorder) Test(org.junit.Test)

Example 8 with MessageHandlingTimeRecorder

use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.

the class ResponseTimeMessageInInterceptorTest method testClientMessageIn.

@Test
public void testClientMessageIn() {
    // need to increase the counter and is a client
    setupCounterRepository(true, true);
    setupOperationForMessage();
    setupExchangeForMessage();
    EasyMock.expect(message.getExchange()).andReturn(exchange);
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
    EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
    EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
    EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
    EasyMock.expect(exchange.isOneWay()).andReturn(false);
    MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
    mhtr.endHandling();
    EasyMock.expectLastCall();
    mhtr.setFaultMode(null);
    EasyMock.expectLastCall();
    EasyMock.replay(mhtr);
    EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr);
    EasyMock.replay(exchange);
    EasyMock.replay(message);
    rtmii.handleMessage(message);
    EasyMock.verify(message);
    EasyMock.verify(bus);
    EasyMock.verify(exchange);
    EasyMock.verify(mhtr);
    EasyMock.verify(cRepository);
}
Also used : MessageHandlingTimeRecorder(org.apache.cxf.management.counters.MessageHandlingTimeRecorder) Test(org.junit.Test)

Example 9 with MessageHandlingTimeRecorder

use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.

the class ResponseTimeMessageInInterceptorTest method testServerOneWayMessageIn.

// it would not fire the counter increase action now
@Test
public void testServerOneWayMessageIn() {
    // need to increase the counter and is not a client
    setupCounterRepository(true, false);
    setupExchangeForMessage();
    EasyMock.expect(message.getExchange()).andReturn(exchange);
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
    EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
    EasyMock.expect(exchange.getOutMessage()).andReturn(message);
    MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
    mhtr.beginHandling();
    EasyMock.expectLastCall();
    EasyMock.replay(mhtr);
    EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr);
    EasyMock.replay(exchange);
    EasyMock.replay(message);
    rtmii.handleMessage(message);
    EasyMock.verify(message);
    EasyMock.verify(exchange);
    EasyMock.verify(mhtr);
}
Also used : MessageHandlingTimeRecorder(org.apache.cxf.management.counters.MessageHandlingTimeRecorder) Test(org.junit.Test)

Example 10 with MessageHandlingTimeRecorder

use of org.apache.cxf.management.counters.MessageHandlingTimeRecorder in project cxf by apache.

the class ResponseTimeMessageOutInterceptorTest method testServerFaultMessageOut.

public void testServerFaultMessageOut(FaultMode faultMode) {
    // need to increase the counter and is not a client
    setupCounterRepository(true, false);
    setupExchangeForMessage();
    EasyMock.expect(message.getExchange()).andReturn(exchange);
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
    EasyMock.expect(message.get(FaultMode.class)).andReturn(faultMode).anyTimes();
    EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
    EasyMock.expectLastCall();
    EasyMock.expect(exchange.get(FaultMode.class)).andReturn(faultMode).anyTimes();
    MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
    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);
}
Also used : FaultMode(org.apache.cxf.message.FaultMode) MessageHandlingTimeRecorder(org.apache.cxf.management.counters.MessageHandlingTimeRecorder)

Aggregations

MessageHandlingTimeRecorder (org.apache.cxf.management.counters.MessageHandlingTimeRecorder)10 Test (org.junit.Test)5 FaultMode (org.apache.cxf.message.FaultMode)3 InterceptorChain (org.apache.cxf.interceptor.InterceptorChain)1