[jboss-svn-commits] JBL Code SVN: r14189 - 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 16:30:26 EDT 2007
Author: ldimaggi at redhat.com
Date: 2007-08-13 16:30:26 -0400 (Mon, 13 Aug 2007)
New Revision: 14189
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/DynamicRouterTest.java
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/Helpers.java
labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/RecipientlistTest.java
Log:
Updated to handle situations where more than one instance of a message is written to the message file. The test has to verify that the event file is pr
esent, and that it contains the correct number of messages.
Modified: labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/DynamicRouterTest.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/DynamicRouterTest.java 2007-08-13 20:06:11 UTC (rev 14188)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/DynamicRouterTest.java 2007-08-13 20:30:26 UTC (rev 14189)
@@ -21,6 +21,7 @@
private static final String JMS_MESSAGE = "DynamicRouterTest message";
private static final String FILE_NAME = "DynamicRouterTest.log";
private static final String LOG_FILE = Helpers.getTempDir(FILE_NAME) + FILE_NAME;
+ private static final int EXPECTED_RECORD_COUNT = 3;
public DynamicRouterTest(String name)
{
@@ -30,11 +31,22 @@
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 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 theMessage1 = (String) theTable.get("Message1");
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-08-13 20:06:11 UTC (rev 14188)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldTest.java 2007-08-13 20:30:26 UTC (rev 14189)
@@ -41,7 +41,8 @@
private static final String JMS_MESSAGE = "HelloWorldTest message";
private static final String FILE_NAME = "HelloWorldTest.log";
private static final String LOG_FILE = Helpers.getTempDir(FILE_NAME) + FILE_NAME;
-
+ private static final int EXPECTED_RECORD_COUNT = 1;
+
public HelloWorldTest(String name) {
super(name);
}
@@ -55,6 +56,16 @@
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);
Modified: 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 2007-08-13 20:06:11 UTC (rev 14188)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/Helpers.java 2007-08-13 20:30:26 UTC (rev 14189)
@@ -77,6 +77,29 @@
return wasFileFound;
} /* method */
+ /* Determine if the event file has the correct # of entries written to it - this is probably
+ * only needed for tests that write the same message to multiple queues - for example,
+ * the RecipientlistTest */
+ public static boolean checkFileContent(String fileName, int recordCount) throws Exception {
+ boolean correctFileSize = false;
+
+ /* Determine the number of records in the file, if it's not correct
+ * wait and try again */
+ for (int i = 0; i < FILE_COUNTER; i++) {
+ Hashtable theTable = Helpers.getMessageString(fileName);
+ int theKeys = theTable.size();
+ if (theKeys == recordCount){
+ correctFileSize = true;
+ break;
+ }
+ else {
+ Thread.sleep(FILE_TIMER);
+ }
+ }
+ return correctFileSize;
+ } /* method */
+
+
public static String getTempDir(String filename)
{
String tmpDir="";
Modified: labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/RecipientlistTest.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/RecipientlistTest.java 2007-08-13 20:06:11 UTC (rev 14188)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/RecipientlistTest.java 2007-08-13 20:30:26 UTC (rev 14189)
@@ -19,13 +19,17 @@
public class RecipientlistTest extends JBossTestCase {
private static final String JMS_MESSAGE = "RecipientlistTest message";
private static final String FILE_NAME = "RecipientlistTest.log";
- private static final String LOG_FILE = Helpers.getTempDir(FILE_NAME) + FILE_NAME;
- 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 LOG_FILE = Helpers.getTempDir(FILE_NAME) + FILE_NAME;
+ private static final String JMS_CBR_MESSAGE = "<Order sampleData=\"CBR test\" testDate=\"20070518\" routeToFollow=\"both\"><Customer userName=\"user1\" firstName=\"Harry\" lastName=\"Fletcher\" state=\"SD\"/></Order>";
+ private static final int EXPECTED_RECORD_COUNT = 3;
public RecipientlistTest(String name) {
super(name);
}
+ /* This test is intentionally skipped as of 20070813 - ldimaggi -
+ * there's some problem with the CBR - the test seems unable to
+ * send the messages to the destinations targetted by the CBR */
public void skip_testCBRMessage() throws Exception {
sendCBRJMSMessage();
Thread.sleep(10000); // wait for message to post.
@@ -33,8 +37,23 @@
public void testStaticMessage() throws Exception {
sendStaticRouterJMSMessage();
- Thread.sleep(10000); // wait for message to post.
+ /* 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 theMessage1 = (String) theTable.get("Message1");
More information about the jboss-svn-commits
mailing list