Author: dejanb
Date: Wed Mar 31 11:49:53 2010
New Revision: 929486

URL: http://svn.apache.org/viewvc?rev=929486&view=rev
Log:
adding test for https://issues.apache.org/activemq/browse/AMQ-2677

Added:
    
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/
    
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/AMQ2677.java
    
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/TestMDB.java
    activemq/activemq-systest/trunk/src/test/resources/jmstest-camel.xml
Modified:
    activemq/activemq-systest/trunk/pom.xml
    
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/StompLoadTest.java

Modified: activemq/activemq-systest/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/pom.xml?rev=929486&r1=929485&r2=929486&view=diff
==============================================================================
--- activemq/activemq-systest/trunk/pom.xml (original)
+++ activemq/activemq-systest/trunk/pom.xml Wed Mar 31 11:49:53 2010
@@ -44,6 +44,11 @@
        </dependency>
        <dependency>
                <groupId>org.apache.activemq</groupId>
+               <artifactId>activemq-camel</artifactId>
+               <version>${activemq-version}</version>
+       </dependency>
+       <dependency>
+               <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-pool</artifactId>
                <version>${activemq-version}</version>
        </dependency>

Modified: 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/StompLoadTest.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/StompLoadTest.java?rev=929486&r1=929485&r2=929486&view=diff
==============================================================================
--- 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/StompLoadTest.java
 (original)
+++ 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/StompLoadTest.java
 Wed Mar 31 11:49:53 2010
@@ -1,3 +1,19 @@
+/**
+ * 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.activemq.systest;
 
 import java.net.Socket;

Added: 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/AMQ2677.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/AMQ2677.java?rev=929486&view=auto
==============================================================================
--- 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/AMQ2677.java
 (added)
+++ 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/AMQ2677.java
 Wed Mar 31 11:49:53 2010
@@ -0,0 +1,82 @@
+/**
+ * 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.activemq.systest.camel;
+
+import javax.jms.Connection;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class AMQ2677 extends TestCase {
+
+       private static final Log log = LogFactory.getLog(AMQ2677.class);
+
+       private static ClassPathXmlApplicationContext context;
+       
+       public void testPooledConnections() throws Exception {
+               new Thread(new Runnable() {
+                       public void run() {
+                               context = new 
ClassPathXmlApplicationContext("jmstest-camel.xml");
+                       }
+               }, "TestThread").start();
+
+               log.info("main sleeping 10 seconds");
+               Thread.sleep(10000);
+
+               log.info("main starting broker");
+               final BrokerService brokerService = new BrokerService();
+               brokerService.setPersistent(false);
+               brokerService.addConnector("tcp://127.0.0.1:61616");
+               brokerService.start();
+
+               log.info("main finished starting broker, sleeping 10 seconds");
+               Thread.sleep(10000);
+
+               try {
+                       final Connection connection = new 
ActiveMQConnectionFactory(
+                                       
"tcp://127.0.0.1:61616").createConnection();
+                       final Session session = connection.createSession(false,
+                                       Session.AUTO_ACKNOWLEDGE);
+                       final MessageProducer producer = session
+                                       .createProducer(new 
ActiveMQQueue("test.queue"));
+                       connection.start();
+                       for (int i = 0; i < 10; ++i) {
+                               log.info("main sending " + i);
+                               
producer.send(session.createTextMessage(Integer.toString(i)));
+                       }
+               } catch (Exception e) {
+                       log.warn("main", e);
+               }
+               
+               Thread.sleep(2000);
+               
+               assertEquals("Messages not received", 10, 
((TestMDB)context.getBean("testMDB")).getReceived());
+
+               brokerService.stop();
+               context.stop();
+               context.close();
+       }
+
+}

Added: 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/TestMDB.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/TestMDB.java?rev=929486&view=auto
==============================================================================
--- 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/TestMDB.java
 (added)
+++ 
activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/camel/TestMDB.java
 Wed Mar 31 11:49:53 2010
@@ -0,0 +1,47 @@
+/**
+ * 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.activemq.systest.camel;
+
+import org.apache.camel.Body;
+import org.apache.camel.Consume;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TestMDB {
+
+       private final Log log = LogFactory.getLog(getClass());
+       int received = 0;
+
+       public void init() {
+               log.info("init");
+       }
+
+       public void destroy() {
+               log.info("destroy");
+       }
+
+       @Consume(ref = "testQueueEndpoint")
+       public void processMessage(@Body String message) {
+               log.info("processMessage message = " + message);
+               received++;
+       }
+
+       public int getReceived() {
+               return received;
+       }
+
+}

Added: activemq/activemq-systest/trunk/src/test/resources/jmstest-camel.xml
URL: 
http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/resources/jmstest-camel.xml?rev=929486&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/src/test/resources/jmstest-camel.xml (added)
+++ activemq/activemq-systest/trunk/src/test/resources/jmstest-camel.xml Wed 
Mar 31 11:49:53 2010
@@ -0,0 +1,53 @@
+<?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:camel="http://camel.apache.org/schema/spring";
+       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
+    ">
+
+       <camel:camelContext
+               id="jmstest.camel.context">
+
+               <camel:endpoint
+                       id="testQueueEndpoint"
+                       uri="activemq:queue:test.queue" />
+
+       </camel:camelContext>
+
+       <bean
+               id="activemq"
+               class="org.apache.activemq.camel.component.ActiveMQComponent">
+               <property
+                       name="brokerURL"
+                       
value="failover:(tcp://127.0.0.1:61616)?timeout=1000&amp;initialReconnectDelay=1000&amp;maxReconnectDelay=1000&amp;useExponentialBackOff=false"
 />
+       </bean>
+
+       <bean
+               id="testMDB"
+               class="org.apache.activemq.activemq.systest.camel.TestMDB"
+               init-method="init"
+               destroy-method="destroy">
+       </bean>
+
+</beans>


Reply via email to