activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject 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 createConnectionFactory met
Date Sat, 02 Nov 2013 20:31:31 GMT
Updated Branches:
  refs/heads/trunk 1ad6bd59e -> 48d615d31


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/48d615d3
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/48d615d3
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/48d615d3

Branch: refs/heads/trunk
Commit: 48d615d3113cf3d2a9d33bd5264c4f334d34b5c5
Parents: 1ad6bd5
Author: Claus Ibsen <claus.ibsen@gmail.com>
Authored: Sat Nov 2 20:17:28 2013 +0100
Committer: Claus Ibsen <claus.ibsen@gmail.com>
Committed: Sat Nov 2 20:17:28 2013 +0100

----------------------------------------------------------------------
 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/48d615d3/activemq-camel/pom.xml
----------------------------------------------------------------------
diff --git a/activemq-camel/pom.xml b/activemq-camel/pom.xml
index 5906dc2..8b8c51e 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/48d615d3/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/48d615d3/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/48d615d3/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/48d615d3/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/48d615d3/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/48d615d3/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