[jboss-svn-commits] JBL Code SVN: r14191 - labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 13 23:25:57 EDT 2007


Author: ldimaggi at redhat.com
Date: 2007-08-13 23:25:57 -0400 (Mon, 13 Aug 2007)
New Revision: 14191

Modified:
   labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/WiretapTest.java
Log:
Updated to match validation in Helpers.java



Modified: labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/WiretapTest.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/WiretapTest.java	2007-08-13 21:46:35 UTC (rev 14190)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/WiretapTest.java	2007-08-14 03:25:57 UTC (rev 14191)
@@ -1,5 +1,8 @@
 package org.jboss.soa.esb.quickstart.test;
 
+import java.io.File;
+import java.util.Hashtable;
+
 import junit.framework.Test;
 
 import org.jboss.soa.esb.samples.quickstart.wiretap.test.SendCBRJMSMessage;
@@ -10,73 +13,63 @@
 
 /**
  * Sample client for the jboss container.
- *
+ * 
  * @author <a href="mailto:"></a>
  * @version $Id: $
  */
 
-public class WiretapTest
-        extends JBossTestCase
-{
-	private static final String JMS_MESSAGE = "FOOBAResbmessage";
+public class WiretapTest extends JBossTestCase {
+	private static final String JMS_CBR_MESSAGE = "<Order sampleData=\"CBR wiretap test\" testDate=\"20070518\" routeToFollow=\"both\"><Customer userName=\"user1\" firstName=\"Harry\" lastName=\"Fletcher\" state=\"SD\"/></Order>";
+	private static final String JMS_MESSAGE = "Wiretap Message";
+	private static final String FILE_NAME = "Wiretap.log";
+	private static final String LOG_FILE = Helpers.getTempDir(FILE_NAME) + FILE_NAME;
+	private static final int EXPECTED_RECORD_COUNT = 2;
 
-        private static final String JMS_CBR_MESSAGE = "<Order sampleData=\"CBR wiretap test\" testDate=\"20070518\" routeToFollow=\"both\"><Customer userName=\"user1\" firstName=\"Harry\" lastName=\"Fletcher\" state=\"SD\"/></Order>";
-
-
-	public WiretapTest(String name)
-	{
+	public WiretapTest(String name) {
 		super(name);
-	}
+	} /* method */
 
-	public void testMessage() throws Exception
-	{
-		sendMessage();
-		Thread.sleep(10000); // wait for message to post.
-                sendWiretapMessage();
-                Thread.sleep(10000); // wait for message to post.
-                sendStaticRouterJMSMessage();
-                Thread.sleep(10000); // wait for message to post.
-                sendCBRJMSMessage();
-                Thread.sleep(10000); // wait for message to post.
-	}
+	public void testStaticRouterMessage() throws Exception {
+		sendStaticRouterJMSMessage();
 
-	public void sendMessage() throws Exception
-	{
-    	SendJMSMessage sm = new SendJMSMessage();
-    	sm.setupConnection();
-    	sm.sendAMessage(JMS_MESSAGE);
-        sm.stop();
+		/* Verify that the message file is created */
+		boolean fileExists = Helpers.checkForFile(LOG_FILE);
+		if (!fileExists) {
+			fail ("Event file " + LOG_FILE + " not created - test marked as failing");
+		}        
+        
+        /* Verify that the message file is complete */
+        boolean fileComplete = Helpers.checkFileContent(LOG_FILE, EXPECTED_RECORD_COUNT);
+        if (!fileComplete) {
+        		Hashtable temp = Helpers.getMessageString(LOG_FILE);
+        		File target = new File(LOG_FILE);
+        		target.delete();
+                fail ("Event file " + LOG_FILE + " not complete - expected " + EXPECTED_RECORD_COUNT 
+                		+ " records - found " + temp.size() + ", test marked as failing");
         }
+        
+		Hashtable theTable = Helpers.getMessageString(LOG_FILE);
 
-        public void sendCBRJMSMessage() throws Exception
-        {
-        SendCBRJMSMessage sm = new SendCBRJMSMessage();
-        sm.setupConnection();
-        sm.sendAMessage(JMS_CBR_MESSAGE);
-        sm.stop();
-        }
+		String theMessage1 = (String) theTable.get("Message1");
+		String theMessage2 = (String) theTable.get("Message2");
+		
+		assertEquals("The strings1 should match", theMessage1, JMS_MESSAGE);
+		assertEquals("The strings2 should match", theMessage2, JMS_MESSAGE);
+		
+		File target = new File(LOG_FILE);
+		target.delete();       	
+       	
+	} /* method */
 
-        public void sendWiretapMessage() throws Exception
-        {
-        SendWiretapJMSMessage sm = new SendWiretapJMSMessage();
-        sm.setupAConnection();
-        sm.sendMessage(JMS_MESSAGE);
-        sm.stop();
-        }
+	public void sendStaticRouterJMSMessage() throws Exception {
+		SendStaticRouterJMSMessage sm = new SendStaticRouterJMSMessage();
+		sm.setupConnection();
+		sm.sendAMessage(JMS_MESSAGE + Helpers.START_TAG + FILE_NAME + Helpers.END_TAG);
+		sm.stop();
+	} /* method */
 
-        public void sendStaticRouterJMSMessage() throws Exception
-        {
-        SendStaticRouterJMSMessage sm = new SendStaticRouterJMSMessage();
-        sm.setupConnection();
-        sm.sendAMessage(JMS_MESSAGE);
-        sm.stop();
-        }
+	public static Test suite() throws Exception {
+		return getDeploySetup(WiretapTest.class, "Quickstart_wiretap.esb");
+	} /* method */
 
-
-
-
-   public static Test suite() throws Exception
-   {
-      return getDeploySetup(WiretapTest.class, "Quickstart_wiretap.esb");
-   }
-}
+} /* class */




More information about the jboss-svn-commits mailing list