camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r807573 [3/3] - in /camel/trunk: camel-core/ camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/component/seda/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/mana...
Date Tue, 25 Aug 2009 11:57:55 GMT
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java Tue Aug 25 11:57:51 2009
@@ -88,7 +88,7 @@
         assertMockEndpointsSatisfied();
 
         // this should take the when path
-        assertEquals("#choice2##when3#", ids);
+        assertEquals("#choice4##when2#", ids);
     }
 
     /**
@@ -102,7 +102,7 @@
         assertMockEndpointsSatisfied();
 
         // this should take the otherwise path
-        assertEquals("#choice2##otherwise4#", ids);
+        assertEquals("#choice4##otherwise3#", ids);
     }
 
     private class MyDebuggerCheckingId implements InterceptStrategy {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TwoTimerWithJMXIssue.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TwoTimerWithJMXIssue.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TwoTimerWithJMXIssue.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TwoTimerWithJMXIssue.java Tue Aug 25 11:57:51 2009
@@ -59,8 +59,8 @@
 
     private class MyTracer implements InterceptStrategy {
 
-        public Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition definition, Processor target, Processor nextTarget)
-                throws Exception {
+        public Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition definition,
+                                                     Processor target, Processor nextTarget) throws Exception {
             assertNotNull(target);
             counter++;
             return target;

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,128 @@
+/**
+ * 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.camel.management;
+
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.management.event.CamelContextStartedEvent;
+import org.apache.camel.management.event.CamelContextStartingEvent;
+import org.apache.camel.management.event.CamelContextStoppedEvent;
+import org.apache.camel.management.event.CamelContextStoppingEvent;
+import org.apache.camel.management.event.ExchangeCompletedEvent;
+import org.apache.camel.management.event.ExchangeCreatedEvent;
+import org.apache.camel.management.event.ExchangeFailedEvent;
+import org.apache.camel.management.event.RouteStartEvent;
+import org.apache.camel.management.event.RouteStopEvent;
+import org.apache.camel.spi.EventNotifier;
+
+/**
+ * @version $Revision$
+ */
+public class EventNotifierEventsTest extends ContextTestSupport {
+
+    private static List<EventObject> events = new ArrayList<EventObject>();
+
+    @Override
+    public void setUp() throws Exception {
+        events.clear();
+        super.setUp();
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        DefaultCamelContext context = new DefaultCamelContext(createRegistry());
+        context.getManagementStrategy().setEventNotifier(new EventNotifier() {
+            public void notify(EventObject event) throws Exception {
+                events.add(event);
+            }
+
+            public boolean isEnabled(EventObject event) {
+                return true;
+            }
+        });
+        return context;
+    }
+
+    public void testExchangeDone() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        assertEquals(6, events.size());
+        assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
+        assertIsInstanceOf(RouteStartEvent.class, events.get(1));
+        assertIsInstanceOf(RouteStartEvent.class, events.get(2));
+        assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
+        assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(4));
+        assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(5));
+
+        context.stop();
+
+        assertEquals(10, events.size());
+        assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(6));
+        assertIsInstanceOf(RouteStopEvent.class, events.get(7));
+        assertIsInstanceOf(RouteStopEvent.class, events.get(8));
+        assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(9));
+    }
+
+    public void testExchangeFailed() throws Exception {
+        try {
+            template.sendBody("direct:fail", "Hello World");
+            fail("Should have thrown an exception");
+        } catch (Exception e) {
+            // expected
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+        }
+
+        assertEquals(6, events.size());
+        assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
+        assertIsInstanceOf(RouteStartEvent.class, events.get(1));
+        assertIsInstanceOf(RouteStartEvent.class, events.get(2));
+        assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
+        assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(4));
+        assertIsInstanceOf(ExchangeFailedEvent.class, events.get(5));
+
+        context.stop();
+
+        assertEquals(10, events.size());
+        assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(6));
+        assertIsInstanceOf(RouteStopEvent.class, events.get(7));
+        assertIsInstanceOf(RouteStopEvent.class, events.get(8));
+        assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(9));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").to("mock:result");
+
+                from("direct:fail").throwException(new IllegalArgumentException("Damn"));
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=807573&r1=807572&r2=807573&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 Tue Aug 25 11:57:51 2009
@@ -81,7 +81,6 @@
         resultEndpoint.assertIsSatisfied();
 
         verifyCounter(mbsc, new ObjectName(domainName + ":type=routes,*"));
