[embjopr-commits] EMBJOPR SVN: r162 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: exceptions and 1 other directory.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Thu Feb 19 22:23:07 EST 2009


Author: ozizka at redhat.com
Date: 2009-02-19 22:23:06 -0500 (Thu, 19 Feb 2009)
New Revision: 162

Added:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/PageHasChangedException.java
Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
Log:
 * PageAware

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java	2009-02-20 03:08:01 UTC (rev 161)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java	2009-02-20 03:23:06 UTC (rev 162)
@@ -22,6 +22,7 @@
 package org.jboss.jopr.jsfunit;
 
 import com.gargoylesoftware.htmlunit.ElementNotFoundException;
+import com.gargoylesoftware.htmlunit.Page;
 import java.util.List;
 import java.util.Set;
 import javax.management.*;
@@ -393,6 +394,8 @@
 	 * Base class for parts that will check their validity before performing actions.
 	 * Not necessary if we pay attention to validity, but why not check it - 
 	 * performance is not a question for us.
+	 *
+	 * TODO: Instead, use the Page returned from click() etc.
 	 */
 	protected class PageContextAwareElement {
 		private URL validForURL;
@@ -419,14 +422,27 @@
 			    !validForURL_.equals(this.validForURL) )
 			{
 				throw new ActionOutOfSyncException(
-								"This tab content box was created from another page and is not valid now.");
+								"This element wrapper was created from another page and is not valid now.");
 			}
 		}
 
 	}
-	
 
+	/** Better try... */
+	protected class PageAware {
+		private Page  validForPage;
+		public PageAware(){
+			this.validForPage = client.getContentPage();
+		}
+		public void checkIfStillValid() throws PageHasChangedException  {
+			if( !client.getContentPage().equals( this.validForPage ) )
+				throw new PageHasChangedException(
+								"This element wrapper was created from another page and is not valid now.",
+								client.getContentPage(), this.validForPage );
+		}
+	}
 
+
 	/**
 	 * Inner class for manipulation with tab content box.
 	 */

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/PageHasChangedException.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/PageHasChangedException.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/PageHasChangedException.java	2009-02-20 03:23:06 UTC (rev 162)
@@ -0,0 +1,42 @@
+package org.jboss.jopr.jsfunit.exceptions;
+
+import com.gargoylesoftware.htmlunit.Page;
+
+/**
+ * Signalizes that there was an action performed
+ * that was out of context - e.g. clicking on a button
+ * that was a part of a HTML page that's already gone.
+ *
+ *
+ * @author ondra
+ */
+public class PageHasChangedException extends ActionOutOfSyncException {
+
+	private Page validForPage;
+	private Page actualPage;
+
+	public PageHasChangedException() {
+	}
+
+	public PageHasChangedException(String message) {
+		super(message);
+	}
+
+	public PageHasChangedException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public PageHasChangedException(Throwable cause) {
+		super(cause);
+	}
+
+	public PageHasChangedException( String message, Page validForPage, Page actualPage) {
+		super(message);
+		this.validForPage = validForPage;
+		this.actualPage = actualPage;
+	}
+
+
+	
+
+}




More information about the embjopr-commits mailing list