You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/08/02 12:56:44 UTC

svn commit: r1368413 [3/5] - in /camel/trunk: components/ components/camel-sjms/ components/camel-sjms/src/ components/camel-sjms/src/main/ components/camel-sjms/src/main/java/ components/camel-sjms/src/main/java/org/ components/camel-sjms/src/main/jav...

Added: camel/trunk/components/camel-sjms/src/main/resources/META-INF/services/org/apache/camel/component/sjms
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/main/resources/META-INF/services/org/apache/camel/component/sjms?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/main/resources/META-INF/services/org/apache/camel/component/sjms (added)
+++ camel/trunk/components/camel-sjms/src/main/resources/META-INF/services/org/apache/camel/component/sjms Thu Aug  2 10:56:40 2012
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.sjms.SjmsComponent

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorOptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorOptionTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorOptionTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorOptionTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,84 @@
+/**
+ * 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.camel.component.sjms;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+public class JmsSelectorOptionTest extends JmsTestSupport  {
+
+    @Test
+    public void testJmsMessageWithSelector() throws Exception {
+        MockEndpoint endpointA = getMockEndpoint("mock:a");
+        MockEndpoint endpointB = getMockEndpoint("mock:b");
+        MockEndpoint endpointC = getMockEndpoint("mock:c");
+        
+        endpointA.expectedBodiesReceivedInAnyOrder("A blue car!", "A blue car, again!");
+        endpointA.expectedHeaderReceived("color", "blue");
+        endpointB.expectedHeaderReceived("color", "red");
+        endpointB.expectedBodiesReceived("A red car!");
+        
+        endpointC.expectedBodiesReceived("Message1", "Message2");
+        endpointC.expectedMessageCount(2);
+
+        template.sendBodyAndHeader("sjms:queue:hello", "A blue car!", "color", "blue");
+        template.sendBodyAndHeader("sjms:queue:hello", "A red car!", "color", "red");
+        template.sendBodyAndHeader("sjms:queue:hello", "A blue car, again!", "color", "blue");
+        template.sendBodyAndHeader("sjms:queue:hello", "Message1", "SIZE_NUMBER", 1505);
+        template.sendBodyAndHeader("sjms:queue:hello", "Message3", "SIZE_NUMBER", 1300);
+        template.sendBodyAndHeader("sjms:queue:hello", "Message2", "SIZE_NUMBER", 1600);
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Test
+    public void testConsumerTemplate() throws Exception {
+        template.sendBodyAndHeader("sjms:queue:consumer", "Message1", "SIZE_NUMBER", 1505);
+        template.sendBodyAndHeader("sjms:queue:consumer", "Message3", "SIZE_NUMBER", 1300);
+        template.sendBodyAndHeader("sjms:queue:consumer", "Message2", "SIZE_NUMBER", 1600);
+
+        // process every exchange which is ready. If no exchange is left break
+        // the loop
+        while (true) {
+            Exchange ex = consumer.receiveNoWait("sjms:queue:consumer?messageSelector=SIZE_NUMBER<1500");
+            if (ex != null) {
+                Message message = ex.getIn();
+                int size = message.getHeader("SIZE_NUMBER", int.class);
+                assertTrue("The message header SIZE_NUMBER should be less than 1500", size < 1500);
+                assertEquals("The message body is wrong", "Message3", message.getBody());
+            } else {
+                break;
+            }
+        }
+
+    }
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:queue:hello?messageSelector=color='blue'").to("mock:a");
+                from("sjms:queue:hello?messageSelector=color='red'").to("mock:b");
+                from("sjms:queue:hello?messageSelector=SIZE_NUMBER>1500").to("mock:c");
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/JmsSelectorTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,58 @@
+/**
+ * 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.camel.component.sjms;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class JmsSelectorTest extends JmsTestSupport {
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testJmsSelector() throws Exception {
+        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
+        String expectedBody = "Hello there!";
+        String expectedBody2 = "Goodbye!";
+
+        resultEndpoint.expectedBodiesReceived(expectedBody2);
+        resultEndpoint.message(0).header("cheese").isEqualTo("y");
+
+        template.sendBodyAndHeader("sjms:test.a", expectedBody, "cheese", "x");
+        template.sendBodyAndHeader("sjms:test.a", expectedBody2, "cheese", "y");
+
+        resultEndpoint.assertIsSatisfied();
+    }
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:test.a").to("sjms:test.b");
+                from("sjms:test.b?messageSelector=cheese='y'").to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SimpleJmsComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SimpleJmsComponentTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SimpleJmsComponentTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SimpleJmsComponentTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,46 @@
+/**
+ * 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.camel.component.sjms;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+public class SimpleJmsComponentTest extends CamelTestSupport {
+
+
+    @Test
+    public void testHelloWorld() throws Exception {
+        SjmsComponent component = (SjmsComponent) this.context.getComponent("sjms");
+        assertNotNull(component);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
+                        "vm://broker?broker.persistent=false&broker.useJmx=true");
+                SjmsComponent component = new SjmsComponent();
+                component.setConnectionFactory(connectionFactory);
+                getContext().addComponent("sjms", component);
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointNameOverrideTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointNameOverrideTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointNameOverrideTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointNameOverrideTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,80 @@
+/**
+ * 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.camel.component.sjms;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+public class SjmsEndpointNameOverrideTest extends CamelTestSupport {
+
+    private static final String BEAN_NAME = "not-sjms";
+    
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testDefaults() throws Exception {
+        Endpoint endpoint = context.getEndpoint(BEAN_NAME + ":test");
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof SjmsEndpoint);
+        SjmsEndpoint sjms = (SjmsEndpoint) endpoint;
+        assertEquals(sjms.getEndpointUri(), BEAN_NAME + "://queue:test");
+        assertEquals(sjms.createExchange().getPattern(), ExchangePattern.InOnly);
+    }
+
+    @Test(expected = ResolveEndpointFailedException.class)
+    public void testUnsupportedProtocol() throws Exception {
+        context.getEndpoint("sjms:bad-queue:test");
+    }
+
+    @Test
+    public void testQueueEndpoint() throws Exception {
+        Endpoint sjms = context.getEndpoint(BEAN_NAME + ":queue:test");
+        assertNotNull(sjms);
+        assertTrue(sjms instanceof SjmsEndpoint);
+        assertEquals(sjms.getEndpointUri(), BEAN_NAME + "://queue:test");
+    }
+
+    @Test
+    public void testTopicEndpoint() throws Exception {
+        Endpoint sjms = context.getEndpoint(BEAN_NAME + ":topic:test");
+        assertNotNull(sjms);
+        assertTrue(sjms instanceof SjmsEndpoint);
+        assertEquals(sjms.getEndpointUri(), BEAN_NAME + "://topic:test");
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
+                "vm://broker?broker.persistent=false&broker.useJmx=false");
+        SjmsComponent component = new SjmsComponent();
+        component.setMaxConnections(1);
+        component.setConnectionFactory(connectionFactory);
+        camelContext.addComponent(BEAN_NAME, component);
+
+        return camelContext;
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsEndpointTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,154 @@
+/**
+ * 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.camel.component.sjms;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+public class SjmsEndpointTest extends CamelTestSupport {
+    
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testDefaults() throws Exception {
+        Endpoint endpoint = context.getEndpoint("sjms:test");
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof SjmsEndpoint);
+        SjmsEndpoint sjms = (SjmsEndpoint) endpoint;
+        assertEquals(sjms.getEndpointUri(), "sjms://queue:test");
+        assertEquals(sjms.createExchange().getPattern(), ExchangePattern.InOnly);
+    }
+
+    @Test(expected = ResolveEndpointFailedException.class)
+    public void testUnsupportedProtocol() throws Exception {
+        context.getEndpoint("sjms:bad-queue:test");
+    }
+
+    @Test
+    public void testQueueEndpoint() throws Exception {
+        Endpoint sjms = context.getEndpoint("sjms:queue:test");
+        assertNotNull(sjms);
+        assertEquals(sjms.getEndpointUri(), "sjms://queue:test");
+        assertTrue(sjms instanceof SjmsEndpoint);
+    }
+
+    @Test
+    public void testSetTransacted() throws Exception {
+        Endpoint endpoint = context.getEndpoint("sjms:queue:test?transacted=true");
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof SjmsEndpoint);
+        SjmsEndpoint qe = (SjmsEndpoint) endpoint;
+        assertTrue(qe.isTransacted());
+    }
+
+    @Test
+    public void testAsyncProducer() throws Exception {
+        Endpoint endpoint = context.getEndpoint("sjms:queue:test?synchronous=true");
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof SjmsEndpoint);
+        SjmsEndpoint qe = (SjmsEndpoint) endpoint;
+        assertTrue(qe.isSynchronous());
+    }
+
+    @Test
+    public void testNamedReplyTo() throws Exception {
+        String namedReplyTo = "reply.to.queue";
+        Endpoint endpoint = context.getEndpoint("sjms:queue:test?namedReplyTo=" + namedReplyTo);
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof SjmsEndpoint);
+        SjmsEndpoint qe = (SjmsEndpoint) endpoint;
+        assertEquals(qe.getNamedReplyTo(), namedReplyTo);
+        assertEquals(qe.createExchange().getPattern(), ExchangePattern.InOut);
+    }
+
+    @Test
+    public void testDefaultExchangePattern() throws Exception {
+        try {
+            SjmsEndpoint sjms = (SjmsEndpoint) context.getEndpoint("sjms:queue:test");
+            assertNotNull(sjms);
+            assertEquals(ExchangePattern.InOnly, sjms.getExchangePattern());
+//            assertTrue(sjms.createExchange().getPattern().equals(ExchangePattern.InOnly));
+        } catch (Exception e) {
+            fail("Exception thrown: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Test
+    public void testInOnlyExchangePattern() throws Exception {
+        try {
+            Endpoint sjms = context.getEndpoint("sjms:queue:test?exchangePattern=" + ExchangePattern.InOnly);
+            assertNotNull(sjms);
+            assertTrue(sjms.createExchange().getPattern().equals(ExchangePattern.InOnly));
+        } catch (Exception e) {
+            fail("Exception thrown: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Test
+    public void testInOutExchangePattern() throws Exception {
+        try {
+            Endpoint sjms = context.getEndpoint("sjms:queue:test?exchangePattern=" + ExchangePattern.InOut);
+            assertNotNull(sjms);
+            assertTrue(sjms.createExchange().getPattern().equals(ExchangePattern.InOut));
+        } catch (Exception e) {
+            fail("Exception thrown: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Test(expected = ResolveEndpointFailedException.class)
+    public void testUnsupportedMessageExchangePattern() throws Exception {
+        context.getEndpoint("sjms:queue:test2?messageExchangePattern=" + ExchangePattern.OutOnly);
+    }
+
+    @Test
+    public void testNamedReplyToAndMEPMatch() throws Exception {
+        String namedReplyTo = "reply.to.queue";
+        Endpoint endpoint = context.getEndpoint("sjms:queue:test?namedReplyTo=" + namedReplyTo + "&exchangePattern=" + ExchangePattern.InOut);
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof SjmsEndpoint);
+        SjmsEndpoint qe = (SjmsEndpoint) endpoint;
+        assertEquals(qe.getNamedReplyTo(), namedReplyTo);
+        assertEquals(qe.createExchange().getPattern(), ExchangePattern.InOut);
+    }
+
+    @Test(expected = Exception.class)
+    public void testNamedReplyToAndMEPMismatch() throws Exception {
+        context.getEndpoint("sjms:queue:test?namedReplyTo=reply.to.queue&exchangePattern=" + ExchangePattern.InOnly);
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
+                "vm://broker?broker.persistent=false&broker.useJmx=false");
+        SjmsComponent component = new SjmsComponent();
+        component.setMaxConnections(3);
+        component.setConnectionFactory(connectionFactory);
+        camelContext.addComponent("sjms", component);
+
+        return camelContext;
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerFalseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerFalseTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerFalseTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerFalseTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,73 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.SjmsComponent;
+import org.apache.camel.component.sjms.support.MyAsyncComponent;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class AsyncConsumerFalseTest extends CamelTestSupport {
+
+    @Test
+    public void testAsyncJmsConsumer() throws Exception {
+        // async is disabled (so we should receive in same order)
+        getMockEndpoint("mock:result").expectedBodiesReceived("Camel", "Hello World");
+
+        template.sendBody("sjms:queue:start", "Hello Camel");
+        template.sendBody("sjms:queue:start", "Hello World");
+        assertMockEndpointsSatisfied();
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        camelContext.addComponent("async", new MyAsyncComponent());
+
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
+                "vm://broker?broker.persistent=false");
+        SjmsComponent component = new SjmsComponent();
+        component.setConnectionFactory(connectionFactory);
+        camelContext.addComponent("sjms", component);
+
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // disable async in only mode on the consumer
+                from("sjms:queue:start")
+                        .choice()
+                            .when(body().contains("Camel"))
+                            .to("async:camel?delay=2000")
+                            .to("mock:result")
+                        .otherwise()
+                            .to("mock:result");
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerInOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerInOutTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerInOutTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/AsyncConsumerInOutTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,83 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.SjmsComponent;
+import org.apache.camel.component.sjms.support.MyAsyncComponent;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class AsyncConsumerInOutTest extends CamelTestSupport {
+
+    @Test
+    public void testAsyncJmsConsumer() throws Exception {
+        // Hello World is received first despite its send last
+        // the reason is that the first message is processed asynchronously
+        // and it takes 2 sec to complete, so in between we have time to
+        // process the 2nd message on the queue
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Bye Camel");
+
+        template.sendBody("sjms:queue:start", "Hello Camel");
+        template.sendBody("sjms:queue:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        camelContext.addComponent("async", new MyAsyncComponent());
+
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
+                "vm://broker?broker.persistent=false");
+        SjmsComponent component = new SjmsComponent();
+        component.setConnectionFactory(connectionFactory);
+        camelContext.addComponent("sjms", component);
+
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // enable async in only mode on the consumer
+                from("sjms:queue:start?synchronous=false")
+                        .choice()
+                            .when(body().contains("Camel"))
+                            .to("async:camel?delay=2000")
+                            .inOut("sjms:queue:in.out.test?namedReplyTo=response.queue&synchronous=false")
+                            .to("mock:result")
+                        .otherwise()
+                            .to("log:other")
+                            .to("mock:result");
+
+                from("sjms:queue:in.out.test?exchangePattern=InOut&synchronous=false")
+                    .to("log:camel")
+                    .transform(constant("Bye Camel"));
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncFalseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncFalseTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncFalseTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncFalseTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,73 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class InOnlyConsumerAsyncFalseTest extends JmsTestSupport {
+
+    private static final String SJMS_QUEUE_NAME = "sjms:queue:in.only.consumer.synch";
+    private static final String MOCK_RESULT = "mock:result";
+    private static String beforeThreadName;
+    private static String afterThreadName;
+    
+    @Test
+    public void testInOnlyConsumerAsyncTrue() throws Exception {
+        getMockEndpoint(MOCK_RESULT).expectedBodiesReceived("Hello Camel", "Hello World");
+
+        template.sendBody(SJMS_QUEUE_NAME, "Hello Camel");
+        template.sendBody(SJMS_QUEUE_NAME, "Hello World");
+
+        // Hello World is received first despite its send last
+        // the reason is that the first message is processed asynchronously
+        // and it takes 2 sec to complete, so in between we have time to
+        // process the 2nd message on the queue
+        Thread.sleep(3000);
+
+        assertMockEndpointsSatisfied();
+        assertTrue(beforeThreadName.equals(afterThreadName));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(SJMS_QUEUE_NAME).to("log:before").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        beforeThreadName = Thread.currentThread().getName();
+                        if (exchange.getIn().getBody(String.class).equals("Hello Camel")) {
+                            Thread.sleep(2000);
+                        }
+                    }
+                }).process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        afterThreadName = Thread.currentThread().getName();
+                    }
+                }).to("log:after").to(MOCK_RESULT);
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncTrueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncTrueTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncTrueTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerAsyncTrueTest.java Thu Aug  2 10:56:40 2012
@@ -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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class InOnlyConsumerAsyncTrueTest extends JmsTestSupport {
+
+    private static final String MOCK_RESULT = "mock:result";
+    
+    @Test
+    public void testInOnlyConsumerAsyncTrue() throws Exception {
+        getMockEndpoint(MOCK_RESULT).expectedBodiesReceived("Hello World", "Hello Camel");
+
+        template.sendBody("sjms:queue:in.only.consumer.async", "Hello Camel");
+        template.sendBody("sjms:queue:in.only.consumer.async", "Hello World");
+//        Thread.sleep(4000);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("sjms:queue:in.only.consumer.async?synchronous=false").to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            if (exchange.getIn().getBody(String.class).equals("Hello Camel")) {
+                                Thread.sleep(2000);
+                            }
+                        }
+                    }).to("log:after").to(MOCK_RESULT);
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerDefaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerDefaultTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerDefaultTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerDefaultTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOnlyConsumerDefaultTest extends JmsTestSupport {
+
+    private static final String SJMS_QUEUE_NAME = "sjms:in.only.consumer.";
+    private static final String MOCK_RESULT = "mock:result";
+
+    @Test
+    public void testSynchronous() throws Exception {
+        final String expectedBody = "Hello World";
+        MockEndpoint mock = getMockEndpoint(MOCK_RESULT);
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived(expectedBody);
+
+        template.sendBody(SJMS_QUEUE_NAME, expectedBody);
+        
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(SJMS_QUEUE_NAME)
+                    .to(MOCK_RESULT);
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerQueueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerQueueTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerQueueTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerQueueTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOnlyConsumerQueueTest extends JmsTestSupport {
+
+    private static final String SJMS_QUEUE_NAME = "sjms:queue:in.only.consumer.queue";
+    private static final String MOCK_RESULT = "mock:result";
+
+    @Test
+    public void testSynchronous() throws Exception {
+        final String expectedBody = "Hello World";
+        MockEndpoint mock = getMockEndpoint(MOCK_RESULT);
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived(expectedBody);
+
+        template.sendBody(SJMS_QUEUE_NAME, expectedBody);
+        
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(SJMS_QUEUE_NAME)
+                    .to(MOCK_RESULT);
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTempQueueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTempQueueTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTempQueueTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTempQueueTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOnlyConsumerTempQueueTest extends JmsTestSupport {
+
+    private static final String SJMS_QUEUE_NAME = "sjms:queue:in.only.consumer.";
+    private static final String MOCK_RESULT = "mock:result";
+
+    @Test
+    public void testSynchronous() throws Exception {
+        final String expectedBody = "Hello World";
+        MockEndpoint mock = getMockEndpoint(MOCK_RESULT);
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived(expectedBody);
+
+        template.sendBody(SJMS_QUEUE_NAME, expectedBody);
+        
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(SJMS_QUEUE_NAME)
+                    .to(MOCK_RESULT);
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTopicTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTopicTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTopicTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyConsumerTopicTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,59 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOnlyConsumerTopicTest extends JmsTestSupport {
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testSynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello Camel", "Hello World");
+        template.sendBody("sjms:topic:in.only.topic", "Hello Camel");
+        template.sendBody("sjms:topic:in.only.topic", "Hello World");
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:topic:in.only.topic").to("log:request").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        String body = (String)exchange.getIn().getBody();
+                        if (body.contains("Camel")) {
+                            Thread.sleep(2000);
+                        }
+                    }
+                }).to("log:response").to("mock:result");
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyQueueConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyQueueConsumerTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyQueueConsumerTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyQueueConsumerTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,65 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+public class InOnlyQueueConsumerTest extends JmsTestSupport {
+    
+    private static final String TEST_DESTINATION_NAME = "sjms:queue:in.only.queue.consumer.test";
+    
+    @Override
+    protected boolean useJmx() {
+        return false;
+    }
+
+    @Test
+    public void testInOnlyQueueProducer() throws Exception {
+        final String expectedBody = "Hello World";
+        MockEndpoint mock = getMockEndpoint("mock:test.done");
+
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived(expectedBody);
+
+        template.sendBody(TEST_DESTINATION_NAME, "World");
+        
+        mock.assertIsSatisfied();
+
+    }
+
+    /*
+     * @see org.apache.camel.test.junit4.CamelTestSupport#createRouteBuilder()
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+
+                from(TEST_DESTINATION_NAME)
+                    .transform(body().prepend("Hello "))
+                    .to("log:test?showAll=true", "mock:test.done");
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicConsumerTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicConsumerTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicConsumerTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,66 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+public class InOnlyTopicConsumerTest extends JmsTestSupport {
+    
+    private static final String TEST_DESTINATION_NAME = "sjms:topic:in.only.topic.consumer.test";
+    
+    @Override
+    protected boolean useJmx() {
+        return false;
+    }
+
+    @Test
+    public void testSynchronous() throws Exception {
+        final String expectedBody = "Hello World!";
+        MockEndpoint mock = getMockEndpoint("mock:result");
+
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived(expectedBody);
+
+        template.sendBody("direct:start", expectedBody);
+        
+        mock.assertIsSatisfied();
+
+    }
+
+    /*
+     * @see org.apache.camel.test.junit4.CamelTestSupport#createRouteBuilder()
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                    .to(TEST_DESTINATION_NAME);
+                
+                from(TEST_DESTINATION_NAME)
+                    .to("log:test.log.1?showBody=true", "mock:result");
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicDurableConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicDurableConsumerTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicDurableConsumerTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOnlyTopicDurableConsumerTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,89 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.SjmsComponent;
+import org.apache.camel.component.sjms.pool.DefaultConnectionResource;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+public class InOnlyTopicDurableConsumerTest extends CamelTestSupport {
+    
+    private static final String CONNECTION_ID = "test-connection-1";
+    private static final String BROKER_URI = "vm://durable.broker?broker.persistent=false&broker.useJmx=true";
+    
+    @Override
+    protected boolean useJmx() {
+        return false;
+    }
+
+    @Test
+    public void testDurableTopic() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+
+        MockEndpoint mock2 = getMockEndpoint("mock:result2");
+        mock2.expectedBodiesReceived("Hello World");
+
+        // wait a bit and send the message
+        Thread.sleep(1000);
+
+        template.sendBody("sjms:topic:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    
+    /*
+     * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
+        DefaultConnectionResource connectionResource = new DefaultConnectionResource();
+        connectionResource.setConnectionFactory(connectionFactory);
+        connectionResource.setConnectionId(CONNECTION_ID);
+        CamelContext camelContext = super.createCamelContext();
+        SjmsComponent component = new SjmsComponent();
+        component.setConnectionResource(connectionResource);
+        component.setMaxConnections(1);
+        camelContext.addComponent("sjms", component);
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("sjms:topic:foo?durableSubscriptionId=bar")
+                    .to("mock:result");
+
+                from("sjms:topic:foo?durableSubscriptionId=bar")
+                    .to("mock:result2");
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueAsyncTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueAsyncTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueAsyncTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,61 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOutConsumerQueueAsyncTest extends JmsTestSupport {
+
+    @Test
+    public void testAynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello Camel");
+
+        template.sendBody("sjms:start", "Hello Camel");
+        template.sendBody("sjms:start", "Hello World");
+        Thread.sleep(4000);
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:queue:start?synchronous=false")
+                    .to("sjms:queue:in.out.queue?exchangePattern=InOut&synchronous=false&namedReplyTo=in.out.queue.response")
+                    .to("mock:result");
+
+                from("sjms:queue:in.out.queue?exchangePattern=InOut&synchronous=false").to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            String body = (String)exchange.getIn().getBody();
+                            if (body.contains("Camel")) {
+                                Thread.sleep(2000);
+                            }
+                        }
+                    });
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerQueueTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,59 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOutConsumerQueueTest extends JmsTestSupport {
+
+    @Test
+    public void testSynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello Camel", "Hello World");
+
+        template.sendBody("sjms:start", "Hello Camel");
+        template.sendBody("sjms:start", "Hello World");
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:queue:start").to("log:request")
+                    .to("sjms:queue:in.out.queue?exchangePattern=InOut&namedReplyTo=in.out.queue.response")
+                    .to("log:response").to("mock:result");
+
+                from("sjms:queue:in.out.queue?exchangePattern=InOut").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        String body = (String)exchange.getIn().getBody();
+                        if (body.contains("Camel")) {
+                            Thread.sleep(2000);
+                        }
+                    }
+                });
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueAsyncTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueAsyncTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueAsyncTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,61 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOutConsumerTempQueueAsyncTest extends JmsTestSupport {
+
+    @Test
+    public void testAynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello Camel");
+
+        template.sendBody("sjms:start", "Hello Camel");
+        template.sendBody("sjms:start", "Hello World");
+        Thread.sleep(5000);
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:queue:start?synchronous=false")
+                    .to("sjms:queue:in.out.temp.queue?exchangePattern=InOut&synchronous=false")
+                    .to("mock:result");
+
+                from("sjms:queue:in.out.temp.queue?exchangePattern=InOut&synchronous=false").to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            String body = (String)exchange.getIn().getBody();
+                            if (body.contains("Camel")) {
+                                Thread.sleep(2000);
+                            }
+                        }
+                    });
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTempQueueTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,59 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOutConsumerTempQueueTest extends JmsTestSupport {
+
+    @Test
+    public void testSynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello Camel", "Hello World");
+
+        template.sendBody("sjms:start", "Hello Camel");
+        template.sendBody("sjms:start", "Hello World");
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:queue:start").to("sjms:queue:in.out.temp.queue?exchangePattern=InOut")
+                    .to("mock:result");
+
+                from("sjms:queue:in.out.temp.queue?exchangePattern=InOut").to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            String body = (String)exchange.getIn().getBody();
+                            if (body.contains("Camel")) {
+                                Thread.sleep(2000);
+                            }
+                        }
+                    });
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTopicTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTopicTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTopicTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConsumerTopicTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,64 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOutConsumerTopicTest extends JmsTestSupport {
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testSynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello Camel", "Hello World");
+        template.sendBody("sjms:topic:start", "Hello Camel");
+        template.sendBody("sjms:topic:start", "Hello World");
+        Thread.sleep(3000);
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("sjms:topic:start").to("log:request")
+                    .to("sjms:topic:in.out.topic?exchangePattern=InOut&namedReplyTo=in.out.topic.response")
+                    .to("log:response").to("mock:result");
+
+                from("sjms:topic:in.out.topic?exchangePattern=InOut").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        String body = (String)exchange.getIn().getBody();
+                        if (body.contains("Camel")) {
+                            Thread.sleep(2000);
+                        }
+                    }
+                });
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutSynchronousConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutSynchronousConsumerTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutSynchronousConsumerTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutSynchronousConsumerTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,71 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class InOutSynchronousConsumerTest extends JmsTestSupport {
+
+    private static String beforeThreadName;
+    private static String afterThreadName;
+    private String url = "sjms:queue:in?namedReplyTo=response.queue";
+
+    @Test
+    public void testSynchronous() throws Exception {
+        String reply = template.requestBody("direct:start", "Hello World", String.class);
+        assertEquals("Bye World", reply);
+
+        assertTrue("Should use same threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            beforeThreadName = Thread.currentThread().getName();
+                        }
+                    })
+                    .inOut(url)
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            afterThreadName = Thread.currentThread().getName();
+                        }
+                    })
+                    .to("log:after")
+                    .to("mock:result");
+
+                from("sjms:queue:in?exchangePattern=InOut").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getOut().setBody("Bye World");
+                    }
+                });
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/TransactedInOnlyQueueConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/TransactedInOnlyQueueConsumerTest.java?rev=1368413&view=auto
==============================================================================
--- camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/TransactedInOnlyQueueConsumerTest.java (added)
+++ camel/trunk/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/TransactedInOnlyQueueConsumerTest.java Thu Aug  2 10:56:40 2012
@@ -0,0 +1,117 @@
+/**
+ * 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.camel.component.sjms.consumer;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelException;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.SjmsComponent;
+import org.apache.camel.component.sjms.jms.JmsMessageHeaderType;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TransactedInOnlyQueueConsumerTest extends CamelTestSupport {
+    private static final String TEST_DESTINATION_1 = "sjms:queue:transacted.in.only.queue.consumer.test.1?transacted=true";
+    private static final String TEST_DESTINATION_2 = "sjms:queue:transacted.in.only.queue.consumer.test.2?transacted=true";
+
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
+   
+    @Test
+    public void testTransactedInOnlyConsumerExchangeFailure() throws Exception {
+        // We should see the World message twice, once for the exception
+        getMockEndpoint("mock:test1.topic.mock.before").expectedBodiesReceived("World", "World");
+        getMockEndpoint("mock:test1.topic.mock.after").expectedBodiesReceived("Hello World");
+        
+        template.sendBody(TEST_DESTINATION_1, "World");
+        
+        getMockEndpoint("mock:test1.topic.mock.before").assertIsSatisfied();
+        getMockEndpoint("mock:test1.topic.mock.after").assertIsSatisfied();
+
+    }
+
+    @Test
+    public void testTransactedInOnlyConsumerRuntimeException() throws Exception {
+        // We should see the World message twice, once for the exception
+        getMockEndpoint("mock:test2.topic.mock.before").expectedBodiesReceived("World", "World");
+        getMockEndpoint("mock:test2.topic.mock.after").expectedBodiesReceived("Hello World");
+        
+        template.sendBody(TEST_DESTINATION_2, "World");
+        
+        getMockEndpoint("mock:test2.topic.mock.before").assertIsSatisfied();
+        getMockEndpoint("mock:test2.topic.mock.after").assertIsSatisfied();
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
+                "vm://broker?broker.persistent=false&broker.useJmx=true");
+        SjmsComponent component = new SjmsComponent();
+        component.setConnectionFactory(connectionFactory);
+        camelContext.addComponent("sjms", component);
+
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from(TEST_DESTINATION_1)
+                    .to("log:test1.before")
+                    .to("mock:test1.topic.mock.before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            logger.info("Begin processing Exchange ID: {}", exchange.getExchangeId());
+                            if (!exchange.getIn().getHeader(JmsMessageHeaderType.JMSRedelivered.toString(), String.class).equalsIgnoreCase("true")) {
+                                logger.info("Exchange does not have a retry message.  Set the exception and allow the retry.");
+                                exchange.setException(new CamelException("Creating Failure"));
+                            } else {
+                                logger.info("Exchange has retry header.  Continue processing the message.");
+                            }
+                        }
+                    })
+                    .transform(body().prepend("Hello "))
+                    .to("log:test1.after?showAll=true", "mock:test1.topic.mock.after");
+                
+                from(TEST_DESTINATION_2)
+                    .to("log:test2.before")
+                    .to("mock:test2.topic.mock.before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            logger.info("Begin processing Exchange ID: {}", exchange.getExchangeId());
+                            if (!exchange.getIn().getHeader(JmsMessageHeaderType.JMSRedelivered.toString(), String.class).equalsIgnoreCase("true")) {
+                                logger.info("Exchange does not have a retry message.  Throw the exception to verify we handle the retry.");
+                                throw new RuntimeCamelException("Creating Failure");
+                            } else {
+                                logger.info("Exchange has retry header.  Continue processing the message.");
+                            }
+                        }
+                    })
+                    .transform(body().prepend("Hello "))
+                    .to("log:test2.after?showAll=true", "mock:test2.topic.mock.after");
+            }
+        };
+    }
+}