-        verifyCounter(mbsc, new ObjectName(domainName + ":type=processors,*"));
     }
 
     @Override

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationOnlyRegisterProcessorWithCustomIdTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationOnlyRegisterProcessorWithCustomIdTest.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationOnlyRegisterProcessorWithCustomIdTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationOnlyRegisterProcessorWithCustomIdTest.java Tue Aug 25 11:57:51 2009
@@ -17,13 +17,11 @@
 package org.apache.camel.management;
 
 import java.lang.management.ManagementFactory;
-import java.util.List;
 import java.util.Set;
 import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -34,29 +32,24 @@
 public class JmxInstrumentationOnlyRegisterProcessorWithCustomIdTest extends ContextTestSupport {
 
     protected String domainName = DefaultInstrumentationAgent.DEFAULT_DOMAIN;
-    protected MBeanServerConnection mbsc;
-    protected long sleepForConnection;
+    protected MBeanServer server;
 
     public void testCustomId() throws Exception {
-        if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null
-                && !Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS)) {
-            assertEquals(domainName, mbsc.getDefaultDomain());
-        }
-
-        Set s = mbsc.queryNames(new ObjectName(domainName + ":type=endpoints,*"), null);
+        Set s = server.queryNames(new ObjectName(domainName + ":type=endpoints,*"), null);
         assertEquals("Could not find 2 endpoints: " + s, 6, s.size());
 
-        s = mbsc.queryNames(new ObjectName(domainName + ":type=context,*"), null);
+        s = server.queryNames(new ObjectName(domainName + ":type=context,*"), null);
         assertEquals("Could not find 1 context: " + s, 1, s.size());
 
-        s = mbsc.queryNames(new ObjectName(domainName + ":type=processors,*"), null);
+        s = server.queryNames(new ObjectName(domainName + ":type=processors,*"), null);
         assertEquals("Could not find 1 processor: " + s, 1, s.size());
         // should be mock foo
         ObjectName on = (ObjectName) s.iterator().next();
-        assertEquals("myfoo", on.getKeyProperty("nodeid"));
+        String id = (String) server.getAttribute(on, "Id");
+        assertEquals("myfoo", id);
 
-        s = mbsc.queryNames(new ObjectName(domainName + ":type=routes,*"), null);
-        assertEquals("Could not find 1 route: " + s, 2, s.size());
+        s = server.queryNames(new ObjectName(domainName + ":type=routes,*"), null);
+        assertEquals("Could not find 2 route: " + s, 2, s.size());
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
@@ -67,36 +60,16 @@
     }
 
     @Override
