You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/09/14 07:59:31 UTC
svn commit: r814483 - in /camel/trunk/components/camel-spring/src/test:
java/org/apache/camel/spring/management/DualCamelContextManagedTest.java
resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
Author: davsclaus
Date: Mon Sep 14 05:59:30 2009
New Revision: 814483
URL: http://svn.apache.org/viewvc?rev=814483&view=rev
Log:
CAMEL-1612: Management of Camel with dual camel contexts.
Added:
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java (with props)
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml (with props)
Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java?rev=814483&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java Mon Sep 14 05:59:30 2009
@@ -0,0 +1,78 @@
+/**
+ * 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.spring.management;
+
+import java.util.Iterator;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class DualCamelContextManagedTest extends SpringTestSupport {
+
+ @Override
+ protected int getExpectedRouteCount() {
+ return 0;
+ }
+
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/management/dualCamelContextManagedTest.xml");
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testDualCamelContextManaged() throws Exception {
+ MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
+ assertEquals(2, set.size());
+ Iterator<ObjectName> it = set.iterator();
+
+ ObjectName on1 = it.next();
+ ObjectName on2 = it.next();
+
+ assertTrue("Route 1 is missing", on1.getCanonicalName().contains("route1") || on2.getCanonicalName().contains("route1"));
+ assertTrue("Route 2 is missing", on1.getCanonicalName().contains("route2") || on2.getCanonicalName().contains("route2"));
+
+ set = mbeanServer.queryNames(new ObjectName("*:type=endpoints,*"), null);
+ assertEquals(7, set.size());
+
+ for (ObjectName on : set) {
+ String name = on.getCanonicalName();
+
+ if (name.contains("mock://mock1")) {
+ String id = (String) mbeanServer.getAttribute(on, "CamelId");
+ assertEquals("camel1", id);
+ } else if (name.contains("mock://mock2")) {
+ String id = (String) mbeanServer.getAttribute(on, "CamelId");
+ assertEquals("camel2", id);
+ } else if (name.contains("file://target/route1")) {
+ String id = (String) mbeanServer.getAttribute(on, "CamelId");
+ assertEquals("camel1", id);
+ } else if (name.contains("file://target/route2")) {
+ String id = (String) mbeanServer.getAttribute(on, "CamelId");
+ assertEquals("camel2", id);
+ }
+ }
+ }
+
+}
Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml?rev=814483&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml Mon Sep 14 05:59:30 2009
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext id="camel1" xmlns="http://camel.apache.org/schema/spring">
+
+ <endpoint id="fromFile" uri="file://target/route1"/>
+ <endpoint id="mock1" uri="mock:mock1"/>
+
+ <route id="route1">
+ <from ref="fromFile"/>
+ <to ref="mock1"/>
+ </route>
+
+ </camelContext>
+
+ <camelContext id="camel2" xmlns="http://camel.apache.org/schema/spring">
+
+ <endpoint id="fromFile2" uri="file://target/route2"/>
+ <endpoint id="mock2" uri="mock:mock2"/>
+
+ <route id="route2">
+ <from ref="fromFile2"/>
+ <to ref="mock2"/>
+ </route>
+
+ </camelContext>
+
+</beans>
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml