camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r880644 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/converter/ test/java/org/apache/camel/component/cxf/
Date Mon, 16 Nov 2009 07:48:30 GMT
Author: ningjiang
Date: Mon Nov 16 07:48:22 2009
New Revision: 880644

URL: http://svn.apache.org/viewvc?rev=880644&view=rev
Log:
CAMEL-2144 fixed the issue of Null Message will disable the message handler of camel consumer

Added:
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java
  (with props)
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceProvider.java
  (with props)
Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java?rev=880644&r1=880643&r2=880644&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
Mon Nov 16 07:48:22 2009
@@ -158,6 +158,7 @@
      * @param registry type converter registry
      * @return the converted value of the desired type or null if no suitable converter found
      */
+    @SuppressWarnings("unchecked")
     @FallbackConverter
     public static <T> T convertTo(Class<T> type, Exchange exchange, Object value,

             TypeConverterRegistry registry) {
@@ -177,6 +178,8 @@
                     }
                 }
             }
+            // return void to indicate its not possible to convert at this time
+            return (T) Void.TYPE;
         }
         
         return null;

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java?rev=880644&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java
Mon Nov 16 07:48:22 2009
@@ -0,0 +1,88 @@
+/**
+ * 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.cxf;
+
+import java.util.List;
+
+import org.w3c.dom.Node;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.junit.Test;
+
+public class CxfConsumerProviderTest extends CamelTestSupport {
+    
+    protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:28080/test";
+    protected static final String SIMPLE_ENDPOINT_URI = "cxf://" + SIMPLE_ENDPOINT_ADDRESS
+        + "?serviceClass=org.apache.camel.component.cxf.ServiceProvider";
+    
+    protected static final String REQUEST_MESSAGE = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:ser=\"test/service\">"
+        + "<soapenv:Header/><soapenv:Body><ser:ping/></soapenv:Body></soapenv:Envelope>";
+    
+    protected static final String RESPONSE_MESSAGE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+        + "<soap:Body><pong xmlns=\"test/service\" /></soap:Body></soap:Envelope>";
+    
+    protected static final String RESPONSE = "<pong xmlns=\"test/service\"/>";
+  
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                errorHandler(noErrorHandler());
+                from(SIMPLE_ENDPOINT_URI).process(new Processor() {
+                    public void process(final Exchange exchange) {
+                        Message in = exchange.getIn();
+                        // Get the parameter list
+                        Node node = in.getBody(Node.class);
+                        assertNotNull(node);
+                        XmlConverter xmlConverter = new XmlConverter();
+                        // Put the result back
+                        exchange.getOut().setBody(xmlConverter.toSource(RESPONSE));
+                    }
+                });
+            }
+        };
+    }
+    
+
+    @Test
+    public void testInvokingServiceFromHttpCompnent() throws Exception {
+        // call the service with right post message
+        
+        String response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS, REQUEST_MESSAGE,
String.class);
+        assertEquals("Get a wrong response ", RESPONSE_MESSAGE, response);
+        try {
+            response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS, null, String.class);
+            fail("Excpetion to get exception here");
+        } catch (Exception ex) {
+            // do nothing here
+        }
+       
+        response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS, REQUEST_MESSAGE, String.class);
+        assertEquals("Get a wrong response ", RESPONSE_MESSAGE, response);
+    }
+
+
+}

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

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

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceProvider.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceProvider.java?rev=880644&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceProvider.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceProvider.java
Mon Nov 16 07:48:22 2009
@@ -0,0 +1,33 @@
+/**
+ * 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.cxf;
+
+import javax.xml.transform.Source;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+
+@WebServiceProvider
+@ServiceMode(Mode.PAYLOAD)
+public class ServiceProvider implements Provider<Source> {
+
+    public Source invoke(Source m) {
+        throw new UnsupportedOperationException("Place holder method");
+    }
+
+}

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

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



Mime
View raw message