[jboss-svn-commits] JBL Code SVN: r14232 - 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 Aug 14 22:22:50 EDT 2007


Author: ldimaggi at redhat.com
Date: 2007-08-14 22:22:50 -0400 (Tue, 14 Aug 2007)
New Revision: 14232

Modified:
   labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldActionTest.java
Log:
Updated to reference validation routines/event file defined in Helpers.java



Modified: labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldActionTest.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldActionTest.java	2007-08-15 02:12:04 UTC (rev 14231)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldActionTest.java	2007-08-15 02:22:50 UTC (rev 14232)
@@ -1,41 +1,93 @@
+/*
+ * 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.File;
+import java.util.Hashtable;
+
 import junit.framework.Test;
 
 import org.jboss.soa.esb.samples.quickstart.helloworldaction.test.SendJMSMessage;
 import org.jboss.test.JBossTestCase;
 
-
 /**
  * Sample client for the jboss container.
- *
- * @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>
+ * 
+ * @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 $
  */
-public class HelloWorldActionTest
-        extends JBossTestCase
-{
-	private static final String JMS_MESSAGE = "FOOBAResbmessage";
-	public HelloWorldActionTest(String name)
-	{
+
+public class HelloWorldActionTest extends JBossTestCase {
+	private static final String JMS_MESSAGE = "HelloWorldActionTest message";
+	private static final String FILE_NAME = "HelloWorldActionTest.log";
+	private static final String LOG_FILE = Helpers.getTempDir(FILE_NAME) + FILE_NAME;
+	private static final int EXPECTED_RECORD_COUNT = 1;
+
+	public HelloWorldActionTest(String name) {
 		super(name);
 	}
 
-	public void testMessage() throws Exception
-	{
-		//sendMessage();
-		Thread.sleep(10000); // wait for message to post.
+	public void testMessage() throws Exception {
+		sendMessage();
+
+		/* 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);
+		String theMessage = (String) theTable.get("Message1");
+		assertEquals("The strings should match", theMessage, JMS_MESSAGE);
+		// assertEquals("The strings should match", "non-matchinf message",
+		// JMS_MESSAGE);
+		File target = new File(Helpers.getTempDir(LOG_FILE));
+		//target.delete();
 	}
 
-	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 + FILE_NAME
+				+ Helpers.END_TAG);
+		sm.stop();
 	}
 
-   public static Test suite() throws Exception
-   {
-      return getDeploySetup(HelloWorldActionTest.class, "Quickstart_helloworld_action.esb");
-   }
+	public static Test suite() throws Exception {
+		return getDeploySetup(HelloWorldActionTest.class,
+				"Quickstart_helloworld_action.esb");
+	}
 }




More information about the jboss-svn-commits mailing list