cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [5/6] git commit: [CXF-5847]:More work on enable/disable ResponseTimeCounter in ResponseTimeOutInterCeptor; Remove the unused classes and test; Fix all the tests
Date Mon, 07 Jul 2014 06:44:10 GMT
[CXF-5847]:More work on enable/disable ResponseTimeCounter in ResponseTimeOutInterCeptor;Remove
the unused classes and test;Fix all the tests


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/00e33d37
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/00e33d37
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/00e33d37

Branch: refs/heads/master
Commit: 00e33d37e9edc414047b1584bd6c1598d3a9dbc7
Parents: 828d7e5
Author: Jim Ma <ema@apache.org>
Authored: Mon Jul 7 11:34:09 2014 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Mon Jul 7 14:43:39 2014 +0800

----------------------------------------------------------------------
 .../management/counters/PerformanceCounter.java |  48 -----
 .../counters/PerformanceCounterMBean.java       |  24 ---
 .../ResponseTimeMessageOutInterceptor.java      |  50 +++---
 .../counters/CounterRepositoryTest.java         |   4 +-
 .../AbstractMessageResponseTestBase.java        |  27 +--
 .../ResponseTimeMessageInInterceptor2Test.java  | 176 -------------------
 .../ResponseTimeMessageInInterceptorTest.java   |  46 +++--
 ...sponseTimeMessageInvokerInterceptorTest.java |   2 +-
 .../ResponseTimeMessageOutInterceptorTest.java  |  49 ++----
 9 files changed, 92 insertions(+), 334 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounter.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounter.java