-    protected void tearDown() throws Exception {
-        System.clearProperty(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID);
-        releaseMBeanServers();
-        mbsc = null;
-        super.tearDown();
-    }
-
-    @SuppressWarnings("unchecked")
-    protected void releaseMBeanServers() {
-        List<MBeanServer> servers = (List<MBeanServer>) MBeanServerFactory.findMBeanServer(null);
-        for (MBeanServer server : servers) {
-            MBeanServerFactory.releaseMBeanServer(server);
-        }
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        context.getManagementStrategy().onlyManageProcessorWithCustomId(true);
+        return context;
     }
 
     @Override
     protected void setUp() throws Exception {
-        System.setProperty(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID, "true");
-        releaseMBeanServers();
         super.setUp();
-        Thread.sleep(sleepForConnection);
-        mbsc = getMBeanConnection();
-    }
-
-
-    protected MBeanServerConnection getMBeanConnection() throws Exception {
-        if (mbsc == null) {
-            mbsc = ManagementFactory.getPlatformMBeanServer();
-        }
-        return mbsc;
+        server = ManagementFactory.getPlatformMBeanServer();
     }
 
     @Override

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=807573&r1=807572&r2=807573&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 Tue Aug 25 11:57:51 2009
@@ -65,7 +65,7 @@
         assertEquals("Could not find 1 context: " + s, 1, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=processors,*"), null);
-        assertEquals("Could not find 1 processor: " + s, 1, s.size());
+        assertEquals("Could not find 2 processors: " + s, 2, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=routes,*"), null);
         assertEquals("Could not find 1 route: " + s, 1, s.size());
@@ -83,7 +83,6 @@
         resultEndpoint.assertIsSatisfied();
 
         verifyCounter(mbsc, new ObjectName(domainName + ":type=routes,*"));
-        verifyCounter(mbsc, new ObjectName(domainName + ":type=processors,*"));
     }
 
     protected void verifyCounter(MBeanServerConnection beanServer, ObjectName name) throws Exception {
@@ -93,48 +92,60 @@
         Iterator iter = s.iterator();
         ObjectName pcob = (ObjectName)iter.next();
 
-        Long valueofNumExchanges = (Long)beanServer.getAttribute(pcob, "NumExchanges");
+        Long valueofNumExchanges = (Long)beanServer.getAttribute(pcob, "ExchangesTotal");
         assertNotNull("Expected attribute found. MBean registered under a "
                       + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
                       valueofNumExchanges);
         assertEquals(Long.valueOf(1), valueofNumExchanges);
-        Long valueofNumCompleted = (Long)beanServer.getAttribute(pcob, "NumCompleted");
+
+        Long valueofNumCompleted = (Long)beanServer.getAttribute(pcob, "ExchangesCompleted");
         assertNotNull("Expected attribute found. MBean registered under a "
                       + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
                       valueofNumCompleted);
         assertEquals(Long.valueOf(1), valueofNumCompleted);
-        Long valueofNumFailed = (Long)beanServer.getAttribute(pcob, "NumFailed");
+
+        Long valueofNumFailed = (Long)beanServer.getAttribute(pcob, "ExchangesFailed");
         assertNotNull("Expected attribute found. MBean registered under a "
                       + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
                       valueofNumFailed);
         assertEquals(Long.valueOf(0), valueofNumFailed);
-        Double valueofMinProcessingTime = (Double)beanServer.getAttribute(pcob, "MinProcessingTimeMillis");
+
+        Long valueofMinProcessingTime = (Long)beanServer.getAttribute(pcob, "MinProcessingTime");
         assertNotNull("Expected attribute found. MBean registered under a "
                       + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
                       valueofMinProcessingTime);
-        assertTrue(valueofMinProcessingTime > 0);
-        Double valueofMaxProcessingTime = (Double)beanServer.getAttribute(pcob, "MaxProcessingTimeMillis");
+        assertTrue(valueofMinProcessingTime >= 0);
+
+        Long valueofMaxProcessingTime = (Long)beanServer.getAttribute(pcob, "MaxProcessingTime");
         assertNotNull("Expected attribute found. MBean registered under a "
                       + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
                       valueofMaxProcessingTime);
-        assertTrue(valueofMaxProcessingTime > 0);
-        Double valueofMeanProcessingTime = (Double)beanServer.getAttribute(pcob, "MeanProcessingTimeMillis");
+        assertTrue(valueofMaxProcessingTime >= 0);
+
+        Long valueofMeanProcessingTime = (Long)beanServer.getAttribute(pcob, "MeanProcessingTime");
         assertNotNull("Expected attribute found. MBean registered under a "
                       + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
                       valueofMeanProcessingTime);
         assertTrue(valueofMeanProcessingTime >= valueofMinProcessingTime
                    && valueofMeanProcessingTime <= valueofMaxProcessingTime);
-        Double totalProcessingTime = (Double)beanServer.getAttribute(pcob, "TotalProcessingTimeMillis");
+
+        Long totalProcessingTime = (Long)beanServer.getAttribute(pcob, "TotalProcessingTime");
         assertNotNull("Expected attribute found. MBean registered under a "
                       + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
                       totalProcessingTime);
-        assertTrue(totalProcessingTime > 0);
+        assertTrue(totalProcessingTime >= 0);
+
+        Long lastProcessingTime = (Long)beanServer.getAttribute(pcob, "LastProcessingTime");
+        assertNotNull("Expected attribute found. MBean registered under a "
+                      + "'<domain>:name=Stats,*' key must be of type PerformanceCounter.class",
+                      lastProcessingTime);
+        assertTrue(lastProcessingTime >= 0);
 
         assertNotNull("Expected first completion time to be available",
-                beanServer.getAttribute(pcob, "FirstExchangeCompletionTime"));
+                beanServer.getAttribute(pcob, "FirstExchangeCompletedTime"));
 
         assertNotNull("Expected last completion time to be available",
-                beanServer.getAttribute(pcob, "LastExchangeCompletionTime"));
+                beanServer.getAttribute(pcob, "LastExchangeCompletedTime"));
     }
 
     protected RouteBuilder createRouteBuilder() {

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=807573&r1=807572&r2=807573&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 Tue Aug 25 11:57:51 2009
@@ -66,8 +66,8 @@
                 }
             }
         }
