svn commit: r595755 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/converter/jaxp/XmlConverter.java test/java/org/apache/camel/converter/JaxpTest.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r595755 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/converter/jaxp/XmlConverter.java test/java/org/apache/camel/converter/JaxpTest.java

jstrachan-2
Author: jstrachan
Date: Fri Nov 16 09:38:39 2007
New Revision: 595755

URL: http://svn.apache.org/viewvc?rev=595755&view=rev
Log:
applied patch for https://issues.apache.org/activemq/browse/CAMEL-199 with thanks!

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java?rev=595755&r1=595754&r2=595755&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java Fri Nov 16 09:38:39 2007
@@ -134,7 +134,15 @@
     public DOMSource toSource(Document document) {
         return new DOMSource(document);
     }
-
+    
+    /**
+     * Converts the given Node to a Source
+     */
+    @Converter
+    public Source toSource(Node node) {
+     return new DOMSource(node);
+    }
+    
     /**
      * Converts the given input Source into text
      */
@@ -616,4 +624,4 @@
         return answer;
     }
 
-}
\ No newline at end of file
+}

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java?rev=595755&r1=595754&r2=595755&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java Fri Nov 16 09:38:39 2007
@@ -29,18 +29,18 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 /**
  * @version $Revision$
  */
 public class JaxpTest extends TestCase {
     private static final transient Log LOG = LogFactory.getLog(JaxpTest.class);
-
     protected TypeConverter converter = new DefaultTypeConverter(new ReflectionInjector());
 
     public void testConvertToDocument() throws Exception {
         Document document = converter
-            .convertTo(Document.class, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello>world!</hello>");
+                .convertTo(Document.class, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello>world!</hello>");
         assertNotNull(document);
 
         LOG.debug("Found document: " + document);
@@ -55,7 +55,7 @@
 
     public void testConvertToSource() throws Exception {
         Source source = converter
-            .convertTo(Source.class, "<hello>world!</hello>");
+                .convertTo(Source.class, "<hello>world!</hello>");
         assertNotNull(source);
 
         LOG.debug("Found document: " + source);
@@ -67,5 +67,14 @@
         assertNotNull("Could not convert to a DOMSource!", domSource);
 
         LOG.debug("Found document: " + domSource);
+    }
+
+    public void testNodeToSource() throws Exception {
+        Document document = converter.convertTo(Document.class, "<?xml version=\"1.0\"?><hello>world!</hello>");
+        Element element = document.getDocumentElement();
+        Source source = converter.convertTo(Source.class, element);
+        assertNotNull("Could not convert from Node to Source!", source);
+
+        LOG.debug("Found source: " + source);
     }
 }