b/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounter.java
deleted file mode 100644
index bf8048d..0000000
--- a/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.management.counters;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.management.JMException;
-import javax.management.ObjectName;
-
-public class PerformanceCounter implements PerformanceCounterMBean, Counter {
-    private AtomicInteger invocations  = new AtomicInteger();
-    private ObjectName objectName;
-    
-
-    public PerformanceCounter(ObjectName on) {
-        objectName = on;
-    }
-
-    public Number getNumInvocations() {        
-        return invocations.get();
-    }
-
-    public void increase(MessageHandlingTimeRecorder mhtr) {
-        invocations.getAndIncrement();
-    }
-
-    public ObjectName getObjectName() throws JMException {        
-        return objectName;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounterMBean.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounterMBean.java
b/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounterMBean.java
deleted file mode 100644
index d1c8ea3..0000000
--- a/rt/management/src/main/java/org/apache/cxf/management/counters/PerformanceCounterMBean.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.management.counters;
-
-public interface PerformanceCounterMBean {
-    Number getNumInvocations();
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
index 9b9bbd1..c0adba0 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
@@ -19,6 +19,7 @@
 package org.apache.cxf.management.interceptor;
 
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.Message;
@@ -29,37 +30,46 @@ public class ResponseTimeMessageOutInterceptor extends AbstractMessageResponseTi
     private EndingInterceptor ending = new EndingInterceptor(); 
 
     public ResponseTimeMessageOutInterceptor() {
-        super(Phase.SEND);
+        super(Phase.PREPARE_SEND_ENDING);
+        addBefore(MessageSenderInterceptor.MessageSenderEndingInterceptor.class.getName());
     }
     
     public void handleMessage(Message message) throws Fault {
         Exchange ex = message.getExchange();
-        if (Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) {
-            return;
-        }
-        if (isClient(message)) {
-            if (ex.isOneWay()) {
-                message.getInterceptorChain().add(ending);
-            } 
-            beginHandlingMessage(ex);
-        } else { // the message is handled by server
-            endHandlingMessage(ex);
+        if (Boolean.TRUE.equals((Boolean)ex.get("org.apache.cxf.management.counter.enabled")))
{
+            if (ex.get(Exception.class) != null) {
+                endHandlingMessage(ex);
+                return;
+            }
+            if (Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) {
+                return;
+            }
+            if (isClient(message)) {
+                if (ex.isOneWay()) {
+                    message.getInterceptorChain().add(ending);
+                }
+                beginHandlingMessage(ex);
+            } else { // the message is handled by server
+                endHandlingMessage(ex);
+            }
         }
     }
     
     @Override
     public void handleFault(Message message) {
         Exchange ex = message.getExchange();
-        if (ex.isOneWay()) {
-            // do nothing, done by the ResponseTimeInvokerInterceptor
-        } else {
-            FaultMode faultMode = message.get(FaultMode.class);
-            if (faultMode == null) {
-                // client side exceptions don't have FaultMode set un the message properties
(as of 2.1.4)
-                faultMode = FaultMode.RUNTIME_FAULT;
+        if (ex.get("org.apache.cxf.management.counter.enabled") != null) {
+            if (ex.isOneWay()) {
+                // do nothing, done by the ResponseTimeInvokerInterceptor
+            } else {
+                FaultMode faultMode = message.get(FaultMode.class);
+                if (faultMode == null) {
+                    // client side exceptions don't have FaultMode set un the message properties
(as of 2.1.4)
+                    faultMode = FaultMode.RUNTIME_FAULT;
+                }
+                ex.put(FaultMode.class, faultMode);
+                endHandlingMessage(ex);
             }
-            ex.put(FaultMode.class, faultMode);
-            endHandlingMessage(ex);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
b/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
index 6571c92..6027949 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
@@ -37,6 +37,7 @@ public class CounterRepositoryTest extends Assert {
     private CounterRepository cr;
     private List<Interceptor<? extends Message>> inlist = new ArrayList<Interceptor<?
extends Message>>();
     private List<Interceptor<? extends Message>> outlist = new ArrayList<Interceptor<?
extends Message>>();
+    private List<Interceptor<? extends Message>> faultlist = new ArrayList<Interceptor<?
extends Message>>();
     //private InstrumentationManager im;
     private ObjectName serviceCounter;
     private ObjectName operationCounter;
@@ -51,6 +52,7 @@ public class CounterRepositoryTest extends Assert {
         bus = EasyMock.createMock(Bus.class);
         EasyMock.expect(bus.getInInterceptors()).andReturn(inlist).anyTimes();
         EasyMock.expect(bus.getOutInterceptors()).andReturn(outlist).anyTimes();
+        EasyMock.expect(bus.getOutFaultInterceptors()).andReturn(faultlist).anyTimes();
         bus.getExtension(InstrumentationManager.class);
         EasyMock.expectLastCall().andReturn(null).anyTimes();
 
@@ -113,7 +115,7 @@ public class CounterRepositoryTest extends Assert {
         EasyMock.expect(mhtr1.getHandlingTime()).andReturn((long)1000).anyTimes();
         EasyMock.expect(mhtr1.getFaultMode()).andReturn(null).anyTimes();
         EasyMock.replay(mhtr1);
-        cr.createCounter(operationCounter, mhtr1);
+        cr.createCounter(operationCounter);
         cr.increaseCounter(serviceCounter, mhtr1);
         cr.increaseCounter(operationCounter, mhtr1);
         ResponseTimeCounter opCounter = (ResponseTimeCounter) cr.getCounter(operationCounter);

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
index 5c345d5..42846b1 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
@@ -88,15 +88,16 @@ public class AbstractMessageResponseTestBase extends Assert {
         }
         BusFactory.setDefaultBus(bus);      
         bus.getExtension(CounterRepository.class);
-        EasyMock.expectLastCall().andReturn(cRepository);
+        EasyMock.expectLastCall().andReturn(cRepository).anyTimes();
         if (increase) {
-            EasyMock.expect(bus.getId()).andReturn(Bus.DEFAULT_BUS_ID);
+            EasyMock.expect(bus.getId()).andReturn(Bus.DEFAULT_BUS_ID).anyTimes();
             cRepository.increaseCounter(EasyMock.eq(serviceCounterOName),
                 EasyMock.isA(MessageHandlingTimeRecorder.class));
             EasyMock.expectLastCall();
             cRepository.increaseCounter(EasyMock.eq(operationCounterOName), 
                 EasyMock.isA(MessageHandlingTimeRecorder.class));
-            EasyMock.expectLastCall(); 
+            EasyMock.expectLastCall();
+            EasyMock.expect(cRepository.getCounter(EasyMock.isA(ObjectName.class))).andReturn(null);
             EasyMock.replay(cRepository);
         }
         
@@ -105,21 +106,27 @@ public class AbstractMessageResponseTestBase extends Assert {
     }
     
     protected void setupExchangeForMessage() {
-        EasyMock.expect(exchange.get(Bus.class)).andReturn(bus);
+        EasyMock.expect(exchange.get(Bus.class)).andReturn(bus).anyTimes();
        
         Service service = EasyMock.createMock(Service.class);
-        EasyMock.expect(service.getName()).andReturn(SERVICE_NAME);        
-        EasyMock.expect(exchange.get(Service.class)).andReturn(service);
+        EasyMock.expect(service.getName()).andReturn(SERVICE_NAME).anyTimes();        
+        EasyMock.expect(exchange.get(Service.class)).andReturn(service).anyTimes();
         EasyMock.replay(service);
         
         Endpoint endpoint = EasyMock.createMock(Endpoint.class);
         EndpointInfo endpointInfo = EasyMock.createMock(EndpointInfo.class);
-        EasyMock.expect(endpointInfo.getName()).andReturn(PORT_NAME);
-        EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo);
-        EasyMock.expect(exchange.get(Endpoint.class)).andReturn(endpoint);
+        EasyMock.expect(endpointInfo.getName()).andReturn(PORT_NAME).anyTimes();
+        EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
+        EasyMock.expect(exchange.get(Endpoint.class)).andReturn(endpoint).anyTimes();
         EasyMock.replay(endpointInfo);
         EasyMock.replay(endpoint);
-        setupOperationForMessage();
+        
+        
+        //EasyMock.expect(exchange.getBus()).andReturn(bus);
+        EasyMock.expect(exchange.get("org.apache.cxf.management.service.counter.name")).andReturn(null).anyTimes();
+        
+            
+        
     }
       
     protected void setupOperationForMessage() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java
deleted file mode 100644
index 085fbf3..0000000
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.management.interceptor;
-
-import org.apache.cxf.management.counters.MessageHandlingTimeRecorder;
-import org.apache.cxf.message.FaultMode;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
-import org.apache.cxf.service.model.OperationInfo;
-import org.easymock.EasyMock;
-
-import org.junit.Test;
-
-public class ResponseTimeMessageInInterceptor2Test extends AbstractMessageResponseTestBase
{
-   
-    private ResponseTimeMessageInInterceptor rtmii = new ResponseTimeMessageInInterceptor();
-    
-    @Test
-    public void testClientMessageIn() {
-        // need to increase the counter and is a client
-        setupCounterRepository(true, true);
-        setupExchangeForMessage();
-        EasyMock.expect(message.getExchange()).andReturn(exchange);
-        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
-        EasyMock.expect(exchange.getOutMessage()).andReturn(message);
-        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);
-        
-    }
-
-    @Test
-    public void testClientCheckedApplicationFaultMessageIn() {
-        testClientFaultMessageIn(FaultMode.CHECKED_APPLICATION_FAULT);
-    }
-
-    @Test
-    public void testClientLogicalFaultMessageIn() {
-        testClientFaultMessageIn(FaultMode.LOGICAL_RUNTIME_FAULT);
-    }
-
-    @Test
-    public void testClientRuntimeFaultMessageIn() {
-        testClientFaultMessageIn(FaultMode.RUNTIME_FAULT);
-    }
-
-    @Test
-    public void testClientUncheckedApplicationFaultMessageIn() {
-        testClientFaultMessageIn(FaultMode.UNCHECKED_APPLICATION_FAULT);
-    }
-
-    public void testClientFaultMessageIn(FaultMode faultMode) {
-        // need to increase the counter and is a client
-        setupCounterRepository(true, true);
-        setupExchangeForMessage();
-        EasyMock.expect(message.getExchange()).andReturn(exchange);
-        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
-        EasyMock.expect(message.get(FaultMode.class)).andReturn(faultMode).anyTimes();
-        EasyMock.expect(exchange.getOutMessage()).andReturn(message);
-        exchange.put(FaultMode.class, faultMode);
-        EasyMock.expectLastCall();
-        EasyMock.expect(exchange.get(FaultMode.class)).andReturn(faultMode).anyTimes();
-        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);
-        
-        rtmii.handleFault(message);
-        EasyMock.verify(message);
-        EasyMock.verify(bus);
-        EasyMock.verify(exchange);
-        EasyMock.verify(mhtr);
-        EasyMock.verify(cRepository);
-        
-    }
-
-    
-    // it would not fire the counter increase action now
-    @Test
-    public void testServerOneWayMessageIn() {
-        // need to increase the counter and is not a client
-        //setupCounterRepository(false, false);
-        //setupExchangeForMessage();
-        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.beginHandling();
-        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);
-        //EasyMock.verify(cRepository);
-    }
-    
-    @Test
-    public void testServiceMessageIn() {
-        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE);
-        EasyMock.expect(message.getExchange()).andReturn(exchange);
-        //EasyMock.expect(exchange.isOneWay()).andReturn(false);
-        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null);
    
-        exchange.put(EasyMock.eq(MessageHandlingTimeRecorder.class), 
-                     EasyMock.isA(MessageHandlingTimeRecorder.class));
-        EasyMock.replay(exchange);
-        EasyMock.replay(message);
-        rtmii.handleMessage(message);        
-        EasyMock.verify(message);        
-        EasyMock.verify(exchange);
-        
-    }
-    
-    public void testIsClient() {
-        Message message1 = null;
-        Message message2 = new MessageImpl();
-        Message message3 = new MessageImpl();
-        message3.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
-        assertTrue("the message should not be client", !rtmii.isClient(message1));
-        assertTrue("the message should not be client", !rtmii.isClient(message2));
-        assertTrue("the message should be client", rtmii.isClient(message3));
-    }
-
-    @Override
-    protected void setupOperationForMessage() {
-        EasyMock.expect(exchange.get(OperationInfo.class)).andReturn(null);
-        EasyMock.expect(exchange.get("org.apache.cxf.resource.operation.name"))
-            .andReturn(OPERATION_NAME.getLocalPart());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
index dcb4bbf..9f52bf6 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
@@ -24,20 +24,26 @@ import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.easymock.EasyMock;
+
 import org.junit.Test;
 
 public class ResponseTimeMessageInInterceptorTest extends AbstractMessageResponseTestBase
{
    
     private ResponseTimeMessageInInterceptor rtmii = new ResponseTimeMessageInInterceptor();
+    private ResponseTimeMessageOutInterceptor rtmoi = new ResponseTimeMessageOutInterceptor();
     
     @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);
+        EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
+        EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
+        EasyMock.expect(exchange.put("org.apache.cxf.management.counter.enabled", true)).andReturn(true);
+        
         EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
         EasyMock.expect(exchange.isOneWay()).andReturn(false);
         MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
@@ -84,13 +90,16 @@ public class ResponseTimeMessageInInterceptorTest extends AbstractMessageRespons
         // 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(message.get(FaultMode.class)).andReturn(faultMode).anyTimes();
-        EasyMock.expect(exchange.getOutMessage()).andReturn(message);
+        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();        
@@ -102,13 +111,11 @@ public class ResponseTimeMessageInInterceptorTest extends AbstractMessageRespons
         EasyMock.replay(exchange);
         EasyMock.replay(message);
         
-        rtmii.handleFault(message);
+        rtmoi.handleFault(message);
         EasyMock.verify(message);
         EasyMock.verify(bus);
         EasyMock.verify(exchange);
-        EasyMock.verify(mhtr);
-        EasyMock.verify(cRepository);
-        
+        EasyMock.verify(mhtr);        
     }
 
     
@@ -116,35 +123,40 @@ public class ResponseTimeMessageInInterceptorTest extends AbstractMessageRespons
     @Test
     public void testServerOneWayMessageIn() {
         // need to increase the counter and is not a client
-        //setupCounterRepository(false, false);
-        //setupExchangeForMessage();
+        setupCounterRepository(true, false);
+        setupExchangeForMessage();
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
-        //EasyMock.expect(exchange.getOutMessage()).andReturn(message);
+        EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
+        EasyMock.expect(exchange.put("org.apache.cxf.management.counter.enabled", true)).andReturn(true);
+        EasyMock.expect(exchange.getOutMessage()).andReturn(message);
         MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         mhtr.beginHandling();
         EasyMock.expectLastCall();
          
         EasyMock.replay(mhtr);
-        //EasyMock.expect(exchange.isOneWay()).andReturn(true);
-        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(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);
     }
     
     @Test
     public void testServiceMessageIn() {
-        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE);
+        setupCounterRepository(true, false);
+        setupExchangeForMessage();
+        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(message.getExchange()).andReturn(exchange);
-        //EasyMock.expect(exchange.isOneWay()).andReturn(false);
-        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null);
    
+        EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
+        EasyMock.expect(exchange.getOutMessage()).andReturn(message);
+        EasyMock.expect(exchange.put("org.apache.cxf.management.counter.enabled", true)).andReturn(true);

+        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null);
         exchange.put(EasyMock.eq(MessageHandlingTimeRecorder.class), 
                      EasyMock.isA(MessageHandlingTimeRecorder.class));
         EasyMock.replay(exchange);

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptorTest.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptorTest.java
index 66809ee..9eda209 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptorTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptorTest.java
@@ -36,6 +36,7 @@ public class ResponseTimeMessageInvokerInterceptorTest extends AbstractMessageRe
         // 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);
@@ -56,6 +57,5 @@ public class ResponseTimeMessageInvokerInterceptorTest extends AbstractMessageRe
         EasyMock.verify(bus);
         EasyMock.verify(exchange);
         EasyMock.verify(mhtr);
-        EasyMock.verify(cRepository);
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/00e33d37/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
index 788b388..1c49393 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
@@ -37,16 +37,10 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         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);
-        EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
-        MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
-        mhtr.setFaultMode(null);
-        EasyMock.expectLastCall();
-        mhtr.endHandling();
-        EasyMock.expectLastCall();              
-         
-        EasyMock.replay(mhtr);
-        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr);
       
+
+        EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
+        MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
        
+        EasyMock.replay(mhtr);      
         EasyMock.replay(exchange);
         EasyMock.replay(message);
         
@@ -55,8 +49,6 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         EasyMock.verify(bus);
         EasyMock.verify(exchange);
         EasyMock.verify(mhtr);
-        EasyMock.verify(cRepository);
-        
     }
 
     @Test
@@ -86,19 +78,13 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         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.getOutMessage()).andReturn(message);
-        exchange.put(FaultMode.class, faultMode);
+        EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
         EasyMock.expectLastCall();
