camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r828399 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/
Date Thu, 22 Oct 2009 08:41:55 GMT
Author: davsclaus
Date: Thu Oct 22 08:41:55 2009
New Revision: 828399

URL: http://svn.apache.org/viewvc?rev=828399&view=rev
Log:
CAMEL-2097: Fixed setting request timeout not disalbed when 0. Also more @deprecated for old
jms 1.0.2. Added more unit tests.

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
  (with props)
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsNoRequestTimeoutTest.java
      - copied, changed from r828342, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java
Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java?rev=828399&r1=828398&r2=828399&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
Thu Oct 22 08:41:55 2009
@@ -295,6 +295,10 @@
         getConfiguration().setTransactionTimeout(transactionTimeout);
     }
 
+    /**
+     * @deprecated will be removed in Camel 2.2
+     */
+    @Deprecated
     public void setUseVersion102(boolean useVersion102) {
         getConfiguration().setUseVersion102(useVersion102);
     }

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java?rev=828399&r1=828398&r2=828399&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
Thu Oct 22 08:41:55 2009
@@ -573,6 +573,10 @@
         return getConfiguration().isUseMessageIDAsCorrelationID();
     }
 
+    /**
+     * @deprecated will be removed in Camel 2.2
+     */
+    @Deprecated
     public boolean isUseVersion102() {
         return getConfiguration().isUseVersion102();
     }
@@ -813,6 +817,10 @@
         getConfiguration().setUseMessageIDAsCorrelationID(useMessageIDAsCorrelationID);
     }
 
+    /**
+     * @deprecated will be removed in Camel 2.2
+     */
+    @Deprecated
     public void setUseVersion102(boolean useVersion102) {
         getConfiguration().setUseVersion102(useVersion102);
     }

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=828399&r1=828398&r2=828399&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
Thu Oct 22 08:41:55 2009
@@ -221,7 +221,7 @@
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Message sent, now waiting for reply at: " + replyTo.toString());
                 }
-                if (requestTimeout < 0) {
+                if (requestTimeout <= 0) {
                     message = (Message)futureHolder.get().get();
                 } else {
                     message = (Message)futureHolder.get().get(requestTimeout, TimeUnit.MILLISECONDS);
@@ -242,9 +242,9 @@
 
                 if (endpoint.isTransferException() && body instanceof Exception)
{
                     if (LOG.isDebugEnabled()) {
-                        LOG.debug("Reply recieved. Setting reply an Exception: " + body);
+                        LOG.debug("Reply recieved. Setting reply as an Exception: " + body);
                     }
-                    // we got an exception back and endpoint was configued to transfer exception
+                    // we got an exception back and endpoint was configured to transfer exception
                     // therefore set response as exception
                     exchange.setException((Exception) body);
                 } else {

Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java?rev=828399&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
(added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
Thu Oct 22 08:41:55 2009
@@ -0,0 +1,104 @@
+/**
+ * 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.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class JmsComponentTest extends CamelTestSupport {
+
+    protected String componentName = "activemq";
+    protected JmsEndpoint endpoint;
+
+    @Test
+    public void testComponentOptions() throws Exception {
+        String reply = template.requestBody("activemq:queue:hello?requestTimeout=0", "Hello
World", String.class);
+        assertEquals("Bye World", reply);
+
+        assertEquals(true, endpoint.isAcceptMessagesWhileStopping());
+        assertEquals(true, endpoint.isAlwaysCopyMessage());
+        assertEquals(1, endpoint.getAcknowledgementMode());
+        assertEquals(true, endpoint.isAutoStartup());
+        assertEquals(1, endpoint.getCacheLevel());
+        assertEquals("foo", endpoint.getClientId());
+        assertEquals(2, endpoint.getConcurrentConsumers());
+        assertEquals(ConsumerType.Simple, endpoint.getConsumerType());
+        assertEquals(true, endpoint.isDeliveryPersistent());
+        assertEquals(true, endpoint.isExplicitQosEnabled());
+        assertEquals(20, endpoint.getIdleTaskExecutionLimit());
+        assertEquals(5, endpoint.getMaxConcurrentConsumers());
+        assertEquals(90, endpoint.getMaxMessagesPerTask());
+        assertEquals(3, endpoint.getPriority());
+        assertEquals(5000, endpoint.getReceiveTimeout());
+        assertEquals(9000, endpoint.getRecoveryInterval());
+        assertEquals(3000, endpoint.getTimeToLive());
+        assertEquals(true, endpoint.isTransacted());
+        assertEquals(15000, endpoint.getTransactionTimeout());
+        assertEquals(false, endpoint.isUseVersion102());
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+        JmsComponent comp = jmsComponentClientAcknowledge(connectionFactory);
+
+        comp.setAcceptMessagesWhileStopping(true);
+        comp.setAlwaysCopyMessage(true);
+        comp.setAcknowledgementMode(1);
+        comp.setAutoStartup(true);
+        comp.setCacheLevel(1);
+        comp.setClientId("foo");
+        comp.setConcurrentConsumers(2);
+        comp.setConsumerType(ConsumerType.Simple);
+        comp.setDeliveryPersistent(true);
+        comp.setExplicitQosEnabled(true);
+        comp.setIdleTaskExecutionLimit(20);
+        comp.setMaxConcurrentConsumers(5);
+        comp.setMaxMessagesPerTask(90);
+        comp.setPriority(3);
+        comp.setReceiveTimeout(5000);
+        comp.setRecoveryInterval(9000);
+        comp.setTimeToLive(3000);
+        comp.setTransacted(true);
+        comp.setTransactionTimeout(15000);
+        comp.setUseVersion102(false);
+
+        camelContext.addComponent(componentName, comp);
+
+        endpoint = (JmsEndpoint) comp.createEndpoint("queue:hello");
+
+        return camelContext;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(endpoint).transform(constant("Bye World"));
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsNoRequestTimeoutTest.java
(from r828342, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsNoRequestTimeoutTest.java?p2=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsNoRequestTimeoutTest.java&p1=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java&r1=828342&r2=828399&rev=828399&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsNoRequestTimeoutTest.java
Thu Oct 22 08:41:55 2009
@@ -20,40 +20,19 @@
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
 
-/**
- * A simple request / reply test
- */
-public class JmsSimpleRequestReplyTest extends CamelTestSupport {
+public class JmsNoRequestTimeoutTest extends CamelTestSupport {
 
     protected String componentName = "activemq";
 
     @Test
-    public void testRequetReply() throws Exception {
-        MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedMessageCount(1);
-
-        Exchange out = template.send("activemq:queue:hello", ExchangePattern.InOut, new Processor()
{
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setBody("Hello World");
-                exchange.getIn().setHeader("foo", 123);
-            }
-        });
-
-        result.assertIsSatisfied();
-
-        assertNotNull(out);
-
-        assertEquals("Bye World", out.getOut().getBody(String.class));
-        assertEquals(123, out.getOut().getHeader("foo"));
+    public void testNoRequestTimeout() throws Exception {
+        String reply = template.requestBody("activemq:queue:hello?requestTimeout=0", "Hello
World", String.class);
+        assertEquals("Bye World", reply);
     }
 
     protected CamelContext createCamelContext() throws Exception {
@@ -68,12 +47,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("activemq:queue:hello").process(new Processor() {
-                    public void process(Exchange exchange) throws Exception {
-                        exchange.getIn().setBody("Bye World");
-                        assertNotNull(exchange.getIn().getHeader("JMSReplyTo"));
-                    }
-                }).to("mock:result");
+                from("activemq:queue:hello").transform(constant("Bye World"));
             }
         };
     }



Mime
View raw message