camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r801680 - in /camel/sandbox/tuning-experiment: camel-core/src/main/java/org/apache/camel/util/ components/camel-jms/src/main/java/org/apache/camel/component/jms/ components/camel-jms/src/test/java/org/apache/camel/component/jms/ components/...
Date Thu, 06 Aug 2009 15:42:28 GMT
Author: davsclaus
Date: Thu Aug  6 15:42:27 2009
New Revision: 801680

URL: http://svn.apache.org/viewvc?rev=801680&view=rev
Log:
Fixed unit test to work with new tuning experiment

Modified:
    camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsBytesMessageTest.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsMapMessageTest.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsObjectMessageTest.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyTest.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateMessageTest.java
    camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateRemoveHeaderMessageTest.java

Modified: camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
(original)
+++ camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
Thu Aug  6 15:42:27 2009
@@ -240,6 +240,12 @@
             if (source.hasProperties()) {
                 result.getProperties().putAll(source.getProperties());
             }
+        } else {
+            // fix problem with IN being at OUT
+            // TODO: make this a bit nicer to read and understand
+            if (!result.isFailed() && result.getPattern().isOutCapable() &&
!result.hasOut() && result.getPattern() != ExchangePattern.InOptionalOut) {
+                result.setOut(result.getIn());
+            }
         }
     }
 

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
Thu Aug  6 15:42:27 2009
@@ -86,7 +86,7 @@
             }
 
             // get the correct jms message to send as reply
-            JmsMessage body = null;
+            org.apache.camel.Message body = null;
             Exception cause = null;
             boolean sendReply = false;
             if (exchange.isFailed()) {
@@ -109,7 +109,7 @@
                 }
             } else if (exchange.hasOut()) {
                 // process OK so get the reply
-                body = (JmsMessage) exchange.getOut();
+                body = exchange.getOut();
                 sendReply = true;
             }
 
@@ -229,7 +229,7 @@
     //-------------------------------------------------------------------------
 
     protected void sendReply(Destination replyDestination, final Message message, final Exchange
exchange,
-                             final JmsMessage out, final Exception cause) {
+                             final org.apache.camel.Message out, final Exception cause) {
         if (replyDestination == null) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Cannot send reply message as there is no replyDestination for:
" + out);

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
Thu Aug  6 15:42:27 2009
@@ -154,6 +154,12 @@
     }
 
     @Override
+    public boolean hasHeaders() {
+        ensureInitialHeaders();
+        return super.hasHeaders();
+    }
+
+    @Override
     public JmsMessage newInstance() {
         return new JmsMessage(null, binding);
     }

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsBytesMessageTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsBytesMessageTest.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsBytesMessageTest.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsBytesMessageTest.java
Thu Aug  6 15:42:27 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.jms;
 
-
 import java.util.Arrays;
 
 import javax.jms.BytesMessage;
@@ -28,6 +27,7 @@
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+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;
@@ -39,7 +39,6 @@
 
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
 
-
 /**
  * @version $Revision$
  */
@@ -68,10 +67,9 @@
 
     @Test
     public void testSendBytesMessage() throws Exception {
-
         endpoint.expectedMessageCount(1);
 
-        byte[] bytes = new byte[] {1, 2, 3};
+        byte[] bytes = new byte[]{1, 2, 3};
 
         template.sendBody("direct:test", bytes);
 
@@ -81,21 +79,15 @@
 
     protected void assertCorrectBytesReceived() {
         Exchange exchange = endpoint.getReceivedExchanges().get(0);
-        // This should be a JMS Exchange
-        assertNotNull(ExchangeHelper.getBinding(exchange, JmsBinding.class));
-        JmsMessage in = (JmsMessage) exchange.getIn();
-        assertNotNull(in);
-        
+
         byte[] bytes = exchange.getIn().getBody(byte[].class);
         log.info("Received bytes: " + Arrays.toString(bytes));
 
         assertNotNull("Should have received a bytes message!", bytes);
-        assertIsInstanceOf(BytesMessage.class, in.getJmsMessage());
         assertEquals("Wrong byte 1", 1, bytes[0]);
         assertEquals("Wrong payload lentght", 3, bytes.length);
     }
 
-
     @Override
     @Before
     public void setUp() throws Exception {
@@ -116,7 +108,15 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("activemq:test.bytes").to("mock:result");
+                from("activemq:test.bytes").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        // This should be a JMS Exchange
+                        assertNotNull(ExchangeHelper.getBinding(exchange, JmsBinding.class));
+                        JmsMessage in = (JmsMessage) exchange.getIn();
+                        assertNotNull(in);
+                        assertIsInstanceOf(BytesMessage.class, in.getJmsMessage());
+                    }
+                }).to("mock:result");
                 from("direct:test").to("activemq:test.bytes");
             }
         };

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsMapMessageTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsMapMessageTest.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsMapMessageTest.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsMapMessageTest.java
Thu Aug  6 15:42:27 2009
@@ -28,6 +28,7 @@
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+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;
@@ -65,16 +66,11 @@
 
     protected void assertCorrectMapReceived() {
         Exchange exchange = endpoint.getReceivedExchanges().get(0);
-        // This should be a JMS Exchange
-        assertNotNull(ExchangeHelper.getBinding(exchange, JmsBinding.class));
-        JmsMessage in = (JmsMessage) exchange.getIn();
-        assertNotNull(in);
-        
+
         Map map = exchange.getIn().getBody(Map.class);
         log.info("Received map: " + map);
 
         assertNotNull("Should have received a map message!", map);
-        assertIsInstanceOf(MapMessage.class, in.getJmsMessage());
         assertEquals("map.foo", "abc", map.get("foo"));
         assertEquals("map.bar", "xyz", map.get("bar"));
         assertEquals("map.size", 2, map.size());
@@ -115,7 +111,15 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("activemq:test.map").to("mock:result");
+                from("activemq:test.map").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        // This should be a JMS Exchange
+                        assertNotNull(ExchangeHelper.getBinding(exchange, JmsBinding.class));
+                        JmsMessage in = (JmsMessage) exchange.getIn();
+                        assertNotNull(in);
+                        assertIsInstanceOf(MapMessage.class, in.getJmsMessage());
+                    }
+                }).to("mock:result");
                 from("direct:test").to("activemq:test.map");
             }
         };

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsObjectMessageTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsObjectMessageTest.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsObjectMessageTest.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeJmsObjectMessageTest.java
Thu Aug  6 15:42:27 2009
@@ -30,7 +30,6 @@
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.util.ExchangeHelper;
 import org.junit.Before;
 import org.junit.Test;
 import org.springframework.jms.core.JmsTemplate;
