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/18 20:48:19 UTC
svn commit: r1083028 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-test/src:
main/java/org/apache/myfaces/tobago/example/test/
test/java/org/apache/myfaces/tobago/example/test/
Author: lofwyr
Date: Fri Mar 18 19:48:19 2011
New Revision: 1083028
URL: http://svn.apache.org/viewvc?rev=1083028&view=rev
Log:
improve logging output
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Filter.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Filter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Filter.java?rev=1083028&r1=1083027&r2=1083028&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Filter.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Filter.java Fri Mar 18 19:48:19 2011
@@ -54,11 +54,12 @@ public class Filter {
"/meta-test/meta-3.*\\.xhtml",
"/meta-test/meta-4.*",
+ "/tc/attribute/mode-valueIfSet.jspx", // set id="${id}" not possible with JSP.
"/tc/button/plain.html",
"/tc/button/plain_de.html",
"/tc/gridLayout/horizontal-600px-default-300px.*",
"/tc/gridLayout/horizontal-default-default-600px.*"
- ));
+ ));
public static boolean isValid(String name) {
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java?rev=1083028&r1=1083027&r2=1083028&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java Fri Mar 18 19:48:19 2011
@@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
@RunWith(Parameterized.class)
@@ -45,15 +46,38 @@ public class AutomaticSeleniumTest exten
@Parameterized.Parameters
public static Collection<Object[]> findPages() {
+ List<String> paths = new ArrayList<String>();
+
+ collect(paths, MAVEN_TARGET + '/', "");
+
+ Collections.sort(paths);
+
List<Object[]> result = new ArrayList<Object[]>();
- collect(result, MAVEN_TARGET + '/', "");
+ for (String path : paths) {
+ Object[] objects = {
+ path.replace('.', '_'), // because dots will be displayed strange in the IDE
+ createUrl(path)
+ };
+ result.add(objects);
+ }
return result;
}
- private static void collect(List<Object[]> result, String base, String directory) {
- String[] filenames = new File(base + directory).list();
+ private static void collect(List<String> result, String base, String directory) {
+
+ final File file = new File(base + directory);
+
+ if (! file.exists()) {
+ throw new RuntimeException("Input directory doesn't exists: '" + file.getAbsolutePath() + "'");
+ }
+
+ if (! file.isDirectory()) {
+ throw new RuntimeException("Input is not a directory: '" + file.getAbsolutePath() + "'");
+ }
+
+ String[] filenames = file.list();
for (String filename : filenames) {
@@ -65,11 +89,7 @@ public class AutomaticSeleniumTest exten
}
if (Filter.isValid(path)) {
- Object[] objects = {
- path,
- createUrl(path)
- };
- result.add(objects);
+ result.add(path);
}
}
}
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=1083028&r1=1083027&r2=1083028&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 Fri Mar 18 19:48:19 2011
@@ -53,21 +53,32 @@ public abstract class SeleniumTest {
return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080/");
}
-
-
protected void checkPage() {
- Assert.assertFalse(
- "Page '" + selenium.getLocation() + "' " + CONTAINS_A_404 + ". " + getHtmlSource(), pageNotFound());
+ final String location = selenium.getLocation();
+ final String html = getHtmlSource();
+ Assert.assertFalse(format(CONTAINS_A_404, location, html, ""), pageNotFound());
try {
- Assert.assertFalse(
- "Page '" + selenium.getLocation() + "' " + HAS_ERROR_SEVERITY + ". " + getHtmlSource(), isErrorOnPage());
+ if (isErrorOnPage()) {
+ Assert.fail(format(HAS_ERROR_SEVERITY, location, html, getErrors()));
+ }
} catch (SeleniumException e) {
- Assert.fail(
- "Page '" + selenium.getLocation() + "' " + IS_BROKEN + ". Not a Tobago page? " + getHtmlSource()
- + " exception=" + e);
+ Assert.fail(format(IS_BROKEN, location, html, "Not a Tobago page? Exception=" + e));
}
}
+ public String format(String error, String location, String html, String options) {
+ StringBuilder b = new StringBuilder();
+ b.append(error);
+ b.append("\nPage URL: ");
+ b.append(location);
+ b.append("\n");
+ b.append(options);
+ b.append("\n---------------------------------------------------------------------------------------------------\n");
+ b.append(html);
+ b.append("\n---------------------------------------------------------------------------------------------------\n");
+ return b.toString();
+ }
+
/**
* Was the page not found?
*
@@ -90,10 +101,13 @@ public abstract class SeleniumTest {
return Boolean.parseBoolean(errorSeverity);
}
+ protected String getErrors() throws SeleniumException {
+ String errors = selenium.getEval("window.LOG.getMessages(window.LOG.INFO)");
+ return errors;
+ }
+
protected String getHtmlSource() {
- return "\ncode=\n********************************************************************************\n"
- + selenium.getHtmlSource()
- + "\n********************************************************************************\n";
+ return selenium.getHtmlSource();
}
protected static String createUrl(String page) {