cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1363367 - in /cxf/branches/2.5.x-fixes: ./ rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
Date Thu, 19 Jul 2012 15:10:48 GMT
Author: ay
Date: Thu Jul 19 15:10:47 2012
New Revision: 1363367

URL: http://svn.apache.org/viewvc?rev=1363367&view=rev
Log:
Merged revisions 1363363 via  svn merge from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1363363 | ay | 2012-07-19 17:07:10 +0200 (Thu, 19 Jul 2012) | 9 lines
  
  Merged revisions 1363350 via  svn merge from
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1363350 | ay | 2012-07-19 16:29:15 +0200 (Thu, 19 Jul 2012) | 1 line
    
    [CXF-4435] CounterRepository bean not registering to the bus in BP
  ........
  
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
    cxf/branches/2.5.x-fixes/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java

Propchange: cxf/branches/2.5.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java?rev=1363367&r1=1363366&r2=1363367&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
Thu Jul 19 15:10:47 2012
@@ -26,7 +26,6 @@ import java.util.concurrent.locks.Reentr
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.annotation.PostConstruct;
 import javax.management.JMException;
 import javax.management.ObjectName;
 
@@ -56,6 +55,9 @@ public class CounterRepository {
     
     public void setBus(Bus b) {
         bus = b;
+        if (bus != null) {
+            registerInterceptorsToBus();
+        }
     }
 
     public Bus getBus() {
@@ -66,7 +68,6 @@ public class CounterRepository {
         return counters;
     }
     
-    @PostConstruct
     void registerInterceptorsToBus() {
         ResponseTimeMessageInInterceptor in = new ResponseTimeMessageInInterceptor();
         ResponseTimeMessageInvokerInterceptor invoker = new ResponseTimeMessageInvokerInterceptor();

Modified: cxf/branches/2.5.x-fixes/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java?rev=1363367&r1=1363366&r2=1363367&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/management/src/test/java/org/apache/cxf/management/counters/CounterRepositoryTest.java
Thu Jul 19 15:10:47 2012
@@ -18,10 +18,15 @@
  */
 package org.apache.cxf.management.counters;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.management.ObjectName;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.management.InstrumentationManager;
+import org.apache.cxf.message.Message;
 import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.Before;
@@ -29,26 +34,37 @@ import org.junit.Test;
 
 public class CounterRepositoryTest extends Assert {
     private Bus bus;
+    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 InstrumentationManager im;
     private ObjectName serviceCounter;
     private ObjectName operationCounter;
     
     @Before
     public void setUp() throws Exception {
+        inlist.clear();
+        outlist.clear();
         
         serviceCounter = new ObjectName("tandoori:type=counter,service=help");
         operationCounter = new ObjectName("tandoori:type=counter,service=help,operation=me");
-        bus = EasyMock.createMock(Bus.class);        
+        bus = EasyMock.createMock(Bus.class);
+        EasyMock.expect(bus.getInInterceptors()).andReturn(inlist).anyTimes();
+        EasyMock.expect(bus.getOutInterceptors()).andReturn(outlist).anyTimes();
         bus.getExtension(InstrumentationManager.class);
         EasyMock.expectLastCall().andReturn(null).anyTimes();
+
+        cr = new CounterRepository();
+        bus.setExtension(cr, CounterRepository.class);
+        EasyMock.expectLastCall().once();
+        
         EasyMock.replay(bus);
+        cr.setBus(bus);
     }
     
     @Test
     public void testIncreaseOneWayResponseCounter() throws Exception {        
         
-        CounterRepository cr = new CounterRepository();
-        cr.setBus(bus);
         //cr.createCounter(operationCounter, true);
         MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         EasyMock.expect(mhtr.isOneWay()).andReturn(true).anyTimes();
@@ -64,15 +80,13 @@ public class CounterRepositoryTest exten
         assertEquals("The operation counter isn't increased", opCounter.getNumInvocations(),
1);
         assertEquals("The Service counter isn't increased", sCounter.getNumInvocations(),
1);
         
-        EasyMock.verify(bus);
-        EasyMock.verify(mhtr);        
+        verifyBus();
+        EasyMock.verify(mhtr);
     }
     
     @Test
     public void testIncreaseOneWayNoResponseCounter() throws Exception {        
         
-        CounterRepository cr = new CounterRepository();
-        cr.setBus(bus);
         //cr.createCounter(operationCounter, true);
         MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         EasyMock.expect(mhtr.isOneWay()).andReturn(true).anyTimes();
@@ -87,14 +101,12 @@ public class CounterRepositoryTest exten
         assertEquals("The operation counter isn't increased", opCounter.getNumInvocations(),
1);
         assertEquals("The Service counter isn't increased", sCounter.getNumInvocations(),
1);
         
-        EasyMock.verify(bus);
+        verifyBus();
         EasyMock.verify(mhtr);        
     }
     
     @Test
     public void testIncreaseResponseCounter() throws Exception {
-        CounterRepository cr = new CounterRepository();
-        cr.setBus(bus);
         
         MessageHandlingTimeRecorder mhtr1 = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         EasyMock.expect(mhtr1.isOneWay()).andReturn(false).anyTimes();
@@ -142,9 +154,18 @@ public class CounterRepositoryTest exten
         assertTrue(opCounter.getMinResponseTime().longValue() == Integer.MAX_VALUE);
         assertTrue(opCounter.getMaxResponseTime().intValue() == 0);
         
-        EasyMock.verify(bus);
+        verifyBus();
         EasyMock.verify(mhtr1);
         EasyMock.verify(mhtr2);
     }
    
+    
+    private void verifyBus() {
+        EasyMock.verify(bus);
+
+        // the numbers should match the implementation of CounterRepository
+        assertEquals(2, inlist.size());
+        assertEquals(1, outlist.size());
+    }
+
 }



Mime
View raw message