-        EasyMock.expect(exchange.isOneWay()).andReturn(false);
         EasyMock.expect(exchange.get(FaultMode.class)).andReturn(faultMode).anyTimes();
-        MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
-        mhtr.setFaultMode(faultMode);
-        EasyMock.expectLastCall();
-        mhtr.endHandling();
-        EasyMock.expectLastCall();              
+        MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         
         
         EasyMock.replay(mhtr);
-        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr);
       
+        //EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr);
       
         EasyMock.replay(exchange);
         EasyMock.replay(message);
         
@@ -107,8 +93,6 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         EasyMock.verify(bus);
         EasyMock.verify(exchange);
         EasyMock.verify(mhtr);
-        EasyMock.verify(cRepository);
-        
     }
 
     @Test
@@ -116,21 +100,18 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         //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);
         EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
-        //MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
-        //mhtr.setOneWay(true);
-        //EasyMock.expectLastCall();
-         
-        //EasyMock.replay(mhtr);
         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(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);
+        //EasyMock.expect(message.getInterceptorChain()).andReturn(chain);
         chain.add(EasyMock.isA(ResponseTimeMessageOutInterceptor.EndingInterceptor.class));
         EasyMock.expectLastCall();
         EasyMock.replay(exchange);
@@ -142,19 +123,13 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         EasyMock.verify(message);
         EasyMock.verify(bus);
         EasyMock.verify(exchange);
-        //EasyMock.verify(mhtr);
-        EasyMock.verify(cRepository);
     }
     
     @Test
     public void testClientMessageOut() {
         EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
-        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE);
         EasyMock.expect(message.getExchange()).andReturn(exchange);
-        EasyMock.expect(exchange.isOneWay()).andReturn(false);
-        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null);
    
-        exchange.put(EasyMock.eq(MessageHandlingTimeRecorder.class), 
-                     EasyMock.isA(MessageHandlingTimeRecorder.class));
+        EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
         EasyMock.replay(exchange);
         EasyMock.replay(message);
         rtmoi.handleMessage(message);        


Mime
View raw message