camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r617758 - /activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapBindingTest.java
Date Sat, 02 Feb 2008 06:27:40 GMT
Author: ningjiang
Date: Fri Feb  1 22:27:40 2008
New Revision: 617758

URL: http://svn.apache.org/viewvc?rev=617758&view=rev
Log:
CAMEL-311 Added the missing test file 

Added:
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapBindingTest.java
  (with props)

Added: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapBindingTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapBindingTest.java?rev=617758&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapBindingTest.java
(added)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapBindingTest.java
Fri Feb  1 22:27:40 2008
@@ -0,0 +1,67 @@
+package org.apache.camel.component.cxf;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.commons.io.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.staxutils.StaxUtils;
+import junit.framework.TestCase;
+
+public class CxfSoapBindingTest extends TestCase {
+    private DefaultCamelContext context = new DefaultCamelContext();
+    private static final String REQUEST_STRING =
+        "<testMethod xmlns=\"http://camel.apache.org/testService\"/>";
+
+    // setup the default context for testing
+    public void testGetCxfInMessage() throws Exception {
+        org.apache.camel.Exchange exchange = new DefaultExchange(context);
+        // String
+        exchange.getIn().setBody("hello world");
+        org.apache.cxf.message.Message message = CxfSoapBinding.getCxfInMessage(exchange,
false);
+        // test message
+        InputStream is = message.getContent(InputStream.class);
+        assertNotNull("The input stream should not be null", is);
+        assertEquals("Don't get the right message", toString(is), "hello world");
+
+        // DOMSource
+        URL request = this.getClass().getResource("RequestBody.xml");
+        File requestFile = new File(request.toURI());
+        FileInputStream inputStream = new FileInputStream(requestFile);
+        XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(inputStream);
+        DOMSource source = new DOMSource(StaxUtils.read(xmlReader));
+        exchange.getIn().setBody(source);
+        message = CxfSoapBinding.getCxfInMessage(exchange, false);
+        is = message.getContent(InputStream.class);
+        assertNotNull("The input stream should not be null", is);
+        assertEquals("Don't get the right message", toString(is), REQUEST_STRING);
+
+        // File
+        exchange.getIn().setBody(requestFile);
+        message = CxfSoapBinding.getCxfInMessage(exchange, false);
+        is = message.getContent(InputStream.class);
+        assertNotNull("The input stream should not be null", is);
+        assertEquals("Don't get the right message", toString(is), REQUEST_STRING);
+
+    }
+
+    private String toString(InputStream is) throws IOException {
+        StringBuilder out = new StringBuilder();
+        CachedOutputStream os = new CachedOutputStream();
+        IOUtils.copy(is, os);
+        is.close();
+        os.writeCacheTo(out);
+        return out.toString();
+
+    }
+
+}

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

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



Mime
View raw message