servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1386534 - in /servicemix/components/trunk: engines/servicemix-eip/src/test/java/org/apache/servicemix/eip/ shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/util/ shared-libraries/servicemix-common/src/test/java...
Date Mon, 17 Sep 2012 09:58:41 GMT
Author: ffang
Date: Mon Sep 17 09:58:41 2012
New Revision: 1386534

URL: http://svn.apache.org/viewvc?rev=1386534&view=rev
Log:
[SMXCOMP-947]use DOMSource instead of StringSource in servicemix-common/MessageUtil

Modified:
    servicemix/components/trunk/engines/servicemix-eip/src/test/java/org/apache/servicemix/eip/AbstractEIPTest.java
    servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/util/MessageUtil.java
    servicemix/components/trunk/shared-libraries/servicemix-common/src/test/java/org/apache/servicemix/common/util/MessageUtilTest.java

Modified: servicemix/components/trunk/engines/servicemix-eip/src/test/java/org/apache/servicemix/eip/AbstractEIPTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-eip/src/test/java/org/apache/servicemix/eip/AbstractEIPTest.java?rev=1386534&r1=1386533&r2=1386534&view=diff
==============================================================================
--- servicemix/components/trunk/engines/servicemix-eip/src/test/java/org/apache/servicemix/eip/AbstractEIPTest.java
(original)
+++ servicemix/components/trunk/engines/servicemix-eip/src/test/java/org/apache/servicemix/eip/AbstractEIPTest.java
Mon Sep 17 09:58:41 2012
@@ -95,8 +95,7 @@ public abstract class AbstractEIPTest ex
     protected void configurePattern(EIPEndpoint endpoint) {
         endpoint.setStore(new MemoryStore(new IdGenerator()) {
             public void store(String id, Object exchange) throws IOException {
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                new ObjectOutputStream(baos).writeObject(exchange);
+                //do your customer store here
                 super.store(id, exchange);
             }
         });

Modified: servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/util/MessageUtil.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/util/MessageUtil.java?rev=1386534&r1=1386533&r2=1386534&view=diff
==============================================================================
--- servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/util/MessageUtil.java
(original)
+++ servicemix/components/trunk/shared-libraries/servicemix-common/src/main/java/org/apache/servicemix/common/util/MessageUtil.java
Mon Sep 17 09:58:41 2012
@@ -37,13 +37,13 @@ import javax.security.auth.Subject;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamSource;
 
 import org.xml.sax.SAXException;
 
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.apache.servicemix.jbi.jaxp.StringSource;
 
 public final class MessageUtil {
     
@@ -142,18 +142,18 @@ public final class MessageUtil {
         if (message.getContent() instanceof StreamSource
                 || message.getContent() instanceof SAXSource) {
             try {
-                String content = sourceTransformer.contentToString(message);
-                if (content != null) {
-                    message.setContent(new StringSource(content));
+                DOMSource domSource = (DOMSource)sourceTransformer.toDOMSource(message);
+                if (domSource != null) {
+                    message.setContent(domSource);
                 }
             } catch (TransformerException e) {
-                throw new MessagingException("Unable to convert message content into StringSource",
e);
+                throw new MessagingException("Unable to convert message content into DOMSource",
e);
             } catch (ParserConfigurationException e) {
-                throw new MessagingException("Unable to convert message content into StringSource",
e);
+                throw new MessagingException("Unable to convert message content into DOMSource",
e);
             } catch (IOException e) {
-                throw new MessagingException("Unable to convert message content into StringSource",
e);
+                throw new MessagingException("Unable to convert message content into DOMSource",
e);
             } catch (SAXException e) {
-                throw new MessagingException("Unable to convert message content into StringSource",
e);
+                throw new MessagingException("Unable to convert message content into DOMSource",
e);
             }
         }
     }
@@ -172,10 +172,11 @@ public final class MessageUtil {
 
         public NormalizedMessageImpl(NormalizedMessage message) throws MessagingException
{
             try {
-                String str = sourceTransformer.contentToString(message);
-                if (str != null) {
-                    this.content = new StringSource(str);
+                DOMSource domSource = (DOMSource)sourceTransformer.toDOMSource(message);
+                if (domSource != null) {
+                    this.content = domSource;
                 }
+
                 for (Iterator it = message.getPropertyNames().iterator(); it.hasNext();)
{
                     String name = (String) it.next();
                     this.properties.put(name, message.getProperty(name));

Modified: servicemix/components/trunk/shared-libraries/servicemix-common/src/test/java/org/apache/servicemix/common/util/MessageUtilTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/shared-libraries/servicemix-common/src/test/java/org/apache/servicemix/common/util/MessageUtilTest.java?rev=1386534&r1=1386533&r2=1386534&view=diff
==============================================================================
--- servicemix/components/trunk/shared-libraries/servicemix-common/src/test/java/org/apache/servicemix/common/util/MessageUtilTest.java
(original)
+++ servicemix/components/trunk/shared-libraries/servicemix-common/src/test/java/org/apache/servicemix/common/util/MessageUtilTest.java
Mon Sep 17 09:58:41 2012
@@ -76,14 +76,14 @@ public class MessageUtilTest extends Tes
         assertTrue(sub.getPublicCredentials().contains(credential));
         
         MessageUtil.NormalizedMessageImpl nmsg = new MessageUtil.NormalizedMessageImpl(src);
       
-        assertEquals("StringSource[<hello>world</hello>]", nmsg.getContent().toString());
+        assertTrue(new SourceTransformer().toString(nmsg.getContent()).contains("<hello>world</hello>"));
         
         NormalizedMessage newMsg = MessageUtil.copy(src);
-        assertEquals("StringSource[<hello>world</hello>]", newMsg.getContent().toString());
+        assertTrue(new SourceTransformer().toString(newMsg.getContent()).contains("<hello>world</hello>"));
         
         src.setContent(null);
         MessageUtil.NormalizedMessageImpl nmsg2 = new MessageUtil.NormalizedMessageImpl(src);
-        assertNull(nmsg2.getContent());
+        assertNull(((DOMSource)nmsg2.getContent()).getNode());
         
         URL url = getClass().getClassLoader().getResource(getClass().getName().replace('.','/')+".class");
 
@@ -113,7 +113,7 @@ public class MessageUtilTest extends Tes
         meSrc.setMessage(srcMsg, "in");
         MessageUtil.transferTo(meSrc, meDest, "in");
         NormalizedMessage nm = meDest.getMessage("in");        
-        assertEquals("StringSource[<hello>world</hello>]", nm.getContent().toString());
+        assertTrue(new SourceTransformer().toString(nm.getContent()).contains("<hello>world</hello>"));
         
         // Tests transferInToIn
         meSrc.setMessage(srcMsg, "in");
@@ -147,11 +147,11 @@ public class MessageUtilTest extends Tes
         
         // Tests copyIn
         NormalizedMessage copyIn = MessageUtil.copyIn(meSrc);
-        assertEquals("StringSource[<hello>world</hello>]", copyIn.getContent().toString());
+        assertTrue(new SourceTransformer().toString(copyIn.getContent()).contains("<hello>world</hello>"));
         
         // Tests copyOut
         NormalizedMessage copyOut = MessageUtil.copyOut(meSrc);
-        assertEquals("StringSource[<hello>world</hello>]", copyOut.getContent().toString());
+        assertTrue(new SourceTransformer().toString(copyOut.getContent()).contains("<hello>world</hello>"));
     }
     
     public void testEnableContentRereadability() throws Exception {
@@ -159,7 +159,7 @@ public class MessageUtilTest extends Tes
         srcMsg.setContent(new StringSource("<hello>world</hello>"));
         srcMsg.setProperty("name", "edell");        
         MessageUtil.enableContentRereadability(srcMsg);
-        assertEquals("StringSource[<hello>world</hello>]", srcMsg.getContent().toString());
               
+        assertTrue(new SourceTransformer().toString(srcMsg.getContent()).contains("<hello>world</hello>"));
               
         
         try {
             srcMsg.setContent(new StreamSource("@@@@@@@@@@@@@"));            
@@ -186,17 +186,17 @@ public class MessageUtilTest extends Tes
     	    	    	    	
     	// Tests copyFault    	
         Fault copyFault = MessageUtil.copyFault(exchangeSrc);
-        assertEquals("StringSource[<fault>failure</fault>]", copyFault.getContent().toString());
+        assertTrue(new SourceTransformer().toString(copyFault.getContent()).contains("<fault>failure</fault>"));
         
         NormalizedMessage nm = MessageUtil.copy(fault);
-        assertEquals("StringSource[<fault>failure</fault>]", nm.getContent().toString());
+        assertTrue(new SourceTransformer().toString(nm.getContent()).contains("<fault>failure</fault>"));
         
     	// Tests transferFaultToFault
         MessageUtil.transferFaultToFault(exchangeSrc, exchangeDest);
-        assertEquals("StringSource[<fault>failure</fault>]", exchangeDest.getFault().getContent().toString());
+        assertTrue(new SourceTransformer().toString(exchangeDest.getFault().getContent()).contains("<fault>failure</fault>"));
         
         MessageUtil.transferTo(exchangeSrc, exchangeDest, "fault");
-        assertEquals("StringSource[<fault>failure</fault>]", exchangeDest.getFault().getContent().toString());
+        assertTrue(new SourceTransformer().toString(exchangeDest.getFault().getContent()).contains("<fault>failure</fault>"));
 
     }
     



Mime
View raw message