[jboss-svn-commits] JBL Code SVN: r13913 - 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
Tue Jul 31 12:11:34 EDT 2007


Author: ldimaggi at redhat.com
Date: 2007-07-31 12:11:34 -0400 (Tue, 31 Jul 2007)
New Revision: 13913

Added:
   labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/Helpers.java
Modified:
   labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldTest.java
Log:
Helpers.java - helper class for test case asserts - reads the message file created via 

    <action name="action2"
       class="org.jboss.soa.esb.actions.SystemPrintln" />

into a Hashtable

HelloWorld.java - modified to use the helper class.





Modified: labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldTest.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldTest.java	2007-07-31 15:27:19 UTC (rev 13912)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldTest.java	2007-07-31 16:11:34 UTC (rev 13913)
@@ -1,10 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
 package org.jboss.soa.esb.quickstart.test;
 
-import java.io.OutputStream;
-import java.io.PrintStream;
+import java.io.*;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Date;
+import java.util.Hashtable;
 
 import javax.management.ObjectName;
 import junit.framework.Test;
@@ -15,38 +36,41 @@
 import org.jboss.soa.esb.samples.quickstart.helloworld.test.*;
 import org.jboss.soa.esb.samples.quickstart.helloworld.*;
 
+import org.jboss.soa.esb.quickstart.test.Helpers;
+
 /**
  * Sample client for the jboss container.
- *
+ * 
  * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
- * @version $Id: BlobUnitTestCase.java 58110 2006-11-04 08:34:21Z scott.stark at jboss.org $
+ * @version $Id: BlobUnitTestCase.java 58110 2006-11-04 08:34:21Z
+ *          scott.stark at jboss.org $
  */
 
-public class HelloWorldTest
-        extends JBossTestCase
-{
-	private static final String JMS_MESSAGE = "FOOBAResbmessage";
-	public HelloWorldTest(String name)
-	{
+public class HelloWorldTest extends JBossTestCase {
+	private static final String JMS_MESSAGE = "HelloWorldTest message";
+	private static final String LOG_FILE = "/opt/HelloWorldTest.log";
+
+	public HelloWorldTest(String name) {
 		super(name);
 	}
 
-	public void testMessage() throws Exception
-	{
+	public void testMessage() throws Exception {
 		sendMessage();
 		Thread.sleep(10000); // wait for message to post.
+		Hashtable theTable = Helpers.getMessageString(LOG_FILE);
+		String theMessage = (String) theTable.get("Message1");
+		assertEquals("The strings should match", theMessage, JMS_MESSAGE);
+		//assertEquals("The strings should match", "non-matchinf message", JMS_MESSAGE);
 	}
 
-	public void sendMessage() throws Exception
-	{
-    	SendJMSMessage sm = new SendJMSMessage();
-    	sm.setupConnection();
-    	sm.sendAMessage(JMS_MESSAGE);
-    	sm.stop();
+	public void sendMessage() throws Exception {
+		SendJMSMessage sm = new SendJMSMessage();
+		sm.setupConnection();
+		sm.sendAMessage(JMS_MESSAGE + Helpers.START_TAG + LOG_FILE + Helpers.END_TAG);
+		sm.stop();
 	}
 
-   public static Test suite() throws Exception
-   {
-      return getDeploySetup(HelloWorldTest.class, "Quickstart_helloworld.esb");
-   }
+	public static Test suite() throws Exception {
+		return getDeploySetup(HelloWorldTest.class, "Quickstart_helloworld.esb");
+	}
 }

Added: labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/Helpers.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/Helpers.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/Helpers.java	2007-07-31 16:11:34 UTC (rev 13913)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.quickstart.test;
+
+import java.io.*;
+import java.util.Hashtable;
+import junit.framework.Assert;
+
+/**
+ * Helper class for quickstart tests
+ * 
+ */
+
+public class Helpers {
+	public static final String START_TAG = "[jbesb-filename]";
+	public static final String END_TAG = "[/jbesb-filename]\n";
+
+	/* Read the message files into a hash */
+	public static Hashtable getMessageString(String fileName) {
+		Hashtable returnTable = new Hashtable();
+		int theCounter = 1;
+		try {
+			BufferedReader in = new BufferedReader(new FileReader(fileName));
+			String str;
+			while ((str = in.readLine()) != null) {
+				int startTag = str.indexOf(START_TAG);
+				String returnString = str.substring(0, startTag);
+				returnTable.put("Message" + theCounter++, returnString);
+			}
+			in.close();
+		} catch (IOException e) {
+			Assert.fail("Cannot read file: " + fileName);
+		}
+		return returnTable;
+	} /* method */
+
+} /* class */




More information about the jboss-svn-commits mailing list