camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r961566 - in /camel/trunk/camel-core/src/test/java/org/apache/camel: management/ processor/
Date Thu, 08 Jul 2010 03:37:45 GMT
Author: hadrian
Date: Thu Jul  8 03:37:44 2010
New Revision: 961566

URL: http://svn.apache.org/viewvc?rev=961566&view=rev
Log:
CAMEL-2716. Enforce cleanup of jmx properties after running tests

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableOnCamelContextTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPlatformMBSTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPropertiesTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/MultiInstanceProcessorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java
Thu Jul  8 03:37:44 2010
@@ -51,10 +51,7 @@ public class JmxInstrumentationCustomMBe
     }
 
     public void testCustomEndpoint() throws Exception {
-        if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
-                && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
-            assertEquals(domainName, mbsc.getDefaultDomain());
-        }
+        assertDefaultDomain();
 
         resolveMandatoryEndpoint("custom://end", CustomEndpoint.class);
 
@@ -73,12 +70,8 @@ public class JmxInstrumentationCustomMBe
         }
     }
 
-    @SuppressWarnings("unchecked")
     public void testManagedEndpoint() throws Exception {
-        if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
-                && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
-            assertEquals(domainName, mbsc.getDefaultDomain());
-        }
+        assertDefaultDomain();
 
         resolveMandatoryEndpoint("direct:start", DirectEndpoint.class);
 
@@ -98,10 +91,7 @@ public class JmxInstrumentationCustomMBe
     }
 
     public void testMBeansRegistered() throws Exception {
-        if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
-                && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
-            assertEquals(domainName, mbsc.getDefaultDomain());
-        }
+        assertDefaultDomain();
 
         Set<ObjectName> s = CastUtils.cast(mbsc.queryNames(new ObjectName(domainName
+ ":type=endpoints,*"), null));
         assertEquals("Could not find 2 endpoints: " + s, 2, s.size());

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableOnCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableOnCamelContextTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableOnCamelContextTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableOnCamelContextTest.java
Thu Jul  8 03:37:44 2010
@@ -44,14 +44,11 @@ public class JmxInstrumentationDisableOn
 
     @Override
     public void testMBeansRegistered() throws Exception {
-        if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
-                && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
-            assertEquals(domainName, mbsc.getDefaultDomain());
-        }
+        assertDefaultDomain();
 
         resolveMandatoryEndpoint("mock:end", MockEndpoint.class);
 
-        Set s = mbsc.queryNames(new ObjectName(domainName + ":type=endpoints,*"), null);
+        Set<ObjectName> s = mbsc.queryNames(new ObjectName(domainName + ":type=endpoints,*"),
null);
         assertEquals("Could not find 0 endpoints: " + s, 0, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=contexts,*"), null);
@@ -66,7 +63,7 @@ public class JmxInstrumentationDisableOn
 
     @Override
     protected void verifyCounter(MBeanServerConnection beanServer, ObjectName name) throws
Exception {
-        Set s = beanServer.queryNames(name, null);
+        Set<ObjectName> s = beanServer.queryNames(name, null);
         assertEquals("Found mbeans: " + s, 0, s.size());
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationDisableTest.java
Thu Jul  8 03:37:44 2010
@@ -37,14 +37,11 @@ public class JmxInstrumentationDisableTe
 
     @Override
     public void testMBeansRegistered() throws Exception {
-        if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
-                && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
-            assertEquals(domainName, mbsc.getDefaultDomain());
-        }
+        assertDefaultDomain();
 
         resolveMandatoryEndpoint("mock:end", MockEndpoint.class);
 
-        Set s = mbsc.queryNames(new ObjectName(domainName + ":type=endpoints,*"), null);
+        Set<ObjectName> s = mbsc.queryNames(new ObjectName(domainName + ":type=endpoints,*"),
null);
         assertEquals("Could not find 0 endpoints: " + s, 0, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=contexts,*"), null);
@@ -59,8 +56,7 @@ public class JmxInstrumentationDisableTe
 
     @Override
     protected void verifyCounter(MBeanServerConnection beanServer, ObjectName name) throws
Exception {
-        Set s = beanServer.queryNames(name, null);
+        Set<ObjectName> s = beanServer.queryNames(name, null);
         assertEquals("Found mbeans: " + s, 0, s.size());
     }
-
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
Thu Jul  8 03:37:44 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.management;
 
+import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.util.Iterator;
 import java.util.List;
@@ -47,11 +48,15 @@ public class JmxInstrumentationUsingDefa
         return true;
     }
 
-    public void testMBeansRegistered() throws Exception {
+    protected void assertDefaultDomain() throws IOException {
         if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
                 && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
             assertEquals(domainName, mbsc.getDefaultDomain());
         }
+    }
+
+    public void testMBeansRegistered() throws Exception {
+        assertDefaultDomain();
 
         template.sendBody("direct:start", "Hello World");
 
@@ -169,9 +174,19 @@ public class JmxInstrumentationUsingDefa
 
     @Override
     protected void tearDown() throws Exception {
-        super.tearDown();
-        releaseMBeanServers();
-        mbsc = null;
+        try {
+            super.tearDown();
+            releaseMBeanServers();
+            mbsc = null;
+        } finally {
+            // restore environment to original state
+            // the following properties may have been set by specialization of this test
class
+            System.clearProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS);
+            System.clearProperty(JmxSystemPropertyKeys.DOMAIN);
+            System.clearProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN);
+            System.clearProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR);
+            System.clearProperty(JmxSystemPropertyKeys.REGISTRY_PORT);
+        }
     }
 
     protected void releaseMBeanServers() {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPlatformMBSTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPlatformMBSTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPlatformMBSTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPlatformMBSTest.java
Thu Jul  8 03:37:44 2010
@@ -38,17 +38,11 @@ public class JmxInstrumentationUsingPlat
 
     @Override
     protected void setUp() throws Exception {
-        System.setProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS, "False");
+        System.setProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS, "false");
         super.setUp();
     }
 
     @Override
