servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r733760 - /servicemix/smx3/branches/servicemix-3.2/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/file/FileAuditorTest.java
Date Mon, 12 Jan 2009 14:04:06 GMT
Author: gertv
Date: Mon Jan 12 06:04:04 2009
New Revision: 733760

URL: http://svn.apache.org/viewvc?rev=733760&view=rev
Log:
Adding a DOMSource unit test for FileAuditor

Modified:
    servicemix/smx3/branches/servicemix-3.2/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/file/FileAuditorTest.java

Modified: servicemix/smx3/branches/servicemix-3.2/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/file/FileAuditorTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/file/FileAuditorTest.java?rev=733760&r1=733759&r2=733760&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/file/FileAuditorTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/file/FileAuditorTest.java
Mon Jan 12 06:04:04 2009
@@ -20,10 +20,13 @@
 import java.util.Locale;
 
 import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessagingException;
+import javax.xml.transform.Source;
 
 import junit.framework.TestCase;
 
 import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
 import org.apache.servicemix.jbi.util.FileUtil;
 import org.apache.servicemix.tck.ReceiverComponent;
@@ -32,6 +35,7 @@
 public class FileAuditorTest extends TestCase {
 
     private static final File DIRECTORY = new File("target/tests/FileAuditor");
+    private final SourceTransformer transformer = new SourceTransformer();
 
     private JBIContainer jbi;
 
@@ -62,15 +66,22 @@
         auditor.setDirectory(DIRECTORY);
         auditor.afterPropertiesSet();
 
+        sendMessageExchange(sender, new StringSource("<hello>world</hello>"));
+
+        //check if the message has been audited
+        assertEquals(1, auditor.getExchangeCount());
+        
+        sendMessageExchange(sender, transformer.toDOMSource(new StringSource("<hello>world</hello>")));
+        
+        //check if the message has been audited
+        assertEquals(2, auditor.getExchangeCount());
+    }
+
+    private void sendMessageExchange(SenderComponent sender, Source content) throws MessagingException
{
         InOnly inonly = sender.createInOnlyExchange(ReceiverComponent.SERVICE, null, null);
         inonly.setInMessage(inonly.createMessage());
-        inonly.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        inonly.getInMessage().setContent(content);
         inonly.getInMessage().setProperty("from", Locale.getDefault().getCountry());
         sender.send(inonly);
-
-        //check if a message has been audited
-        int nbMessages = auditor.getExchangeCount();
-        assertEquals(1, nbMessages);
     }
-
 }



Mime
View raw message