You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/08/12 11:25:29 UTC
svn commit: r984699 - in /camel/trunk/tests/camel-itest-osgi/src/test:
java/org/apache/camel/itest/osgi/ java/org/apache/camel/itest/osgi/blueprint/
java/org/apache/camel/itest/osgi/management/
resources/org/apache/camel/itest/osgi/management/
Author: ningjiang
Date: Thu Aug 12 09:25:29 2010
New Revision: 984699
URL: http://svn.apache.org/viewvc?rev=984699&view=rev
Log:
CAMEL-3041 Added OSGi JMX test for the auto assigned CamelContextId
Added:
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/OSGiIntegrationManagedCamelContextTest.java (with props)
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml (with props)
Removed:
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/ManagedCamelContextTest.java
Modified:
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java
Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java?rev=984699&r1=984698&r2=984699&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java Thu Aug 12 09:25:29 2010
@@ -49,7 +49,7 @@ public class OSGiIntegrationTest extends
@Test
public void testCamelContextName() throws Exception {
- // should get the context name here
+ // should get the context name with osgi bundle id
assertTrue("Get the wrong camel context name.", context.getName().indexOf("-1") > 0);
assertTrue("Get the wrong camel context name.", context.getName().indexOf("camel-1") < 0);
Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java?rev=984699&r1=984698&r2=984699&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/OSGiBlueprintTestSupport.java Thu Aug 12 09:25:29 2010
@@ -140,7 +140,8 @@ public class OSGiBlueprintTestSupport ex
workingDirectory("target/paxrunner/"),
- felix(), equinox());
+ //felix(),
+ equinox());
return options;
}
Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/OSGiIntegrationManagedCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/OSGiIntegrationManagedCamelContextTest.java?rev=984699&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/OSGiIntegrationManagedCamelContextTest.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/OSGiIntegrationManagedCamelContextTest.java Thu Aug 12 09:25:29 2010
@@ -0,0 +1,102 @@
+/**
+ * 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.itest.osgi.management;
+
+import java.net.URL;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
+import org.apache.camel.management.DefaultManagementNamingStrategy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.swissbox.tinybundles.dp.Constants;
+
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
+
+@RunWith(JUnit4TestRunner.class)
+public class OSGiIntegrationManagedCamelContextTest extends OSGiIntegrationTestSupport {
+ protected boolean useJmx() {
+ return true;
+ }
+
+ @Test
+ public void testCamelContextName() throws Exception {
+ // Wait a while to let the MBeanServer be created
+ Thread.sleep(1000);
+
+ MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+ LOG.info("The MBeanServer is " + mbeanServer);
+
+
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=context,*"), null);
+ assertEquals("There should have 2 camelcontext registed", 2, set.size());
+
+ String camelContextName = context.getName();
+ ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/" + camelContextName + ",type=context,name=\"" + camelContextName + "\"");
+
+ assertTrue("Should be registered", mbeanServer.isRegistered(on));
+ String name = (String) mbeanServer.getAttribute(on, "CamelId");
+ assertEquals(camelContextName, name);
+
+ }
+
+ private static URL getCamelContextInputStream() {
+ return OSGiIntegrationManagedCamelContextTest.class.getResource("CamelContext.xml");
+ }
+
+ @Configuration
+ public static Option[] configure() throws Exception {
+
+ Option[] options = options(
+ // install the spring dm profile
+ profile("spring.dm").version("1.2.0"),
+ // this is how you set the default log level when using pax logging (logProfile)
+ org.ops4j.pax.exam.CoreOptions.systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // using the features to install the camel components
+ scanFeatures(getCamelKarafFeatureUrl(),
+ "camel-core", "camel-spring", "camel-test"),
+ //set up the camel context bundle first
+ provision(newBundle().add("META-INF/spring/CamelContext.xml", getCamelContextInputStream())
+ .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.camel.itest.osgi.CamelContextTinyBundle")
+ .set(Constants.BUNDLE_NAME, "CamelContextTinyBundle").build()),
+
+ workingDirectory("target/paxrunner/"),
+
+ equinox(),
+ felix());
+
+ return options;
+ }
+
+}
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/OSGiIntegrationManagedCamelContextTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/management/OSGiIntegrationManagedCamelContextTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml?rev=984699&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml Thu Aug 12 09:25:29 2010
@@ -0,0 +1,35 @@
+<?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"
+ xmlns:osgi="http://camel.apache.org/schema/osgi"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://camel.apache.org/schema/osgi http://camel.apache.org/schema/osgi/camel-osgi.xsd">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <camel:route>
+ <camel:from uri="direct:start"/>
+ <camel:to uri="mock:result"/>
+ </camel:route>
+ </camelContext>
+
+</beans>
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/management/CamelContext.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml