camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1139163 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java
Date Fri, 24 Jun 2011 06:14:30 GMT
Author: ningjiang
Date: Fri Jun 24 06:14:30 2011
New Revision: 1139163

URL: http://svn.apache.org/viewvc?rev=1139163&view=rev
Log:
CAMEL-4143 Fixed the issue of CxfPayload to Node conversion

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java?rev=1139163&r1=1139162&r2=1139163&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
Fri Jun 24 06:14:30 2011
@@ -69,6 +69,15 @@ public final class CxfPayloadConverter {
     public static <T> NodeList cxfPayloadToNodeList(CxfPayload<T> payload, Exchange
exchange) {
         return new NodeListWrapper(payload.getBody());
     }
+    
+    @Converter
+    public static <T> Node cxfPayLoadToNode(CxfPayload<T> payload, Exchange exchange)
{
+        List<Element> payloadBodyElements = payload.getBody();
+        if (payloadBodyElements.size() > 0) {
+            return payloadBodyElements.get(0);
+        }
+        return null;
+    }
 
     @SuppressWarnings("unchecked")
     @FallbackConverter

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java?rev=1139163&r1=1139162&r2=1139163&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java
Fri Jun 24 06:14:30 2011
@@ -48,6 +48,7 @@ public class CxfPayloadConverterTest ext
         super.setUp();
         File file = new File("src/test/resources/org/apache/camel/component/cxf/converter/test.xml");
         DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+        documentBuilderFactory.setNamespaceAware(true);
         DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
         document = documentBuilder.parse(file);
         document.getDocumentElement().normalize();
@@ -112,6 +113,15 @@ public class CxfPayloadConverterTest ext
         exchange.getIn().setBody(payload);
         node = exchange.getIn().getBody(Node.class);
         assertNotNull(node);
+        
+        // To make sure we always get the element here
+        Element root = (Element) node;
+        assertEquals("root element name", "root", root.getNodeName());
+        assertEquals("root element namespace", "http://www.test.org/foo", root.getNamespaceURI());
+        Element bar = (Element) root.getElementsByTagName("bar").item(0);
+        assertEquals("child element name", "bar", bar.getNodeName());
+        assertEquals("child element namespace", "http://www.test.org/foo",
+            bar.getNamespaceURI());
     }
 
 }



Mime
View raw message