-
         return mbsc;
     }
 
+
 }

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=807573&r1=807572&r2=807573&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 Tue Aug 25 11:57:51 2009
@@ -29,8 +29,7 @@
  */
 public class JmxInstrumentationWithConnectorTest extends JmxInstrumentationUsingDefaultsTest {
 
-    protected static final String JMXSERVICEURL =
-        "service:jmx:rmi:///jndi/rmi://localhost:2123/jmxrmi/camel";
+    protected static final String JMXSERVICEURL = "service:jmx:rmi:///jndi/rmi://localhost:2123/jmxrmi/camel";
     protected JMXConnector clientConnector;
 
     protected boolean canRunOnThisPlatform() {

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedBrowseableEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedBrowseableEndpointTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedBrowseableEndpointTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedBrowseableEndpointTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,77 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedBrowseableEndpointTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testBrowseableEndpoint() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(2);
+
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Bye World");
+
+        assertMockEndpointsSatisfied();
+
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://result\"");
+        String uri = (String) mbeanServer.getAttribute(name, "Uri");
+        assertEquals("mock://result", uri);
+
+        Long size = (Long) mbeanServer.invoke(name, "qeueSize", null, null);
+        assertEquals(2, size.longValue());
+
+        Exchange exchange = (Exchange) mbeanServer.invoke(name, "browseExchange", new Object[]{0}, new String[]{"java.lang.Integer"});
+        assertNotNull(exchange);
+        assertEquals("Hello World", exchange.getIn().getBody());
+
+        exchange = (Exchange) mbeanServer.invoke(name, "browseExchange", new Object[]{1}, new String[]{"java.lang.Integer"});
+        assertNotNull(exchange);
+        assertEquals("Bye World", exchange.getIn().getBody());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedBrowseableEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedBrowseableEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedDelayerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedDelayerTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedDelayerTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedDelayerTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,97 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Expression;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedDelayerTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testManageDelay() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        // get the stats for the route
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        // get the object name for the delayer
+        ObjectName delayerName = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=processors,name=\"mydelayer\"");
+
+        // use route to get the total time
+        ObjectName routeName = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=routes,name=\"route1\"");
+        Long completed = (Long) mbeanServer.getAttribute(routeName, "ExchangesCompleted");
+        assertEquals(1, completed.longValue());
+
+        Long last = (Long) mbeanServer.getAttribute(routeName, "LastProcessingTime");
+        Long total = (Long) mbeanServer.getAttribute(routeName, "TotalProcessingTime");
+
+        assertTrue("Should take around 1 sec: was " + last, last > 900);
+        assertTrue("Should take around 1 sec: was " + total, total > 900);
+
+        // change the delay time using JMX
+        mbeanServer.invoke(delayerName, "constantDelay", new Object[]{2000}, new String[]{"java.lang.Integer"});
+
+        // send in another message
+        template.sendBody("direct:start", "Bye World");
+
+        Expression delay = (Expression) mbeanServer.getAttribute(delayerName, "Delay");
+        assertNotNull(delay);
+
+        completed = (Long) mbeanServer.getAttribute(routeName, "ExchangesCompleted");
+        assertEquals(2, completed.longValue());
+        last = (Long) mbeanServer.getAttribute(routeName, "LastProcessingTime");
+        total = (Long) mbeanServer.getAttribute(routeName, "TotalProcessingTime");
+
+        assertTrue("Should take around 2 sec: was " + last, last > 1900);
+        assertTrue("Should be around 3 sec now: was " + total, total > 2900);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("log:foo")
+                    .delay(1000).id("mydelayer")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedDelayerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedDelayerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterCamelContextTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterCamelContextTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterCamelContextTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,62 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedRegisterCamelContextTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testRegisterCamelContext() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=context,name=\"camel-1\"");
+        String name = (String) mbeanServer.getAttribute(on, "Name");
+        assertEquals("camel-1", name);
+
+        Boolean started = (Boolean) mbeanServer.getAttribute(on, "Started");
+        assertEquals(Boolean.TRUE, started);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterCamelContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterCamelContextTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterEndpointTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterEndpointTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterEndpointTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,66 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedRegisterEndpointTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testLookupEndpointsByName() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"direct://start\"");
+        String uri = (String) mbeanServer.getAttribute(name, "Uri");
+        assertEquals("direct://start", uri);
+
+        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"log://foo\"");
+        uri = (String) mbeanServer.getAttribute(name, "Uri");
+        assertEquals("log://foo", uri);
+
+        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://result\"");
+        uri = (String) mbeanServer.getAttribute(name, "Uri");
+        assertEquals("mock://result", uri);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterExchangeStatisticsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterExchangeStatisticsTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterExchangeStatisticsTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterExchangeStatisticsTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,67 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedRegisterExchangeStatisticsTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testExchangesCompletedStatistics() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=routes,name=\"route1\"");
+        Long completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
+        assertEquals(0, completed.longValue());
+
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
+        assertEquals(1, completed.longValue());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterExchangeStatisticsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterExchangeStatisticsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,54 @@
+/**
+ * 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.camel.management;
+
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedRegisterRouteTest extends ContextTestSupport {
+
+    public void testRoutes() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
+        assertEquals(1, set.size());
+
+        ObjectName on = set.iterator().next();
+
+        String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+        // the route has this starting endpoint uri
+        assertEquals("direct://start", uri);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterTwoRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterTwoRoutesTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterTwoRoutesTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterTwoRoutesTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,72 @@
+/**
+ * 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.camel.management;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedRegisterTwoRoutesTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testRoutes() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
+        assertEquals(2, set.size());
+
+        Set<String> uris = new HashSet<String>();
+        for (ObjectName on : set) {
+            String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+            uris.add(uri);
+        }
+
+        // the route has this starting endpoint uri
+        assertTrue(uris.contains("direct://start"));
+        assertTrue(uris.contains("direct://foo"));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").to("mock:result");
+
+                from("direct:foo").to("mock:foo");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterTwoRoutesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterTwoRoutesTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,82 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedRoutePerformanceCounterTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testPerformanceCounterStats() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        // get the stats for the route
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=routes,name=\"route1\"");
+
+        Long completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
+        assertEquals(1, completed.longValue());
+
+        Long last = (Long) mbeanServer.getAttribute(on, "LastProcessingTime");
+        Long total = (Long) mbeanServer.getAttribute(on, "TotalProcessingTime");
+
+        assertTrue("Should take around 2 sec: was " + last, last > 1900);
+        assertTrue("Should take around 2 sec: was " + total, total > 1900);
+
+        // send in another message
+        template.sendBody("direct:start", "Bye World");
+
+        completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
+        assertEquals(2, completed.longValue());
+        last = (Long) mbeanServer.getAttribute(on, "LastProcessingTime");
+        total = (Long) mbeanServer.getAttribute(on, "TotalProcessingTime");
+
+        assertTrue("Should take around 2 sec: was " + last, last > 1900);
+        assertTrue("Should be around 4 sec now: was " + total, total > 3900);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:foo").delay(2000).to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,104 @@
+/**
+ * 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.camel.management;
+
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Expression;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedThrottlerTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testManageThrottler() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(10);
+
+        // send in 10 messages
+        for (int i = 0; i < 10; i++) {
+            template.sendBody("direct:start", "Message " + i);
+        }
+
+        assertMockEndpointsSatisfied();
+
+        // get the stats for the route
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        // get the object name for the delayer
+        ObjectName throttlerName = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=processors,name=\"mythrottler\"");
+
+        // use route to get the total time
+        ObjectName routeName = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=routes,name=\"route1\"");
+        Long completed = (Long) mbeanServer.getAttribute(routeName, "ExchangesCompleted");
+        assertEquals(10, completed.longValue());
+
+        Long last = (Long) mbeanServer.getAttribute(routeName, "LastProcessingTime");
+        Long total = (Long) mbeanServer.getAttribute(routeName, "TotalProcessingTime");
+
+        assertTrue("Should take at most 1 sec: was " + total, total < 1100);
+
+        // change the throttler using JMX
+        mbeanServer.setAttribute(throttlerName, new Attribute("MaximumRequestsPerPeriod", (long) 2));
+
+        // reset the counters
+        mbeanServer.invoke(routeName, "reset", null, null);
+
+        // send in another 10 messages
+        for (int i = 0; i < 10; i++) {
+            template.sendBody("direct:start", "Message " + i);
+        }
+
+        Long period = (Long) mbeanServer.getAttribute(throttlerName, "MaximumRequestsPerPeriod");
+        assertNotNull(period);
+        assertEquals(2, period.longValue());
+
+        completed = (Long) mbeanServer.getAttribute(routeName, "ExchangesCompleted");
+        assertEquals(10, completed.longValue());
+        total = (Long) mbeanServer.getAttribute(routeName, "TotalProcessingTime");
+
+        assertTrue("Should be around 5 sec now: was " + total, total > 4500);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("log:foo")
+                    .throttle(10).id("mythrottler")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterCamelContextTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterCamelContextTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterCamelContextTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,59 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.TestSupport;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedUnregisterCamelContextTest extends TestSupport {
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testUnregisterCamelContext() throws Exception {
+        CamelContext context = createCamelContext();
+        context.start();
+
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=context,name=\"camel-1\"");
+
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+        String name = (String) mbeanServer.getAttribute(on, "Name");
+        assertEquals("camel-1", name);
+
+        Boolean started = (Boolean) mbeanServer.getAttribute(on, "Started");
+        assertEquals(true, started.booleanValue());
+
+        context.stop();
+
+        assertFalse("Should no longer be registered", mbeanServer.isRegistered(on));
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterCamelContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterCamelContextTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterComponentTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterComponentTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterComponentTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,68 @@
+/**
+ * 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.camel.management;
+
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedUnregisterComponentTest extends ContextTestSupport {
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testUnregisterComponent() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=components,*"), null);
+        assertEquals(2, set.size());
+
+        ObjectName on = set.iterator().next();
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+
+        context.stop();
+
+        assertFalse("Should no longer be registered", mbeanServer.isRegistered(on));
+        set = mbeanServer.queryNames(new ObjectName("*:type=components,*"), null);
+        assertEquals("Should no longer be registered", 0, set.size());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterComponentTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterConsumerTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterConsumerTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterConsumerTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,69 @@
+/**
+ * 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.camel.management;
+
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedUnregisterConsumerTest extends ContextTestSupport {
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testUnregisterConsumer() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=consumers,*"), null);
+        assertEquals(1, set.size());
+
+        ObjectName on = set.iterator().next();
+
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+        String uri = (String) mbeanServer.getAttribute(on, "Uri");
+        assertEquals("direct://start", uri);
+
+        context.stop();
+
+        assertFalse("Should no longer be registered", mbeanServer.isRegistered(on));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterEndpointTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterEndpointTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterEndpointTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,64 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedUnregisterEndpointTest extends ContextTestSupport {
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testUnregisterEndpoint() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://result\"");
+
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+        String uri = (String) mbeanServer.getAttribute(on, "Uri");
+        assertEquals("mock://result", uri);
+
+        context.stop();
+
+        assertFalse("Should no longer be registered", mbeanServer.isRegistered(on));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterRouteTest.java?rev=807573&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterRouteTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterRouteTest.java Tue Aug 25 11:57:51 2009
@@ -0,0 +1,63 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedUnregisterRouteTest extends ContextTestSupport {
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testUnregisterRoute() throws Exception {
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=routes,name=\"route1\"");
+
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+        String id = (String) mbeanServer.getAttribute(on, "Id");
+        assertEquals("route1", id);
+
+        context.stop();
+
+        assertFalse("Should no longer be registered", mbeanServer.isRegistered(on));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedUnregisterRouteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=807573&r1=807572&r2=807573&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 Tue Aug 25 11:57:51 2009
@@ -64,7 +64,7 @@
         assertEquals("Could not find 1 context: " + s, 1, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=processors,*"), null);
-        assertEquals("Could not find 3 processor: " + s, 3, s.size());
+        assertEquals("Could not find 2 processor: " + s, 2, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=routes,*"), null);
         assertEquals("Could not find 1 route: " + s, 1, s.size());

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java Tue Aug 25 11:57:51 2009
@@ -21,6 +21,7 @@
 import javax.xml.transform.Source;
 
 import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.cxf.util.CxfEndpointUtils;
@@ -85,6 +86,9 @@
         server = sfb.create();
     }
 
+    public Endpoint getEndpoint() {
+        return endpoint;
+    }
 
     public void start() throws Exception {
         server.start();

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Tue Aug 25 11:57:51 2009
@@ -32,10 +32,12 @@
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultLifecycleStrategy;
+import org.apache.camel.impl.SimpleLifecycleStrategy;
 import org.apache.camel.impl.scan.PatternBasedPackageScanFilter;
 import org.apache.camel.management.DefaultInstrumentationAgent;
-import org.apache.camel.management.InstrumentationLifecycleStrategy;
+import org.apache.camel.management.DefaultManagedLifecycleStrategy;
+import org.apache.camel.management.DefaultManagementStrategy;
+import org.apache.camel.management.ManagedManagementStrategy;
 import org.apache.camel.model.FromDefinition;
 import org.apache.camel.model.IdentifiedType;
 import org.apache.camel.model.InterceptDefinition;
@@ -422,7 +424,8 @@
     private void initJMXAgent() throws Exception {
         if (camelJMXAgent != null && camelJMXAgent.isDisabled()) {
             LOG.info("JMXAgent disabled");
-            getContext().setLifecycleStrategy(new DefaultLifecycleStrategy());
+            getContext().setLifecycleStrategy(new SimpleLifecycleStrategy());
+            getContext().setManagementStrategy(new DefaultManagementStrategy());
         } else if (camelJMXAgent != null) {
             DefaultInstrumentationAgent agent = new DefaultInstrumentationAgent();
             agent.setConnectorPort(camelJMXAgent.getConnectorPort());
@@ -435,7 +438,9 @@
             agent.setOnlyRegisterProcessorWithCustomId(camelJMXAgent.getOnlyRegisterProcessorWithCustomId());
 
             LOG.info("JMXAgent enabled: " + camelJMXAgent);
-            getContext().setLifecycleStrategy(new InstrumentationLifecycleStrategy(agent));
+            getContext().setLifecycleStrategy(new DefaultManagedLifecycleStrategy());
+            getContext().setManagementStrategy(new ManagedManagementStrategy());
+            getContext().getManagementStrategy().onlyManageProcessorWithCustomId(camelJMXAgent.getOnlyRegisterProcessorWithCustomId());
         }
     }
 

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java Tue Aug 25 11:57:51 2009
@@ -63,8 +63,7 @@
     }
 
     public void testQueryMbeans() throws Exception {
-        // TODO: Routes are temporary disabled until the code in InstrumentationLifecycleStrategy is fixed
-        // assertEquals(1, mbsc.queryNames(new ObjectName("org.apache.camel" + ":type=routes,*"), null).size());
+        assertEquals(1, mbsc.queryNames(new ObjectName("org.apache.camel" + ":type=routes,*"), null).size());
         assertEquals(1, mbsc.queryNames(new ObjectName("org.apache.camel" + ":type=processors,*"), null).size());
     }
 

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DummyLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DummyLifecycleStrategy.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DummyLifecycleStrategy.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DummyLifecycleStrategy.java Tue Aug 25 11:57:51 2009
@@ -16,15 +16,7 @@
  */
 package org.apache.camel.spring;
 