-    protected void tearDown() throws Exception {
-        System.clearProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS);
-        super.tearDown();
-    }
-
-    @Override
     public void testMBeanServerType() throws Exception {
         try {
             mbsc.getMBeanInfo(new ObjectName("java.lang:type=OperatingSystem"));

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPropertiesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPropertiesTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPropertiesTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingPropertiesTest.java
Thu Jul  8 03:37:44 2010
@@ -39,18 +39,8 @@ public class JmxInstrumentationUsingProp
         super.setUp();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        // restore environment to original state
-        System.clearProperty(JmxSystemPropertyKeys.DOMAIN);
-        System.clearProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN);
-        super.tearDown();
-    }
-
     public void testMBeanServerType() throws Exception {
         // default is platform mbs
-        assertNotNull(mbsc.getMBeanInfo(new ObjectName("java.lang:type=OperatingSystem")));
-        
+        assertNotNull(mbsc.getMBeanInfo(new ObjectName("java.lang:type=OperatingSystem")));
       
     }
-
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
Thu Jul  8 03:37:44 2010
@@ -48,19 +48,15 @@ public class JmxInstrumentationWithConne
     @Override
     protected void setUp() throws Exception {
         sleepForConnection = 3000;
-        System.setProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR, "true");
         // need to explicit set it to false to use non-platform mbs
         System.setProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS, "false");
+        System.setProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR, "true");
         System.setProperty(JmxSystemPropertyKeys.REGISTRY_PORT, "2123");
         super.setUp();
     }
 
     @Override
     protected void tearDown() throws Exception {
-        System.clearProperty(JmxSystemPropertyKeys.REGISTRY_PORT);
-        System.clearProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR);
-        System.clearProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS);
-
         if (clientConnector != null) {
             try {
                 clientConnector.close();
@@ -82,5 +78,4 @@ public class JmxInstrumentationWithConne
         }
         return mbsc;
     }
-
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/MultiInstanceProcessorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/MultiInstanceProcessorTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/MultiInstanceProcessorTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/MultiInstanceProcessorTest.java
Thu Jul  8 03:37:44 2010
@@ -55,10 +55,7 @@ public class MultiInstanceProcessorTest 
      */
     @Override
     public void testMBeansRegistered() throws Exception {
-        if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
-                && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
-            assertEquals(domainName, mbsc.getDefaultDomain());
-        }
+        assertDefaultDomain();
 
         resolveMandatoryEndpoint("mock:end", MockEndpoint.class);
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java?rev=961566&r1=961565&r2=961566&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java Thu
Jul  8 03:37:44 2010
@@ -24,7 +24,6 @@ import org.apache.camel.Route;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.EventDrivenConsumerRoute;
-import org.apache.camel.management.JmxSystemPropertyKeys;
 import org.apache.camel.processor.interceptor.StreamCaching;
 
 /**
@@ -49,9 +48,13 @@ public class ResequencerTest extends Con
     @Override 
     protected void tearDown() throws Exception {
         super.tearDown();
-        System.clearProperty(JmxSystemPropertyKeys.DISABLED);
     }
     
+    protected boolean useJmx() {
+        // use jmx only when running the following test(s)
+        return getName().equals("testBatchResequencerTypeWithJmx");
+    }
+
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
@@ -63,7 +66,6 @@ public class ResequencerTest extends Con
     }
 
     public void testBatchResequencerTypeWithJmx() throws Exception {
-        System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
         testBatchResequencerTypeWithoutJmx();
     }
 



Mime
View raw message