You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2008/06/13 07:44:27 UTC

svn commit: r667361 - in /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src: main/java/org/apache/servicemix/camel/JbiBinding.java test/java/org/apache/servicemix/camel/JbiEndpointWithMepSpecifiedTest.java

Author: gertv
Date: Thu Jun 12 22:44:27 2008
New Revision: 667361

URL: http://svn.apache.org/viewvc?rev=667361&view=rev
Log:
SM-1397: Camel JBI endpoint should honor explicit ?mep being set

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiEndpointWithMepSpecifiedTest.java
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java?rev=667361&r1=667360&r2=667361&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java Thu Jun 12 22:44:27 2008
@@ -91,12 +91,15 @@
                                                        String defaultMep)
         throws MessagingException, URISyntaxException {
 
-        ExchangePattern mep = camelExchange.getPattern();
+        // option 1 -- use the MEP that was configured on the endpoint URI
+        ExchangePattern mep = ExchangePattern.fromWsdlUri(defaultMep);
         if (mep == null) {
-            mep = ExchangePattern.fromWsdlUri(defaultMep);
+            // option 2 -- use the MEP configured on the ToJbiProcessor
+            mep = ExchangePattern.fromWsdlUri(getMessageExchangePattern());
         }
         if (mep == null) {
-            mep = ExchangePattern.fromWsdlUri(getMessageExchangePattern());
+            // option 3 -- use the MEP from the Camel Exchange
+            mep = camelExchange.getPattern();
         }
         MessageExchange answer = null;
         if (mep != null) {

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiEndpointWithMepSpecifiedTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiEndpointWithMepSpecifiedTest.java?rev=667361&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiEndpointWithMepSpecifiedTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiEndpointWithMepSpecifiedTest.java Thu Jun 12 22:44:27 2008
@@ -0,0 +1,91 @@
+/*
+ * 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.servicemix.camel;
+
+import java.util.List;
+
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.xml.namespace.QName;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.tck.ReceiverComponent;
+
+/**
+ * Tests to check correct handling of the ?mep=xxx setting on a Camel JBI endpoint
+ */
+public class JbiEndpointWithMepSpecifiedTest extends JbiTestSupport {
+    
+    private MyReceiverComponent component;
+    
+    @Override
+    protected void setUp() throws Exception {
+        component = new MyReceiverComponent();
+        super.setUp();
+    }
+    
+    public void testCamelInOutSendJbiInOnly() throws Exception {
+        client.send("direct:a", new DefaultExchange(camelContext) {
+            
+            @Override
+            public ExchangePattern getPattern() {
+                //let's explicitly send an in-out Exchange
+                return ExchangePattern.InOut;
+            }
+            
+        });
+        assertEquals(1, component.count);
+    }
+
+    @Override
+    protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
+        ActivationSpec spec = new ActivationSpec();
+        spec.setComponent(component);
+        spec.setComponentName("receiver");
+        spec.setService(new QName("urn:test", "service"));
+        activationSpecList.add(spec);
+    }
+
+    @Override
+    protected RouteBuilder createRoutes() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:a").to("jbi:service:urn:test:service?mep=in-only");
+            }
+        };
+    }
+    
+    private class MyReceiverComponent extends ReceiverComponent {
+        
+        private int count;
+        
+        @Override
+        public void onMessageExchange(MessageExchange exchange) throws MessagingException {
+            if (exchange instanceof InOnly) {
+                count++;
+                done(exchange);
+            } else {
+                fail(exchange, new Exception("Unexpected MEP: " + exchange.getPattern()));
+            }            
+        }
+    }
+}