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 2016/07/08 14:03:26 UTC
svn commit: r1751912 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src:
main/webapp/content/20-component/030-select/10-selectBooleanCheckbox/
main/webapp/content/20-component/030-select/20-selectOneChoice/
main/webapp/content/20-compone...
Author: lofwyr
Date: Fri Jul 8 14:03:26 2016
New Revision: 1751912
URL: http://svn.apache.org/viewvc?rev=1751912&view=rev
Log:
TOBAGO 1473: Test
- use prop instead of attr
- QUnit:all
[developed by hnoeth]
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/10-selectBooleanCheckbox/selectBooleanCheckbox.test.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/20-selectOneChoice/selectOneChoice.test.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.test.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/40-selectOneListbox/selectOneListbox.test.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.test.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/404.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/exception.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/10-selectBooleanCheckbox/selectBooleanCheckbox.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/10-selectBooleanCheckbox/selectBooleanCheckbox.test.js?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/10-selectBooleanCheckbox/selectBooleanCheckbox.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/10-selectBooleanCheckbox/selectBooleanCheckbox.test.js Fri Jul 8 14:03:26 2016
@@ -27,9 +27,9 @@ QUnit.test("submit: select A", function
var $selectC = jQueryFrame("#page\\:mainForm\\:selectC input");
var $submit = jQueryFrame("#page\\:mainForm\\:submit");
- $selectA.attr("checked", "checked");
- $selectB.removeAttr("checked");
- $selectC.removeAttr("checked");
+ $selectA.prop("checked", true);
+ $selectB.prop("checked", false);
+ $selectC.prop("checked", false);
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -47,9 +47,9 @@ QUnit.test("submit: select B and C", fun
var $selectC = jQueryFrame("#page\\:mainForm\\:selectC input");
var $submit = jQueryFrame("#page\\:mainForm\\:submit");
- $selectA.removeAttr("checked");
- $selectB.attr("checked", "checked");
- $selectC.attr("checked", "checked");
+ $selectA.prop("checked", false);
+ $selectB.prop("checked", true);
+ $selectC.prop("checked", true);
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -63,7 +63,7 @@ QUnit.test("ajax: select D", function (a
assert.expect(1);
var done = assert.async();
var $selectD = jQueryFrame("#page\\:mainForm\\:selectD input");
- $selectD.attr("checked", "checked").trigger("change");
+ $selectD.prop("checked", true).trigger("change");
$.ajax({
type: 'GET',
@@ -79,7 +79,7 @@ QUnit.test("ajax: deselect D", function
assert.expect(1);
var done = assert.async();
var $selectD = jQueryFrame("#page\\:mainForm\\:selectD input");
- $selectD.removeAttr("checked").trigger("change");
+ $selectD.prop("checked", false).trigger("change");
$.ajax({
type: 'GET',
@@ -95,7 +95,7 @@ QUnit.test("ajax: select E", function (a
assert.expect(1);
var done = assert.async();
var $selectE = jQueryFrame("#page\\:mainForm\\:selectE input");
- $selectE.attr("checked", "checked").trigger("change");
+ $selectE.prop("checked", true).trigger("change");
$.ajax({
type: 'GET',
@@ -111,7 +111,7 @@ QUnit.test("ajax: deselect E", function
assert.expect(1);
var done = assert.async();
var $selectE = jQueryFrame("#page\\:mainForm\\:selectE input");
- $selectE.removeAttr("checked").trigger("change");
+ $selectE.prop("checked", false).trigger("change");
$.ajax({
type: 'GET',
@@ -127,7 +127,7 @@ QUnit.test("ajax: select F", function (a
assert.expect(1);
var done = assert.async();
var $selectF = jQueryFrame("#page\\:mainForm\\:selectF input");
- $selectF.attr("checked", "checked").trigger("change");
+ $selectF.prop("checked", true).trigger("change");
$.ajax({
type: 'GET',
@@ -143,7 +143,7 @@ QUnit.test("ajax: deselect F", function
assert.expect(1);
var done = assert.async();
var $selectF = jQueryFrame("#page\\:mainForm\\:selectF input");
- $selectF.removeAttr("checked").trigger("change");
+ $selectF.prop("checked", false).trigger("change");
$.ajax({
type: 'GET',
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/20-selectOneChoice/selectOneChoice.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/20-selectOneChoice/selectOneChoice.test.js?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/20-selectOneChoice/selectOneChoice.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/20-selectOneChoice/selectOneChoice.test.js Fri Jul 8 14:03:26 2016
@@ -26,8 +26,8 @@ QUnit.test("submit: Alice", function (as
var $bob = jQueryFrame("#page\\:mainForm\\:selectPerson\\:\\:field option:contains('Bob')");
var $submit = jQueryFrame("#page\\:mainForm\\:submit");
- $alice.attr("selected", "selected");
- $bob.removeAttr("selected");
+ $alice.prop("selected", true);
+ $bob.prop("selected", false);
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -44,8 +44,8 @@ QUnit.test("submit: Bob", function (asse
var $bob = jQueryFrame("#page\\:mainForm\\:selectPerson\\:\\:field option:contains('Bob')");
var $submit = jQueryFrame("#page\\:mainForm\\:submit");
- $alice.removeAttr("selected");
- $bob.attr("selected", "selected");
+ $alice.prop("selected", false);
+ $bob.prop("selected", true);
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -61,8 +61,8 @@ QUnit.test("ajax: select Mars", function
var $mars = jQueryFrame("#page\\:mainForm\\:selectPlanet\\:\\:field option:contains('Mars')");
var $jupiter = jQueryFrame("#page\\:mainForm\\:selectPlanet\\:\\:field option:contains('Jupiter')");
- $jupiter.removeAttr("selected");
- $mars.attr("selected", "selected").trigger("change");
+ $jupiter.prop("selected", false);
+ $mars.prop("selected", true).trigger("change");
$.ajax({
type: 'GET',
@@ -81,8 +81,8 @@ QUnit.test("ajax: select Jupiter", funct
var $mars = jQueryFrame("#page\\:mainForm\\:selectPlanet\\:\\:field option:contains('Mars')");
var $jupiter = jQueryFrame("#page\\:mainForm\\:selectPlanet\\:\\:field option:contains('Jupiter')");
- $mars.removeAttr("selected");
- $jupiter.attr("selected", "selected").trigger("change");
+ $mars.prop("selected", false);
+ $jupiter.prop("selected", true).trigger("change");
$.ajax({
type: 'GET',
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.test.js?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.test.js Fri Jul 8 14:03:26 2016
@@ -26,12 +26,12 @@ QUnit.test("submit: Addition (2 + 4)", f
var $number2 = jQueryFrame("#page\\:mainForm\\:selectNum2 input");
var $submitAdd = jQueryFrame("#page\\:mainForm\\:submitAdd");
- $number1.eq(0).removeAttr("checked");
- $number1.eq(1).attr("checked", "checked"); // Select 2
- $number1.eq(2).removeAttr("checked");
- $number2.eq(0).removeAttr("checked");
- $number2.eq(1).removeAttr("checked");
- $number2.eq(2).attr("checked", "checked"); // Select 4
+ $number1.eq(0).prop("checked", false);
+ $number1.eq(1).prop("checked", true); // Select 2
+ $number1.eq(2).prop("checked", false);
+ $number2.eq(0).prop("checked", false);
+ $number2.eq(1).prop("checked", false);
+ $number2.eq(2).prop("checked", true); // Select 4
$submitAdd.click();
jQuery("#page\\:testframe").load(function () {
@@ -48,12 +48,12 @@ QUnit.test("submit: Subtraction (4 - 1)"
var $number2 = jQueryFrame("#page\\:mainForm\\:selectNum2 input");
var $submitSub = jQueryFrame("#page\\:mainForm\\:submitSub");
- $number1.eq(0).removeAttr("checked");
- $number1.eq(1).removeAttr("checked");
- $number1.eq(2).attr("checked", "checked"); // Select 4
- $number2.eq(0).attr("checked", "checked"); // Select 1
- $number2.eq(1).removeAttr("checked");
- $number2.eq(2).removeAttr("checked");
+ $number1.eq(0).prop("checked", false);
+ $number1.eq(1).prop("checked", false);
+ $number1.eq(2).prop("checked", true); // Select 4
+ $number2.eq(0).prop("checked", true); // Select 1
+ $number2.eq(1).prop("checked", false);
+ $number2.eq(2).prop("checked", false);
$submitSub.click();
jQuery("#page\\:testframe").load(function () {
@@ -68,9 +68,9 @@ QUnit.test("ajax: select Mars", function
var done = assert.async();
var $planet = jQueryFrame("#page\\:mainForm\\:selectPlanet input");
- $planet.eq(0).removeAttr("checked");
- $planet.eq(2).removeAttr("checked");
- $planet.eq(1).attr("checked", "checked").trigger("change"); // Mars.
+ $planet.eq(0).prop("checked", false);
+ $planet.eq(2).prop("checked", false);
+ $planet.eq(1).prop("checked", true).trigger("change"); // Mars.
$.ajax({
type: 'GET',
@@ -88,9 +88,9 @@ QUnit.test("ajax: select Jupiter", funct
var done = assert.async();
var $planet = jQueryFrame("#page\\:mainForm\\:selectPlanet input");
- $planet.eq(0).removeAttr("checked");
- $planet.eq(1).removeAttr("checked");
- $planet.eq(2).attr("checked", "checked").trigger("change"); // Jupiter.
+ $planet.eq(0).prop("checked", false);
+ $planet.eq(1).prop("checked", false);
+ $planet.eq(2).prop("checked", true).trigger("change"); // Jupiter.
$.ajax({
type: 'GET',
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/40-selectOneListbox/selectOneListbox.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/40-selectOneListbox/selectOneListbox.test.js?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/40-selectOneListbox/selectOneListbox.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/40-selectOneListbox/selectOneListbox.test.js Fri Jul 8 14:03:26 2016
@@ -25,11 +25,11 @@ QUnit.test("submit: select 'Nile'", func
var $rivers = jQueryFrame("#page\\:mainForm\\:riverList option");
var $submit = jQueryFrame("#page\\:mainForm\\:riverSubmit");
- $rivers.eq(0).attr("selected", "selected"); // Nile
- $rivers.eq(1).removeAttr("selected"); // Amazon
- $rivers.eq(2).removeAttr("selected"); // Yangtze
- $rivers.eq(3).removeAttr("selected"); // Yellow River
- $rivers.eq(4).removeAttr("selected"); // Paraná River
+ $rivers.eq(0).prop("selected", true); // Nile
+ $rivers.eq(1).prop("selected", false); // Amazon
+ $rivers.eq(2).prop("selected", false); // Yangtze
+ $rivers.eq(3).prop("selected", false); // Yellow River
+ $rivers.eq(4).prop("selected", false); // Paraná River
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -45,11 +45,11 @@ QUnit.test("submit: select 'Yangtze'", f
var $rivers = jQueryFrame("#page\\:mainForm\\:riverList option");
var $submit = jQueryFrame("#page\\:mainForm\\:riverSubmit");
- $rivers.eq(0).removeAttr("selected"); // Nile
- $rivers.eq(1).removeAttr("selected"); // Amazon
- $rivers.eq(2).attr("selected", "selected"); // Yangtze
- $rivers.eq(3).removeAttr("selected"); // Yellow River
- $rivers.eq(4).removeAttr("selected"); // Paraná River
+ $rivers.eq(0).prop("selected", false); // Nile
+ $rivers.eq(1).prop("selected", false); // Amazon
+ $rivers.eq(2).prop("selected", true); // Yangtze
+ $rivers.eq(3).prop("selected", false); // Yellow River
+ $rivers.eq(4).prop("selected", false); // Paraná River
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -64,11 +64,11 @@ QUnit.test("ajax: select Everest", funct
var done = assert.async();
var $mountains = jQueryFrame("#page\\:mainForm\\:mountainList option");
- $mountains.eq(1).removeAttr("selected");
- $mountains.eq(2).removeAttr("selected");
- $mountains.eq(3).removeAttr("selected");
- $mountains.eq(4).removeAttr("selected");
- $mountains.eq(0).attr("selected", "selected").trigger("change"); // Everest
+ $mountains.eq(1).prop("selected", false);
+ $mountains.eq(2).prop("selected", false);
+ $mountains.eq(3).prop("selected", false);
+ $mountains.eq(4).prop("selected", false);
+ $mountains.eq(0).prop("selected", true).trigger("change"); // Everest
$.ajax({
type: 'GET',
@@ -85,11 +85,11 @@ QUnit.test("ajax: select Makalu", functi
var done = assert.async();
var $mountains = jQueryFrame("#page\\:mainForm\\:mountainList option");
- $mountains.eq(0).removeAttr("selected");
- $mountains.eq(1).removeAttr("selected");
- $mountains.eq(2).removeAttr("selected");
- $mountains.eq(3).removeAttr("selected");
- $mountains.eq(4).attr("selected", "selected").trigger("change"); // Everest
+ $mountains.eq(0).prop("selected", false);
+ $mountains.eq(1).prop("selected", false);
+ $mountains.eq(2).prop("selected", false);
+ $mountains.eq(3).prop("selected", false);
+ $mountains.eq(4).prop("selected", true).trigger("change"); // Everest
$.ajax({
type: 'GET',
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.test.js?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.test.js Fri Jul 8 14:03:26 2016
@@ -25,10 +25,10 @@ QUnit.test("submit: select cat", functio
var $animals = jQueryFrame("#page\\:mainForm\\:animals input");
var $submit = jQueryFrame("#page\\:mainForm\\:submit");
- $animals.eq(0).attr("checked", "checked");
- $animals.eq(1).removeAttr("checked");
- $animals.eq(2).removeAttr("checked");
- $animals.eq(3).removeAttr("checked");
+ $animals.eq(0).prop("checked", true);
+ $animals.eq(1).prop("checked", false);
+ $animals.eq(2).prop("checked", false);
+ $animals.eq(3).prop("checked", false);
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -44,10 +44,10 @@ QUnit.test("submit: select fox and rabbi
var $animals = jQueryFrame("#page\\:mainForm\\:animals input");
var $submit = jQueryFrame("#page\\:mainForm\\:submit");
- $animals.eq(0).removeAttr("checked");
- $animals.eq(1).removeAttr("checked");
- $animals.eq(2).attr("checked", "checked");
- $animals.eq(3).attr("checked", "checked");
+ $animals.eq(0).prop("checked", false);
+ $animals.eq(1).prop("checked", false);
+ $animals.eq(2).prop("checked", true);
+ $animals.eq(3).prop("checked", true);
$submit.click();
jQuery("#page\\:testframe").load(function () {
@@ -66,10 +66,10 @@ QUnit.test("ajax: click 'Two'", function
var newOutputValue;
if ($number2.attr("checked") === "checked") {
- $number2.removeAttr("checked").trigger("change");
+ $number2.prop("checked", false).trigger("change");
newOutputValue = parseInt($output.text()) - 2;
} else {
- $number2.attr("checked", "checked").trigger("change");
+ $number2.prop("checked", true).trigger("change");
newOutputValue = parseInt($output.text()) + 2;
}
@@ -91,11 +91,11 @@ QUnit.test("ajax: click 'Three'", functi
var newOutputValue;
- if ($number3.attr("checked") === "checked") {
- $number3.removeAttr("checked").trigger("change");
+ if ($number3.prop("checked")) {
+ $number3.prop("checked", false).trigger("change");
newOutputValue = parseInt($output.text()) - 3;
} else {
- $number3.attr("checked", "checked").trigger("change");
+ $number3.prop("checked", true).trigger("change");
newOutputValue = parseInt($output.text()) + 3;
}
@@ -117,11 +117,11 @@ QUnit.test("ajax: click 'Two'", function
var newOutputValue;
- if ($number2.attr("checked") === "checked") {
- $number2.removeAttr("checked").trigger("change");
+ if ($number2.prop("checked")) {
+ $number2.prop("checked", false).trigger("change");
newOutputValue = parseInt($output.text()) - 2;
} else {
- $number2.attr("checked", "checked").trigger("change");
+ $number2.prop("checked", true).trigger("change");
newOutputValue = parseInt($output.text()) + 2;
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/404.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/404.xhtml?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/404.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/404.xhtml Fri Jul 8 14:03:26 2016
@@ -28,6 +28,6 @@
</f:facet>
<tc:messages />
- <tc:out value="The page was not found!"/>
+ <tc:out id="pageNotFoundMessage" value="The page was not found!"/>
</tc:panel>
</ui:composition>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js?rev=1751912&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/error.test.js Fri Jul 8 14:03:26 2016
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function jQueryFrame(expression) {
+ return document.getElementById("page:testframe").contentWindow.jQuery(expression);
+}
+
+QUnit.test("has no exception", function (assert) {
+ var $error = jQueryFrame("#page\\:errorSection .tobago-section-header span");
+ assert.notEqual($error.text(), "An error has occurred!");
+});
+
+QUnit.test("has no 404", function (assert) {
+ var $error404 = jQueryFrame("#page\\:mainForm\\:pageNotFoundMessage span");
+ assert.notEqual($error404.text(), "The page was not found!");
+});
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/exception.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/exception.xhtml?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/exception.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/error/exception.xhtml Fri Jul 8 14:03:26 2016
@@ -23,7 +23,7 @@
<ui:param name="title" value="Sorry, an error has occured!"/>
<tc:messages/>
- <tc:section label="An error has occurred!">
+ <tc:section id="errorSection" label="An error has occurred!">
<!-- TODO
<tc:out value="#{exceptionContext.exception}" escape="false"/>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java?rev=1751912&r1=1751911&r2=1751912&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java Fri Jul 8 14:03:26 2016
@@ -28,6 +28,7 @@ import org.jboss.arquillian.test.api.Arq
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,8 +39,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
+import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
@RunWith(Arquillian.class)
@@ -47,6 +51,7 @@ import java.util.List;
public class QUnitTests {
private static final Logger LOG = LoggerFactory.getLogger(QUnitTests.class);
+ private static List<String> testedPages = new LinkedList<String>();
@Drone
private WebDriver browser;
@@ -66,10 +71,21 @@ public class QUnitTests {
return webArchive;
}
- private void checkResults(String page) {
+ private void setupBrowser(String page, String testJs) throws UnsupportedEncodingException {
+ browser.get(contextPath + "/faces/test.xhtml?page=" + URLEncoder.encode(page, "UTF-8") + "&testjs="
+ + URLEncoder.encode(testJs, "UTF-8"));
+ }
+
+ private void runStandardTest(String page) throws UnsupportedEncodingException {
+ testedPages.add(page);
+
String testJs = page.substring(0, page.length() - 6) + ".test.js";
- browser.get(contextPath + "/faces/test.xhtml?page=" + page + "&testjs=" + testJs);
+ setupBrowser(page, testJs);
+
+ checkQUnitResults(page);
+ }
+ private void checkQUnitResults(String page) {
WebElement qunitTests = qunit.findElement(By.id("qunit-tests"));
List<WebElement> testCases = qunitTests.findElements(By.xpath("li"));
Assert.assertTrue("There must be at least one test case.", testCases.size() > 0);
@@ -111,17 +127,27 @@ public class QUnitTests {
}
}
- // @Test
- public void allPages() {
- File dir = new File("tobago-example/tobago-example-demo/src/main/webapp/content");
- List<String> testablePages = getTestablePages(dir);
+ @AfterClass
+ public static void checkMissingTests() {
+ if (testedPages.size() > 1) {
+ File dir = new File("tobago-example/tobago-example-demo/src/main/webapp/content");
+ List<String> testablePages = getTestablePages(dir);
+
+ StringBuilder stringBuilder = new StringBuilder();
+ for (String testablePage : testablePages) {
+ if (!testedPages.contains(testablePage)) {
+ String errorString = "missing testmethod for " + testablePage;
+ LOG.warn(errorString);
+ stringBuilder.append("\n");
+ stringBuilder.append(errorString);
+ }
+ }
- for (String page : testablePages) {
- checkResults(page);
+ Assert.assertEquals(stringBuilder.toString(), testablePages.size(), testedPages.size());
}
}
- private List<String> getTestablePages(File dir) {
+ private static List<String> getTestablePages(File dir) {
List<String> testablePages = new ArrayList<String>();
for (File file : dir.listFiles()) {
if (file.isDirectory()) {
@@ -138,80 +164,118 @@ public class QUnitTests {
}
@Test
- public void in() {
+ public void testAccessAllPages() throws UnsupportedEncodingException {
+ File dir = new File("tobago-example/tobago-example-demo/src/main/webapp/content");
+ List<String> pages = getXHTMLs(dir);
+ String testJs = "error/error.test.js";
+ List<WebElement> results;
+
+ // Test if 'has no exception' test is correct.
+ setupBrowser("error/exception.xhtml", testJs);
+ results = qunit.findElement(By.id("qunit-tests")).findElements(By.xpath("li"));
+ Assert.assertEquals(results.get(0).getAttribute("class"), "fail");
+ Assert.assertEquals(results.get(1).getAttribute("class"), "pass");
+
+ // Test if 'has no 404' test is correct.
+ setupBrowser("error/404.xhtml", testJs);
+ results = qunit.findElement(By.id("qunit-tests")).findElements(By.xpath("li"));
+ Assert.assertEquals(results.get(0).getAttribute("class"), "pass");
+ Assert.assertEquals(results.get(1).getAttribute("class"), "fail");
+
+ for (String page : pages) {
+ setupBrowser(page, testJs);
+ checkQUnitResults(page);
+ }
+ }
+
+ private List<String> getXHTMLs(File dir) {
+ List<String> xhtmls = new ArrayList<String>();
+ for (File file : dir.listFiles()) {
+ if (file.isDirectory()) {
+ xhtmls.addAll(getXHTMLs(file));
+ } else if (!file.getName().startsWith("x-") && file.getName().endsWith(".xhtml")) {
+ String path = file.getPath().substring("tobago-example/tobago-example-demo/src/main/webapp/".length());
+ xhtmls.add(path);
+ }
+ }
+ return xhtmls;
+ }
+
+ @Test
+ public void in() throws UnsupportedEncodingException {
String page = "content/20-component/010-input/10-in/in.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void date() {
+ public void date() throws UnsupportedEncodingException {
String page = "content/20-component/010-input/40-date/date.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void selectBooleanCheckbox() {
+ public void selectBooleanCheckbox() throws UnsupportedEncodingException {
String page = "content/20-component/030-select/10-selectBooleanCheckbox/selectBooleanCheckbox.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void selectOneChoice() {
+ public void selectOneChoice() throws UnsupportedEncodingException {
String page = "content/20-component/030-select/20-selectOneChoice/selectOneChoice.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void selectOneRadio() {
- String page = "content/20-component/030-select/30-selectOneRadio/selectOneRadio.xhtml"; // TODO: fails
- checkResults(page);
+ public void selectOneRadio() throws UnsupportedEncodingException {
+ String page = "content/20-component/030-select/30-selectOneRadio/selectOneRadio.xhtml";
+ runStandardTest(page);
}
@Test
- public void selectOneListbox() {
+ public void selectOneListbox() throws UnsupportedEncodingException {
String page = "content/20-component/030-select/40-selectOneListbox/selectOneListbox.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void selectManyCheckbox() {
+ public void selectManyCheckbox() throws UnsupportedEncodingException {
String page = "content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void form() {
+ public void form() throws UnsupportedEncodingException {
String page = "content/30-concept/08-form/form.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void formRequired() {
+ public void formRequired() throws UnsupportedEncodingException {
String page = "content/30-concept/08-form/10-required/form-required.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void formAjax() {
+ public void formAjax() throws UnsupportedEncodingException {
String page = "content/30-concept/08-form/20-ajax/form-ajax.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void testDate() {
+ public void testDate() throws UnsupportedEncodingException {
String page = "content/40-test/1040-date/date.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void rendererBaseGetCurrentValue() {
+ public void rendererBaseGetCurrentValue() throws UnsupportedEncodingException {
String page = "content/40-test/50000-java/10-rendererBase-getCurrentValue/rendererBase-getCurrentValue.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
@Test
- public void ajaxExecute() {
+ public void ajaxExecute() throws UnsupportedEncodingException {
String page = "content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml";
- checkResults(page);
+ runStandardTest(page);
}
}