@@ -79,11 +78,6 @@
 
     protected void assertCorrectObjectReceived() {
         Exchange exchange = endpoint.getReceivedExchanges().get(0);
-        // This should be a JMS Exchange
-        assertNotNull(ExchangeHelper.getBinding(exchange, JmsBinding.class));
-        JmsMessage in = (JmsMessage) exchange.getIn();
-        assertNotNull(in);
-        assertIsInstanceOf(ObjectMessage.class, in.getJmsMessage());
 
         MyUser user = exchange.getIn().getBody(MyUser.class);
         assertEquals("Claus", user.getName());

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
Thu Aug  6 15:42:27 2009
@@ -61,10 +61,8 @@
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
 
-        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
-                "vm://localhost?broker.persistent=false");
-        camelContext.addComponent(componentName,
-                jmsComponentClientAcknowledge(connectionFactory));
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+        camelContext.addComponent(componentName, jmsComponentClientAcknowledge(connectionFactory));
 
         return camelContext;
     }
@@ -81,7 +79,7 @@
                 // the original order request initiator
                 from("amq:queue:inbox")
                     .to("mock:inbox")
-                    .inOnly("amq:topic:orderServiceNotification")
+                    .wireTap("amq:topic:orderServiceNotification")
                     .beanRef("orderService", "handleOrder");
 
                 // this route collects an order request notification

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyTest.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyTest.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyTest.java
Thu Aug  6 15:42:27 2009
@@ -21,6 +21,7 @@
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.CamelContext;
 import org.apache.camel.ExchangePattern;
+import org.apache.camel.InOut;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
@@ -78,7 +79,7 @@
             public void configure() throws Exception {
                 from("activemq:queue:inbox")
                     .to("mock:inbox")
-                    .inOnly("activemq:topic:order")
+                    .wireTap("activemq:topic:order")
                     .beanRef("orderService", "handleOrder");
 
                 from("activemq:topic:order")

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateMessageTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateMessageTest.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateMessageTest.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateMessageTest.java
Thu Aug  6 15:42:27 2009
@@ -58,10 +58,6 @@
                 from(uri)
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
-                            // do not mutate it
-                            JmsMessage msg = assertIsInstanceOf(JmsMessage.class, exchange.getIn());
-                            assertNotNull("javax.jms.Message should not be null", msg.getJmsMessage());
-
                             // get header should not mutate it
                             assertEquals("VALUE_1", exchange.getIn().getHeader("HEADER_1"));
                         }
@@ -70,10 +66,6 @@
                     .setHeader("HEADER_1", constant("VALUE_2"))
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
-                            // it should have been mutated
-                            JmsMessage msg = assertIsInstanceOf(JmsMessage.class, exchange.getIn());
-                            assertNotNull("javax.jms.Message should not be null", msg.getJmsMessage());
-
                             // get header should not mutate it
                             assertEquals("VALUE_2", exchange.getIn().getHeader("HEADER_1"));
                         }

Modified: camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateRemoveHeaderMessageTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateRemoveHeaderMessageTest.java?rev=801680&r1=801679&r2=801680&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateRemoveHeaderMessageTest.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsMutateRemoveHeaderMessageTest.java
Thu Aug  6 15:42:27 2009
@@ -58,10 +58,6 @@
                 from(uri)
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
-                            // do not mutate it
-                            JmsMessage msg = assertIsInstanceOf(JmsMessage.class, exchange.getIn());
-                            assertNotNull("javax.jms.Message should not be null", msg.getJmsMessage());
-
                             // get header should not mutate it
                             assertEquals("VALUE_1", exchange.getIn().getHeader("HEADER_1"));
                         }
@@ -70,10 +66,6 @@
                     .removeHeader("HEADER_1")
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
-                            // it should have been mutated
-                            JmsMessage msg = assertIsInstanceOf(JmsMessage.class, exchange.getIn());
-                            assertNotNull("javax.jms.Message should not be null", msg.getJmsMessage());
-
                             // get header should not mutate it
                             assertNull("Header should have been removed", exchange.getIn().getHeader("HEADER_1"));
                         }



Mime
View raw message