You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2013/04/03 12:36:37 UTC

svn commit: r1463909 - in /activemq/trunk: activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/ activemq-karaf/src/main/resources/ activemq-osgi/ activemq-osgi/src/...

Author: gtully
Date: Wed Apr  3 10:36:37 2013
New Revision: 1463909

URL: http://svn.apache.org/r1463909
Log:
https://issues.apache.org/jira/browse/AMQ-4432 - itest with mods to support, spring.handlers is now aware of camel handler

Added:
    activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java
      - copied, changed from r1463908, activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java
    activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml   (with props)
    activemq/trunk/activemq-osgi/src/main/resources/META-INF/spring.handlers
Modified:
    activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java
    activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java
    activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
    activemq/trunk/activemq-karaf/src/main/resources/features.xml
    activemq/trunk/activemq-osgi/pom.xml

Modified: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java?rev=1463909&r1=1463908&r2=1463909&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java (original)
+++ activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java Wed Apr  3 10:36:37 2013
@@ -167,8 +167,12 @@ public abstract class AbstractFeatureTes
 
     // for use from a probe
     public String getCamelFeatureUrl() {
+        return getCamelFeatureUrl(System.getProperty("camel.version", "unknown"));
+    }
+
+    public static String getCamelFeatureUrl(String ver) {
         return "mvn:org.apache.camel.karaf/apache-camel/"
-        + System.getProperty("camel.version", "unknown")
+        + ver
         + "/xml/features";
     }
 
@@ -180,15 +184,20 @@ public abstract class AbstractFeatureTes
             artifactId("standard").version(karafVersion()).type(type);
     }
 