-import java.util.Collection;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Route;
-import org.apache.camel.Service;
-import org.apache.camel.spi.LifecycleStrategy;
-import org.apache.camel.spi.RouteContext;
+import org.apache.camel.impl.SimpleLifecycleStrategy;
 
 /**
  * Dummy LifecycleStrategy for LifecycleStrategy injection test.
@@ -32,30 +24,5 @@
  * @version $Revision$
  *
  */
-public class DummyLifecycleStrategy implements LifecycleStrategy {
-
-    public void onContextCreate(CamelContext context) {
-        // Do nothing
-    }
-
-    public void onEndpointAdd(Endpoint endpoint) {
-        // Do nothing
-    }
-
-    public void onRouteContextCreate(RouteContext routeContext) {
-        // Do nothing
-    }
-
-    public void onRoutesAdd(Collection<Route> routes) {
-        // Do nothing
-    }
-
-    public void onServiceAdd(CamelContext context, Service service) {
-        // Do nothing
-    }
-
-    public void onContextStart(CamelContext arg0) {
-        // Do nothing
-    }
-
+public class DummyLifecycleStrategy extends SimpleLifecycleStrategy {
 }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java Tue Aug 25 11:57:51 2009
@@ -21,20 +21,21 @@
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 
+import org.junit.Ignore;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
- * Test that verifies JMX properties can be configured via
- * Spring.
+ * Test that verifies JMX properties can be configured via Spring.
  *
  * @version $Revision$
- *
  */
+@Ignore
 public class JMXAgentTest extends DefaultJMXAgentTest {
 
-    protected static final String JMXSERVICEURL =
-        "service:jmx:rmi:///jndi/rmi://localhost:20008/jmxrmi/camel";
+    // TODO: Fix me later
+
+    protected static final String JMXSERVICEURL = "service:jmx:rmi:///jndi/rmi://localhost:20008/jmxrmi/camel";
     protected JMXConnector clientConnector;
 
     @Override
@@ -45,7 +46,6 @@
 
     @Override
     protected void tearDown() throws Exception {
-
         if (clientConnector != null) {
             try {
                 clientConnector.close();
@@ -66,8 +66,7 @@
     protected MBeanServerConnection getMBeanConnection() throws Exception {
         if (mbsc == null) {
             if (clientConnector == null) {
-                clientConnector = JMXConnectorFactory.connect(
-                        new JMXServiceURL(JMXSERVICEURL), null);
+                clientConnector = JMXConnectorFactory.connect(new JMXServiceURL(JMXSERVICEURL), null);
             }
             mbsc = clientConnector.getMBeanServerConnection();
         }

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml Tue Aug 25 11:57:51 2009
@@ -25,7 +25,7 @@
   <!-- START SNIPPET: example -->
   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
     <jmxAgent id="agent" registryPort="20008" 
-        usePlatformMBeanServer="false"
+        usePlatformMBeanServer="true"
         createConnector="true"
      />
       

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/jmxInstrumentationWithConnector.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/jmxInstrumentationWithConnector.xml?rev=807573&r1=807572&r2=807573&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/jmxInstrumentationWithConnector.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/jmxInstrumentationWithConnector.xml Tue Aug 25 11:57:51 2009
@@ -26,14 +26,13 @@
   <bean id="agent" class="org.apache.camel.management.DefaultInstrumentationAgent">
     <property name="server" ref="mbeanServer"/>
   </bean>
+
+    <bean id="managementStrategy" class="org.apache.camel.management.ManagedManagementStrategy">
+        <property name="managementAgent" ref="agent"/>
+    </bean>
   
-  <bean id="lifeCycleStrategy" class="org.apache.camel.management.InstrumentationLifecycleStrategy">
-  	<constructor-arg>
-  	  <ref bean="agent"/>
-  	</constructor-arg>
-    <constructor-arg>
-  	  <ref bean="camel"/>
-  	</constructor-arg>
+  <bean id="lifeCycleStrategy" class="org.apache.camel.management.DefaultManagedLifecycleStrategy">
+      <constructor-arg index="0" ref="managementStrategy"/>
   </bean>
   
   <bean id="mybean" class="org.apache.camel.spring.example.DummyBean">



Mime
View raw message