You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2011/03/21 10:13:28 UTC

svn commit: r1083708 - in /myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test: SeleniumTest.java TestTheAutomaticSeleniumTest.java

Author: lofwyr
Date: Mon Mar 21 09:13:28 2011
New Revision: 1083708

URL: http://svn.apache.org/viewvc?rev=1083708&view=rev
Log:
current version of selenium throws an exception, when we have status 404, so we get rid of the ugly substring search 404 (which sometime fails, because of the random generated session secret)

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/TestTheAutomaticSeleniumTest.java

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java?rev=1083708&r1=1083707&r2=1083708&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java Mon Mar 21 09:13:28 2011
@@ -28,7 +28,6 @@ public abstract class SeleniumTest {
   private static final String CONTEXT_PATH = "tobago-example-test";
   private static final String SERVLET_MAPPING = "faces";
 
-  public static final String CONTAINS_A_404 = "contains a 404";
   public static final String HAS_ERROR_SEVERITY = "has error severity";
   public static final String IS_BROKEN = "is broken";
 
@@ -56,7 +55,6 @@ public abstract class SeleniumTest {
   protected void checkPage() {
     final String location = selenium.getLocation();
     final String html = getHtmlSource();
-    Assert.assertFalse(format(CONTAINS_A_404, location, html, ""), pageNotFound());
     try {
       if (isErrorOnPage()) {
         Assert.fail(format(HAS_ERROR_SEVERITY, location, html, getErrors()));
@@ -80,16 +78,6 @@ public abstract class SeleniumTest {
   }
 
   /**
-   * Was the page not found?
-   *
-   * @return True if the page not found.
-   */
-  // XXX might be improved, I didn't find a way to read the HTTP status code
-  protected boolean pageNotFound() {
-    return selenium.getHtmlSource().contains("404");
-  }
-
-  /**
    * Checks the page for the Tobago JavaScript Logging Framework and tests its severity.
    *
    * @return True if the severity level of the page is error

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/TestTheAutomaticSeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/TestTheAutomaticSeleniumTest.java?rev=1083708&r1=1083707&r2=1083708&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/TestTheAutomaticSeleniumTest.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/TestTheAutomaticSeleniumTest.java Mon Mar 21 09:13:28 2011
@@ -17,10 +17,11 @@ package org.apache.myfaces.tobago.exampl
  * limitations under the License.
  */
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.thoughtworks.selenium.SeleniumException;
 import org.junit.Assert;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -67,12 +68,8 @@ public class TestTheAutomaticSeleniumTes
       test.testPageConsistency();
       test.tearDown();
       Assert.fail("The test should fail, but wasn't.");
-    } catch (AssertionError e) {
-      if (e.getMessage().contains(AutomaticSeleniumTest.CONTAINS_A_404)) {
-        // okay, the error was detected.
-      } else {
-        throw e;
-      }
+    } catch (SeleniumException e) {
+      Assert.assertTrue(e.getMessage().contains("Response_Code = 404"));
     }
   }