activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [06/10] git commit: AMQ-4325: Fixed ActiveMQ Camel component to support username/password being configured when using ActiveMQ factory method. Also fixes the factory method would eager create plain connection factory, instead of using createConnectionFac
Date Wed, 12 Mar 2014 12:35:51 GMT
AMQ-4325: Fixed ActiveMQ Camel component to support username/password being configured when
using ActiveMQ factory method. Also fixes the factory method would eager create plain connection
factory, instead of using createConnectionFactory method as otherwise, which is optimized
for AMQ.


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/8238c4d8
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/8238c4d8
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/8238c4d8

Branch: refs/heads/activemq-5.9
Commit: 8238c4d8221f0a0999e2ca76ae033bbb8cc0e870
Parents: 7868b72
Author: Claus Ibsen <claus.ibsen@gmail.com>
Authored: Sat Nov 2 20:17:28 2013 +0100
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Wed Mar 12 08:31:33 2014 -0400

----------------------------------------------------------------------
 activemq-camel/pom.xml                          |  6 ++
 .../camel/component/ActiveMQComponent.java      |  2 -
 .../org/apache/activemq/camel/AMQ2240Test.java  |  4 +-
 ...eMQComponentFactoryUserNamePasswordTest.java | 49 +++++++++++++++++
 .../ActiveMQComponentUserNamePasswordTest.java  | 49 +++++++++++++++++
 ...ActiveMQComponentFactoryUserNamePassword.xml | 58 ++++++++++++++++++++
 .../camel/ActiveMQComponentUserNamePassword.xml | 58 ++++++++++++++++++++
 7 files changed, 223 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/8238c4d8/activemq-camel/pom.xml
----------------------------------------------------------------------
diff --git a/activemq-camel/pom.xml b/activemq-camel/pom.xml
index 32d8082..b01af60 100755
--- a/activemq-camel/pom.xml
+++ b/activemq-camel/pom.xml
@@ -140,6 +140,12 @@
     </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
+      <artifactId>activemq-jaas</artifactId>
+      <optional>true</optional>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
       <artifactId>activemq-ra</artifactId>
       <optional>true</optional>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/activemq/blob/8238c4d8/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
b/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
index 478e4a9..47dee42 100644
--- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
+++ b/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
@@ -80,8 +80,6 @@ public class ActiveMQComponent extends JmsComponent implements EndpointCompleter
                     .setBrokerURL(brokerURL);
         }
 
-        // set the connection factory with the provided broker url
-        answer.setConnectionFactory(new ActiveMQConnectionFactory(brokerURL));
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/8238c4d8/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java b/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java
index 3405a12..f2f799e 100644
--- a/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java
+++ b/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java
@@ -54,7 +54,9 @@ public class AMQ2240Test {
                 "jms.maxXXXXReconnectAttempts=1&jms.timeout=3000";
 
             LOG.info("creating context with bad URI: " + vmUri);
-            ActiveMQComponent.activeMQComponent(vmUri);
+            ActiveMQComponent amq = ActiveMQComponent.activeMQComponent(vmUri);
+
+            amq.getConfiguration().getConnectionFactory();
 
             fail("Should have received an exception from the bad URI.");
         } catch(Exception e) {

http://git-wip-us.apache.org/repos/asf/activemq/blob/8238c4d8/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java
b/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java
new file mode 100644
index 0000000..ffad7a5
--- /dev/null
+++ b/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.activemq.camel;
+
+import org.apache.activemq.camel.component.ActiveMQComponent;
+import org.apache.activemq.camel.component.ActiveMQConfiguration;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ActiveMQComponentFactoryUserNamePasswordTest extends CamelSpringTestSupport
{
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml");
+    }
+
+    @Test
+    public void testActiveMQ() throws Exception {
+        ActiveMQComponent comp = context.getComponent("activemq", ActiveMQComponent.class);
+        assertNotNull(comp);
+
+        ActiveMQConfiguration config = (ActiveMQConfiguration) comp.getConfiguration();
+        assertNotNull(config);
+        assertEquals("admin2", config.getUserName());
+        assertEquals("secret2", config.getPassword());
+
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("activemq:queue:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/8238c4d8/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java
b/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java
new file mode 100644
index 0000000..3d80486
--- /dev/null
+++ b/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.activemq.camel;
+
+import org.apache.activemq.camel.component.ActiveMQComponent;
+import org.apache.activemq.camel.component.ActiveMQConfiguration;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ActiveMQComponentUserNamePasswordTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml");
+    }
+
+    @Test
+    public void testActiveMQ() throws Exception {
+        ActiveMQComponent comp = context.getComponent("activemq", ActiveMQComponent.class);
+        assertNotNull(comp);
+
+        ActiveMQConfiguration config = (ActiveMQConfiguration) comp.getConfiguration();
+        assertNotNull(config);
+        assertEquals("admin", config.getUserName());
+        assertEquals("secret", config.getPassword());
+
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("activemq:queue:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/8238c4d8/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml
b/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml
new file mode 100644
index 0000000..061e8e3
--- /dev/null
+++ b/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml
@@ -0,0 +1,58 @@
+<?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:amq="http://activemq.apache.org/schema/core"
+       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://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route>
+      <from uri="activemq:queue:bar"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+
+  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" factory-method="activeMQComponent">
+    <constructor-arg index="0" value="vm://testBroker2"/>
+    <property name="userName" value="admin2"/>
+    <property name="password" value="secret2"/>
+  </bean>
+
+  <broker brokerName="testBroker2" persistent="false" useShutdownHook="false" deleteAllMessagesOnStartup="true"
+          xmlns="http://activemq.apache.org/schema/core">
+
+    <transportConnectors>
+      <transportConnector uri="vm://testBroker2"/>
+    </transportConnectors>
+
+    <plugins>
+
+      <simpleAuthenticationPlugin>
+        <users>
+          <authenticationUser username="admin2" password="secret2" groups="users,admins"/>
+        </users>
+      </simpleAuthenticationPlugin>
+
+    </plugins>
+  </broker>
+
+
+</beans>

http://git-wip-us.apache.org/repos/asf/activemq/blob/8238c4d8/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml
b/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml
new file mode 100644
index 0000000..83d16fc
--- /dev/null
+++ b/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml
@@ -0,0 +1,58 @@
+<?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:amq="http://activemq.apache.org/schema/core"
+       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://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route>
+      <from uri="activemq:queue:foo"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+
+  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
+    <property name="brokerURL" value="vm://testBroker"/>
+    <property name="userName" value="admin"/>
+    <property name="password" value="secret"/>
+  </bean>
+
+  <broker brokerName="testBroker" persistent="false" useShutdownHook="false" deleteAllMessagesOnStartup="true"
+          xmlns="http://activemq.apache.org/schema/core">
+
+    <transportConnectors>
+      <transportConnector uri="vm://testBroker"/>
+    </transportConnectors>
+
+    <plugins>
+
+      <simpleAuthenticationPlugin>
+        <users>
+          <authenticationUser username="admin" password="secret" groups="users,admins"/>
+        </users>
+      </simpleAuthenticationPlugin>
+
+    </plugins>
+  </broker>
+
+
+</beans>


Mime
View raw message