Author: ozizka(a)redhat.com
Date: 2009-01-22 09:07:41 -0500 (Thu, 22 Jan 2009)
New Revision: 122
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
Added: checkClientAndServerMessagesRegExp() which checks the client and server messages
against a regular expressions.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-21
21:56:52 UTC (rev 121)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-22
14:07:41 UTC (rev 122)
@@ -41,10 +41,11 @@
import javax.management.*;
import org.jboss.mx.util.MBeanServerLocator;
//import org.jboss.jmx.adaptor.rmi.RMIAdaptor; // Needs dependency: jmx-adaptor-plugin
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
-
/**
* This is the base test class for Embedded Jopr test cases.
* It supplies access to a JSFClientSession object and a JSFServerSession
@@ -275,13 +276,14 @@
}
}
+
/**
- * Check that the given messages occur on the client side
- * and server side.
+ * Check that the given messages occur on the client side and server side.
*/
public void checkClientAndServerMessages(String expectedClientMsg,
String expectedServerMsg,
- boolean isErrorMsg) {
+ boolean isErrorMsg)
+ {
assertTrue("Expected message not found on page.",
client.getPageAsText().contains(expectedClientMsg));
@@ -301,6 +303,30 @@
/**
+ * Check that the given messages occur on the client side and server side.
+ * Given strings are treated as regular expressions to match.
+ */
+ public void checkClientAndServerMessagesRegExp(String expectedClientMsgRE,
+ String expectedServerMsgRE,
+ boolean isErrorMsg)
+ {
+ String pageText = client.getPageAsText();
+ assertTrue( Pattern.matches(expectedClientMsgRE, pageText) );
+
+ assertTrue(server.getFacesMessages().hasNext());
+ FacesMessage message = server.getFacesMessages().next();
+
+ if(isErrorMsg) {
+ assertTrue(FacesMessage.SEVERITY_ERROR.equals(message.getSeverity()));
+ } else {
+ assertTrue(FacesMessage.SEVERITY_INFO.equals(message.getSeverity()));
+ }
+
+ assertTrue( Pattern.matches( expectedServerMsgRE, message.getDetail() ) );
+ }
+
+
+ /**
* Refresh the content under the given nav tree node.
*/
public void refreshTreeNode(String nodeName) throws IOException {
@@ -313,6 +339,7 @@
nodeArrow.click();
}
+
/**
* This just checks that the JSFServerSession object was created.
*/
@@ -320,6 +347,7 @@
assertTrue(server != null);
}
+
/**
* This just checks that the JSFClientSession object was created.
*/
Show replies by date