-    public static Option[] configureBrokerStart(Option[] existingOptions) {
+    public static Option[] configureBrokerStart(Option[] existingOptions, String xmlConfig) {
         existingOptions = append(
                 replaceConfigurationFile("etc/org.apache.activemq.server-default.cfg", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg")),
                 existingOptions);
         return append(
-                replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml")),
+                replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/" + xmlConfig + ".xml")),
                 existingOptions);
     }
 
+    public static Option[] configureBrokerStart(Option[] existingOptions) {
+        final String xmlConfig = "activemq";
+        return configureBrokerStart(existingOptions, xmlConfig);
+    }
+
     public static Option[] append(Option toAdd, Option[] existingOptions) {
         ArrayList<Option> newOptions = new ArrayList<Option>();
         newOptions.addAll(Arrays.asList(existingOptions));

Modified: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java?rev=1463909&r1=1463908&r2=1463909&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java (original)
+++ activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java Wed Apr  3 10:36:37 2013
@@ -62,6 +62,9 @@ public class ActiveMQBrokerFeatureTest e
         // produce and consume
         final String nameAndPayload = String.valueOf(System.currentTimeMillis());
         produceMessage(nameAndPayload);
+
+        System.err.println(executeCommand("activemq:bstat").trim());
+
         assertEquals("got our message", nameAndPayload, consumeMessage(nameAndPayload));
     }
 

Copied: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java (from r1463908, activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java?p2=activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java&p1=activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java&r1=1463908&r2=1463909&rev=1463909&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java (original)
+++ activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java Wed Apr  3 10:36:37 2013
@@ -24,23 +24,31 @@ import javax.jms.TextMessage;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.MavenUtils;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.CoreOptions.scanFeatures;
 
 @RunWith(JUnit4TestRunner.class)
-public class ActiveMQBrokerFeatureTest extends AbstractFeatureTest {
+public class ActiveMQBrokerNdCamelFeatureTest extends AbstractFeatureTest {
 
     @Configuration
     public static Option[] configure() {
-        return configureBrokerStart(configure("activemq"));
+        Option[] baseOptions = configure("activemq");
+        return configureBrokerStart(append(scanFeatures(getCamelFeatureUrl(
+                MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")
+        ), "activemq-camel"), baseOptions), "activemq-nd-camel");
     }
 
     @Test
     public void test() throws Throwable {
+        System.err.println(executeCommand("features:list").trim());
 
         withinReason(new Callable<Boolean>() {
             @Override
@@ -59,10 +67,12 @@ public class ActiveMQBrokerFeatureTest e
             }
         });
 
+        System.err.println(executeCommand("activemq:bstat").trim());
+
         // produce and consume
         final String nameAndPayload = String.valueOf(System.currentTimeMillis());
-        produceMessage(nameAndPayload);
-        assertEquals("got our message", nameAndPayload, consumeMessage(nameAndPayload));
+        produceMessage("camel_in");
+        assertEquals("got our message", "camel_in", consumeMessage("camel_out"));
     }
 
     protected String consumeMessage(String nameAndPayload) throws Exception {
@@ -71,7 +81,7 @@ public class ActiveMQBrokerFeatureTest e
         connection.start();
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer consumer = session.createConsumer(session.createQueue(nameAndPayload));
-        TextMessage message = (TextMessage) consumer.receive(4000);
+        TextMessage message = (TextMessage) consumer.receive(10000);
         System.err.println("message: " + message);
         connection.close();
         return message.getText();

Modified: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java?rev=1463909&r1=1463908&r2=1463909&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java (original)
+++ activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java Wed Apr  3 10:36:37 2013
@@ -47,6 +47,7 @@ public class ActiveMQBrokerNdWebConsoleF
     protected void produceMessage(String nameAndPayload) throws Exception {
         HttpClient client = new HttpClient();
 
+        System.err.println(executeCommand("activemq:bstat").trim());
         System.err.println("attempting publish via web console..");
 
         // set credentials
@@ -83,5 +84,7 @@ public class ActiveMQBrokerNdWebConsoleF
 
         // execute the send
         assertEquals("post succeeded, " + post, 302, client.executeMethod(post));
+
+        System.err.println(executeCommand("activemq:bstat").trim());
     }
 }

Added: activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml?rev=1463909&view=auto
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml (added)
+++ activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml Wed Apr  3 10:36:37 2013
@@ -0,0 +1,98 @@
+<!--
+
+    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:amq="http://activemq.apache.org/schema/core"
+  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.0.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">
+
+
+    <broker xmlns="http://activemq.apache.org/schema/core"
+            brokerName="${broker-name}"
+            dataDirectory="${data}"
+            start="false">
+
+        <persistenceAdapter>
+            <kahaDB directory="${data}/kahadb"/>
+        </persistenceAdapter>
+
+        <plugins>
+            <jaasAuthenticationPlugin configuration="karaf" />
+            <authorizationPlugin>
+              <map>
+                <authorizationMap groupClass="org.apache.karaf.jaas.boot.principal.RolePrincipal">
+                  <authorizationEntries>
+                    <authorizationEntry queue=">" read="admin" write="admin" admin="admin"/>
+                    <authorizationEntry topic=">" read="admin" write="admin" admin="admin"/>
+                    <authorizationEntry topic="ActiveMQ.Advisory.>" read="admin" write="admin" admin="admin"/>
+                  </authorizationEntries>
+                </authorizationMap>
+              </map>
+            </authorizationPlugin>
+        </plugins>
+
+        <systemUsage>
+            <systemUsage>
+                <memoryUsage>
+                    <memoryUsage limit="64 mb"/>
+                </memoryUsage>
+                <storeUsage>
+                    <storeUsage limit="100 gb"/>
+                </storeUsage>
+                <tempUsage>
+                    <tempUsage limit="50 gb"/>
+                </tempUsage>
+            </systemUsage>
+        </systemUsage>
+
+        <transportConnectors>
+            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
+        </transportConnectors>
+    </broker>
+
+    <bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
+        <property name="brokerURL" value="tcp://localhost:61616?jms.dispatchAsync=false"/>
+        <property name="userName" value="karaf" />
+        <property name="password" value="karaf" />
+
+    </bean>
+
+    <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.XaPooledConnectionFactory">
+        <property name="connectionFactory" ref="activemqConnectionFactory"/>
+    </bean>
+
+    <!-- Define the activemq Camel component so we can integrate with the AMQ broker -->
+    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"
+          depends-on="pooledConnectionFactory">
+        <property name="connectionFactory" ref="pooledConnectionFactory"/>
+        <property name="cacheLevel" value="0"/>
+    </bean>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route id="queueToDbTransacted">
+            <from uri="activemq:queue:camel_in"/>
+            <to uri="activemq:queue:camel_out"/>
+        </route>
+    </camelContext>
+
+
+</beans>

Propchange: activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: activemq/trunk/activemq-karaf/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf/src/main/resources/features.xml?rev=1463909&r1=1463908&r2=1463909&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf/src/main/resources/features.xml (original)
+++ activemq/trunk/activemq-karaf/src/main/resources/features.xml Wed Apr  3 10:36:37 2013
@@ -71,7 +71,7 @@
     <feature name="activemq-camel" version="${project.version}" resolver="(obr)" start-level="50">
         <feature version="${project.version}">activemq-client</feature>
         <feature version="${camel-version-range}">camel-jms</feature>
-        <bundle>mvn:org.apache.activemq/activemq-camel/${project.version}</bundle>
+        <feature version="${camel-version-range}">camel</feature>
     </feature>
 
     <feature name="activemq-web-console" version="${project.version}" resolver="(obr)" start-level="50">

Modified: activemq/trunk/activemq-osgi/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-osgi/pom.xml?rev=1463909&r1=1463908&r2=1463909&view=diff
==============================================================================
--- activemq/trunk/activemq-osgi/pom.xml (original)
+++ activemq/trunk/activemq-osgi/pom.xml Wed Apr  3 10:36:37 2013
@@ -221,6 +221,9 @@
                   <includes>
                     <include>spring.*</include>
                   </includes>
+                  <excludes>
+                      <exclude>spring.handlers</exclude>
+                  </excludes>
                 </resource>
               </resources>
             </configuration>

Added: activemq/trunk/activemq-osgi/src/main/resources/META-INF/spring.handlers
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-osgi/src/main/resources/META-INF/spring.handlers?rev=1463909&view=auto
==============================================================================
--- activemq/trunk/activemq-osgi/src/main/resources/META-INF/spring.handlers (added)
+++ activemq/trunk/activemq-osgi/src/main/resources/META-INF/spring.handlers Wed Apr  3 10:36:37 2013
@@ -0,0 +1,6 @@
+# manual creation to include camel handler so we can embed camel context in xbean xml config
+#
+http\://activemq.apache.org/schema/core=org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
+http\://camel.apache.org/schema/spring=org.apache.camel.spring.handler.CamelNamespaceHandler
+http\://camel.apache.org/schema/spring/v2.10=org.apache.camel.spring.handler.CamelNamespaceHandler
+http\://camel.apache.org/schema/osgi=org.apache.camel.osgi.CamelNamespaceHandler