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 2014/08/23 08:32:56 UTC
git commit: Added unit test based on user forum issue
Repository: camel
Updated Branches:
refs/heads/master 835a41edf -> 84adb90f7
Added unit test based on user forum issue
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/84adb90f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/84adb90f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/84adb90f
Branch: refs/heads/master
Commit: 84adb90f7117df60f2e70334be96f1b0c82e0168
Parents: 835a41e
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Aug 23 08:32:02 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Aug 23 08:32:02 2014 +0200
----------------------------------------------------------------------
.../management/ManagedRefProducerTest.java | 105 +++++++++++++++++++
.../ManagedEndpointInjectRefEndpointTest.java | 87 +++++++++++++++
.../management/ManagedRefEndpointTest.java | 87 +++++++++++++++
.../camel/spring/management/MyRouteBuilder.java | 35 +++++++
.../ManagedEndpointInjectRefEndpointTest.xml | 35 +++++++
.../management/ManagedRefEndpointTest.xml | 36 +++++++
.../ManagedEndpointInjectRefEndpointTest.java | 92 ++++++++++++++++
.../management/ManagedRefEndpointTest.java | 92 ++++++++++++++++
.../blueprint/management/MyRouteBuilder.java | 35 +++++++
.../managedEndpointInjectRefEndpointTest.xml | 33 ++++++
.../management/managedRefEndpointTest.xml | 34 ++++++
11 files changed, 671 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/camel-core/src/test/java/org/apache/camel/management/ManagedRefProducerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedRefProducerTest.java b/camel-core/src/test/java/org/apache/camel/management/ManagedRefProducerTest.java
new file mode 100644
index 0000000..46da815
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedRefProducerTest.java
@@ -0,0 +1,105 @@
+/**
+ * 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.Iterator;
+import java.util.Map;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.SimpleRegistry;
+import org.apache.camel.spi.Registry;
+
+/**
+ * @version
+ */
+public class ManagedRefProducerTest extends ManagementTestSupport {
+
+ private Map registry = new SimpleRegistry();
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = new DefaultCamelContext((Registry) registry);
+ registry.put("foo", new MockEndpoint("mock://foo"));
+ return context;
+ }
+
+ public void testProducer() throws Exception {
+ // JMX tests dont work well on AIX CI servers (hangs them)
+ if (isPlatform("aix")) {
+ return;
+ }
+
+ // fire a message to get it running
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+ getMockEndpoint("foo").expectedMessageCount(1);
+ template.sendBody("direct:start", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=producers,*"), null);
+ assertEquals(2, set.size());
+ Iterator<ObjectName> it = set.iterator();
+
+ for (int i = 0; i < 2; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("mock://foo") || uri.equals("mock://result"));
+
+ // should be started
+ String state = (String) mbeanServer.getAttribute(on, "State");
+ assertEquals("Should be started", ServiceStatus.Started.name(), state);
+ }
+
+ set = mbeanServer.queryNames(new ObjectName("*:type=endpoints,*"), null);
+ assertEquals(3, set.size());
+ it = set.iterator();
+
+ for (int i = 0; i < 3; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("direct://start") || uri.equals("mock://foo") || uri.equals("mock://result"));
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").routeId("foo")
+ .to("ref:foo").to("mock:result");
+ }
+ };
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.java
new file mode 100644
index 0000000..1a35859
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.java
@@ -0,0 +1,87 @@
+/**
+ * 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.ServiceStatus;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ManagedEndpointInjectRefEndpointTest extends SpringTestSupport {
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.xml");
+ }
+
+ protected MBeanServer getMBeanServer() {
+ return context.getManagementStrategy().getManagementAgent().getMBeanServer();
+ }
+
+ public void testRef() throws Exception {
+ // JMX tests dont work well on AIX CI servers (hangs them)
+ if (isPlatform("aix")) {
+ return;
+ }
+
+ // fire a message to get it running
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+ getMockEndpoint("foo").expectedMessageCount(1);
+ template.sendBody("direct:start", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=producers,*"), null);
+ assertEquals(2, set.size());
+ Iterator<ObjectName> it = set.iterator();
+
+ for (int i = 0; i < 2; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("mock://foo") || uri.equals("mock://result"));
+
+ // should be started
+ String state = (String) mbeanServer.getAttribute(on, "State");
+ assertEquals("Should be started", ServiceStatus.Started.name(), state);
+ }
+
+ set = mbeanServer.queryNames(new ObjectName("*:type=endpoints,*"), null);
+ assertEquals(3, set.size());
+ it = set.iterator();
+
+ for (int i = 0; i < 3; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("direct://start") || uri.equals("mock://foo") || uri.equals("mock://result"));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedRefEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedRefEndpointTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedRefEndpointTest.java
new file mode 100644
index 0000000..75d93da
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/ManagedRefEndpointTest.java
@@ -0,0 +1,87 @@
+/**
+ * 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.ServiceStatus;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ManagedRefEndpointTest extends SpringTestSupport {
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/management/ManagedRefEndpointTest.xml");
+ }
+
+ protected MBeanServer getMBeanServer() {
+ return context.getManagementStrategy().getManagementAgent().getMBeanServer();
+ }
+
+ public void testRef() throws Exception {
+ // JMX tests dont work well on AIX CI servers (hangs them)
+ if (isPlatform("aix")) {
+ return;
+ }
+
+ // fire a message to get it running
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+ getMockEndpoint("foo").expectedMessageCount(1);
+ template.sendBody("direct:start", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=producers,*"), null);
+ assertEquals(2, set.size());
+ Iterator<ObjectName> it = set.iterator();
+
+ for (int i = 0; i < 2; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("mock://foo") || uri.equals("mock://result"));
+
+ // should be started
+ String state = (String) mbeanServer.getAttribute(on, "State");
+ assertEquals("Should be started", ServiceStatus.Started.name(), state);
+ }
+
+ set = mbeanServer.queryNames(new ObjectName("*:type=endpoints,*"), null);
+ assertEquals(3, set.size());
+ it = set.iterator();
+
+ for (int i = 0; i < 3; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("direct://start") || uri.equals("mock://foo") || uri.equals("mock://result"));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyRouteBuilder.java b/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyRouteBuilder.java
new file mode 100644
index 0000000..939fa4d
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyRouteBuilder.java
@@ -0,0 +1,35 @@
+/**
+ * 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 org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+ @EndpointInject(ref = "foo")
+ private Endpoint foo;
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").routeId("foo")
+ .to(foo)
+ .to("mock:result");
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.xml
new file mode 100644
index 0000000..ca34ec4
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedEndpointInjectRefEndpointTest.xml
@@ -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"
+ 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
+ ">
+
+ <bean id="myRouteBuilder" class="org.apache.camel.spring.management.MyRouteBuilder"/>
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <routeBuilder ref="myRouteBuilder"/>
+
+ <endpoint id="foo" uri="mock:foo"/>
+
+ </camelContext>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedRefEndpointTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedRefEndpointTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedRefEndpointTest.xml
new file mode 100644
index 0000000..8671b81
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedRefEndpointTest.xml
@@ -0,0 +1,36 @@
+<?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.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <!-- define the endpoint -->
+ <endpoint id="foo" uri="mock:foo"/>
+
+ <route id="foo">
+ <from uri="direct:start"/>
+ <to ref="foo"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedEndpointInjectRefEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedEndpointInjectRefEndpointTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedEndpointInjectRefEndpointTest.java
new file mode 100644
index 0000000..ff36b3a
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedEndpointInjectRefEndpointTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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.test.blueprint.management;
+
+import java.util.Iterator;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+public class ManagedEndpointInjectRefEndpointTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected boolean useJmx() {
+ return true;
+ }
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/management/managedEndpointInjectRefEndpointTest.xml";
+ }
+
+ protected MBeanServer getMBeanServer() {
+ return context.getManagementStrategy().getManagementAgent().getMBeanServer();
+ }
+
+ @Test
+ public void testRef() throws Exception {
+ // JMX tests dont work well on AIX CI servers (hangs them)
+ if (isPlatform("aix")) {
+ return;
+ }
+
+ // fire a message to get it running
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+ getMockEndpoint("foo").expectedMessageCount(1);
+ template.sendBody("direct:start", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=producers,*"), null);
+ assertEquals(2, set.size());
+ Iterator<ObjectName> it = set.iterator();
+
+ for (int i = 0; i < 2; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("mock://foo") || uri.equals("mock://result"));
+
+ // should be started
+ String state = (String) mbeanServer.getAttribute(on, "State");
+ assertEquals("Should be started", ServiceStatus.Started.name(), state);
+ }
+
+ set = mbeanServer.queryNames(new ObjectName("*:type=endpoints,*"), null);
+ assertEquals(3, set.size());
+ it = set.iterator();
+
+ for (int i = 0; i < 3; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("direct://start") || uri.equals("mock://foo") || uri.equals("mock://result"));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedRefEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedRefEndpointTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedRefEndpointTest.java
new file mode 100644
index 0000000..a077a87
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedRefEndpointTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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.test.blueprint.management;
+
+import java.util.Iterator;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+public class ManagedRefEndpointTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected boolean useJmx() {
+ return true;
+ }
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/management/managedRefEndpointTest.xml";
+ }
+
+ protected MBeanServer getMBeanServer() {
+ return context.getManagementStrategy().getManagementAgent().getMBeanServer();
+ }
+
+ @Test
+ public void testRef() throws Exception {
+ // JMX tests dont work well on AIX CI servers (hangs them)
+ if (isPlatform("aix")) {
+ return;
+ }
+
+ // fire a message to get it running
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+ getMockEndpoint("foo").expectedMessageCount(1);
+ template.sendBody("direct:start", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=producers,*"), null);
+ assertEquals(2, set.size());
+ Iterator<ObjectName> it = set.iterator();
+
+ for (int i = 0; i < 2; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("mock://foo") || uri.equals("mock://result"));
+
+ // should be started
+ String state = (String) mbeanServer.getAttribute(on, "State");
+ assertEquals("Should be started", ServiceStatus.Started.name(), state);
+ }
+
+ set = mbeanServer.queryNames(new ObjectName("*:type=endpoints,*"), null);
+ assertEquals(3, set.size());
+ it = set.iterator();
+
+ for (int i = 0; i < 3; i++) {
+ ObjectName on = it.next();
+
+ boolean registered = mbeanServer.isRegistered(on);
+ assertEquals("Should be registered", true, registered);
+
+ String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
+ assertTrue(uri, uri.equals("direct://start") || uri.equals("mock://foo") || uri.equals("mock://result"));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/MyRouteBuilder.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/MyRouteBuilder.java
new file mode 100644
index 0000000..15acefc
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/MyRouteBuilder.java
@@ -0,0 +1,35 @@
+/**
+ * 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.test.blueprint.management;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+ @EndpointInject(ref = "foo")
+ private Endpoint foo;
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").routeId("foo")
+ .to(foo)
+ .to("mock:result");
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedEndpointInjectRefEndpointTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedEndpointInjectRefEndpointTest.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedEndpointInjectRefEndpointTest.xml
new file mode 100644
index 0000000..fb1923f
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedEndpointInjectRefEndpointTest.xml
@@ -0,0 +1,33 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <bean id="myRouteBuilder" class="org.apache.camel.test.blueprint.management.MyRouteBuilder"/>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+ <routeBuilder ref="myRouteBuilder"/>
+
+ <endpoint id="foo" uri="mock:foo"/>
+
+ </camelContext>
+
+</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/84adb90f/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedRefEndpointTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedRefEndpointTest.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedRefEndpointTest.xml
new file mode 100644
index 0000000..aae0444
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedRefEndpointTest.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+ <!-- define the endpoint -->
+ <endpoint id="foo" uri="mock:foo"/>
+
+ <route id="foo">
+ <from uri="direct:start"/>
+ <to ref="foo"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+
+</blueprint>
\ No newline at end of file