You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2017/12/04 16:00:55 UTC

[myfaces-tobago] branch master updated: improve tests * better check if error/exception and error/404 test works * accessAllPages test now checks error/exception and error/404 * fix error/exception test

This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 02a137b  improve tests * better check if error/exception and error/404 test works * accessAllPages test now checks error/exception and error/404 * fix error/exception test
02a137b is described below

commit 02a137b488236a4f4a20092b9fa874b78c7b44d1
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Mon Dec 4 17:00:17 2017 +0100

    improve tests
    * better check if error/exception and error/404 test works
    * accessAllPages test now checks error/exception and error/404
    * fix error/exception test
---
 .../myfaces/tobago/example/demo/TestController.java       | 11 +++++++----
 .../src/main/webapp/error/error.test.js                   |  2 +-
 .../src/main/webapp/testAccessAllPages.xhtml              | 15 ++++++++++-----
 .../apache/myfaces/tobago/example/demo/QUnitTests.java    | 10 ++++++++++
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
index e901aca..8381f35 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
@@ -55,13 +55,15 @@ public class TestController implements Serializable {
     return viewId.substring(1, viewId.length() - 6); //remove leading '/' and trailing '.xhtml'
   }
 
-  public List<String> getAllPages() {
-    final List<String> pages = new ArrayList<>();
+  public List<TestPage> getAllTestPages() {
+    final List<TestPage> pages = new ArrayList<>();
 
     final File rootDir = new File("src/main/webapp/content");
     if (rootDir.exists()) {
+      int idCount = 1;
       for (final String page : getXHTMLs(rootDir)) {
-        pages.add(page.substring(16));
+        final String base = page.substring(16, page.length() - 6);
+        pages.add(new TestPage("tp" + idCount++, base));
       }
     }
     return pages;
@@ -72,7 +74,8 @@ public class TestController implements Serializable {
     for (final File file : dir.listFiles()) {
       if (file.isDirectory()) {
         xhtmls.addAll(getXHTMLs(file));
-      } else if (!file.getName().startsWith("x-") && file.getName().endsWith(".xhtml")) {
+      } else if (!file.getName().startsWith("x-") && file.getName().endsWith(".xhtml")
+          && !file.getPath().contains("content/40-test/90000-attic/")) {
         xhtmls.add(file.getPath());
       }
     }
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js b/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js
index 2ec4c37..9dd2bb7 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js
@@ -16,7 +16,7 @@
  */
 
 QUnit.test("has no exception", function (assert) {
-  var $error = jQueryFrame("#page\\:errorSection .tobago-section-header span");
+  var $error = jQueryFrame("#page\\:mainForm\\:errorSection .tobago-section-header span");
   assert.notEqual($error.text(), "An error has occurred!");
 });
 
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml
index 7f2d624..790cb93 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml
@@ -22,11 +22,16 @@
                 xmlns:c="http://java.sun.com/jsp/jstl/core"
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="http://java.sun.com/jsf/facelets">
-  <c:forEach items="#{testController.allPages}" var="page">
-    <div style="border: 1px solid black">
-      <tc:link label="#{request.contextPath}/#{page} - open in new tab" outcome="/#{page}" target="_blank"/>
-      <tc:object src="#{request.contextPath}/#{page}">
-        <tc:style width="100%" height="300px"/>
+  <tc:style file="#{request.contextPath}/style/tobago.css"/>
+  <tc:script file="#{request.contextPath}/script/tobago-testAll.js"/>
+
+  <c:forEach items="#{testController.allTestPages}" var="testPage">
+    <div class="testframe-wrapper">
+      <div>
+        <tc:link label="open in new tab" link="test.xhtml?base=#{testPage.base}&amp;accessTest=true" target="_blank"/>
+      </div>
+      <tc:object id="#{testPage.id}" name="test.xhtml?base=#{testPage.base}&amp;accessTest=true">
+        <tc:style height="300px"/>
       </tc:object>
     </div>
   </c:forEach>
diff --git a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
index 2143d57..c6e716a 100644
--- a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
+++ b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
@@ -269,21 +269,31 @@ public class QUnitTests {
 
     // Test if 'has no exception' test is correct.
     setupBrowser("error/exception", true);
+    final boolean timeoutException = waitForTest("error/exception");
+    Assert.assertFalse("Could not verify 'has no exception' test: TIMEOUT", timeoutException);
     results = qunitTests.findElements(By.xpath("li"));
+    boolean testException = false;
     for (final WebElement result : results) {
       if ("has no exception".equals(result.findElement(By.className("test-name")).getText())) {
         Assert.assertEquals(result.getAttribute("class"), "fail");
+        testException = true;
       }
     }
+    Assert.assertTrue("Could not verify 'has no exception' test.", testException);
 
     // Test if 'has no 404' test is correct.
     setupBrowser("error/404", true);
+    final boolean timeout404 = waitForTest("error/404");
+    Assert.assertFalse("Could not verify 'has no 404' test. TIMEOUT", timeout404);
+    boolean test404 = false;
     results = qunitTests.findElements(By.xpath("li"));
     for (final WebElement result : results) {
       if ("has no 404".equals(result.findElement(By.className("test-name")).getText())) {
         Assert.assertEquals(result.getAttribute("class"), "fail");
+        test404 = true;
       }
     }
+    Assert.assertTrue("Could not verify 'has no 404' test.", test404);
 
     for (final String page : pages) {
       final String pathForBrowser = page.substring(page.indexOf("src/main/webapp/") + "src/main/webapp/".length(),

-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].