activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r631509 - in /activemq/trunk: ./ activemq-core/ activemq-core/src/test/data/ activemq-core/src/test/java/org/apache/activemq/camel/ activemq-core/src/test/resources/org/apache/activemq/camel/
Date Wed, 27 Feb 2008 07:56:37 GMT
Author: jstrachan
Date: Tue Feb 26 23:56:33 2008
New Revision: 631509

URL: http://svn.apache.org/viewvc?rev=631509&view=rev
Log:
added a test case showing how to set a property using a Processor http://www.nabble.com/setting-JMSXGroupId-property-from-within-a-processor-tp15706825s22882p15706825.html

Added:
    activemq/trunk/activemq-core/src/test/data/
    activemq/trunk/activemq-core/src/test/data/message1.xml   (with props)
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java
  (with props)
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetHeaderTest.java
  (with props)
    activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml
      - copied, changed from r631503, activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/spring.xml
Modified:
    activemq/trunk/activemq-core/pom.xml
    activemq/trunk/pom.xml

Modified: activemq/trunk/activemq-core/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/pom.xml?rev=631509&r1=631508&r2=631509&view=diff
==============================================================================
--- activemq/trunk/activemq-core/pom.xml (original)
+++ activemq/trunk/activemq-core/pom.xml Tue Feb 26 23:56:33 2008
@@ -201,6 +201,11 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <scope>test</scope>
+    </dependency>
 
     <!-- database testing -->
     <dependency>

Added: activemq/trunk/activemq-core/src/test/data/message1.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/data/message1.xml?rev=631509&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/data/message1.xml (added)
+++ activemq/trunk/activemq-core/src/test/data/message1.xml Tue Feb 26 23:56:33 2008
@@ -0,0 +1,22 @@
+<?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.
+-->
+<person user="james">
+  <firstName>James</firstName>
+  <lastName>Strachan</lastName>
+  <city>London</city>
+</person>
\ No newline at end of file

Propchange: activemq/trunk/activemq-core/src/test/data/message1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java?rev=631509&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java
Tue Feb 26 23:56:33 2008
@@ -0,0 +1,36 @@
+/**
+ *
+ * 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.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.Message;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class SetGroupIdProcessor implements Processor {
+    public void process(Exchange exchange) throws Exception {
+        // lets copy the IN to the OUT message
+        Message out = exchange.getOut();
+        out.copyFrom(exchange.getIn());
+
+        // now lets set a header
+        out.setHeader("JMSXGroupID", "ABC");
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetHeaderTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetHeaderTest.java?rev=631509&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetHeaderTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetHeaderTest.java
Tue Feb 26 23:56:33 2008
@@ -0,0 +1,60 @@
+/**
+ *
+ * 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 java.util.List;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@ContextConfiguration
+public class SetHeaderTest extends AbstractJUnit38SpringContextTests {
+    private static final transient Log LOG = LogFactory.getLog(SetHeaderTest.class);
+
+    @Autowired
+    protected CamelContext camelContext;
+
+    @EndpointInject(uri = "mock:results")
+    protected MockEndpoint expectedEndpoint;
+
+    public void testMocksAreValid() throws Exception {
+        // lets add more expectations
+        expectedEndpoint.expectedMessageCount(1);
+        expectedEndpoint.message(0).header("JMSXGroupID").isEqualTo("ABC");
+
+        MockEndpoint.assertIsSatisfied(camelContext);
+
+        // lets dump the received messages
+        List<Exchange> list = expectedEndpoint.getReceivedExchanges();
+        for (Exchange exchange : list) {
+            Object body = exchange.getIn().getBody();
+            LOG.debug("Received: body: " + body + " of type: " + ObjectHelper.className(body)
+ " on: " + exchange);
+        }
+    }
+}
\ No newline at end of file

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/camel/SetHeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml
(from r631503, activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/spring.xml)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml?p2=activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml&p1=activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/spring.xml&r1=631503&r2=631509&rev=631509&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/spring.xml (original)
+++ activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml
Tue Feb 26 23:56:33 2008
@@ -15,6 +15,7 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
+<!-- START SNIPPET: example -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
@@ -22,31 +23,27 @@
        http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
-  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
-    <beanPostProcessor/>
-    
+  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+    <route>
+      <from uri="file://src/test/data?noop=true"/>
+      <to uri="activemq:testQ-input"/>
+    </route>
+    <route>
+      <from uri="activemq:testQ-input"/>
+      <process ref="groupIdInsertionProcessor"/>
+      <to uri="activemq:testQ-output"/>
+    </route>
+    <route>
+      <from uri="activemq:testQ-output"/>
+      <to uri="mock:results"/>
+    </route>
   </camelContext>
 
-  <bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
-    <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
-  </bean>
-
-  <bean id="sendTo" class="org.apache.activemq.camel.CamelDestination">
-    <property name="uri" value="mock:result"/>
-  </bean>
+  <bean id="groupIdInsertionProcessor" class="org.apache.activemq.camel.SetGroupIdProcessor"/>
 
-  <bean id="consumeFrom" class="org.apache.activemq.camel.CamelDestination">
-    <property name="uri" value="seda:consumer"/>
-  </bean>
-
-  <bean id="camelTemplate" class="org.apache.camel.spring.CamelTemplateFactoryBean"/>
-  <!-- END SNIPPET: example -->
-
-<!--
-  <bean id="connectionFactory" class="org.apache.camel.jms.CamelConnectionFactory">
+  <bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
     <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
   </bean>
--->
 
 </beans>
+        <!-- END SNIPPET: example -->

Modified: activemq/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/pom.xml?rev=631509&r1=631508&r2=631509&view=diff
==============================================================================
--- activemq/trunk/pom.xml (original)
+++ activemq/trunk/pom.xml Tue Feb 26 23:56:33 2008
@@ -30,7 +30,7 @@
 
   <properties>
     <version>5.1-SNAPSHOT</version>
-    <spring-version>2.0.6</spring-version>
+    <spring-version>2.5.1</spring-version>
     <activesoap-version>1.3</activesoap-version>
     <annogen-version>0.1.0</annogen-version>
     <ant-version>1.6.2</ant-version>
@@ -539,6 +539,12 @@
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-test</artifactId>
+        <version>${spring-version}</version>
+      </dependency>
+
       <!-- Optional Derby support-->
       <dependency>
         <groupId>org.apache.derby</groupId>



Mime
View raw message