You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2009/12/15 18:47:00 UTC

svn commit: r890904 - in /tapestry/tapestry5/trunk/tapestry-test/src: main/java/org/apache/tapestry5/test/ test/conf/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/tapestry5/ test/java/org/apache/tapestry5/test/ test/webapp/

Author: hlship
Date: Tue Dec 15 17:46:59 2009
New Revision: 890904

URL: http://svn.apache.org/viewvc?rev=890904&view=rev
Log:
Add a basic test to prove that the servers start up correctly.

Added:
    tapestry/tapestry5/trunk/tapestry-test/src/test/java/
    tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/
    tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/
    tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/
    tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/
    tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java   (with props)
    tapestry/tapestry5/trunk/tapestry-test/src/test/webapp/
    tapestry/tapestry5/trunk/tapestry-test/src/test/webapp/index.html   (with props)
Modified:
    tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
    tapestry/tapestry5/trunk/tapestry-test/src/test/conf/testng.xml

Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java?rev=890904&r1=890903&r2=890904&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java Tue Dec 15 17:46:59 2009
@@ -843,4 +843,46 @@
     // End of delegate methods
     // ---------------------------------------------------------------------
 
+    protected final void unreachable()
+    {
+        throw new AssertionError("This statement should not be reachable.");
+    }
+
+    protected final void openBaseURL()
+    {
+        open(baseURL);
+    }
+
+    /**
+     * Asserts the text of an element, identified by the locator.
+     * 
+     * @param locator
+     *            identifies the element whose text value is to be asserted
+     * @param expected
+     *            expected value for the element's text
+     */
+    protected final void assertText(String locator, String expected)
+    {
+        String actual = null;
+
+        try
+        {
+            actual = getText(locator);
+        }
+        catch (RuntimeException ex)
+        {
+            System.err.printf("Error accessing %s: %s, in:\n\n%s\n\n", locator, ex.getMessage(),
+                    getHtmlSource());
+
+            throw ex;
+        }
+
+        if (actual.equals(expected))
+            return;
+
+        System.err.printf("Text for %s should be '%s' but is '%s', in:\n\n%s\n\n", locator,
+                expected, actual, getHtmlSource());
+
+        throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-test/src/test/conf/testng.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/test/conf/testng.xml?rev=890904&r1=890903&r2=890904&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/test/conf/testng.xml Tue Dec 15 17:46:59 2009
@@ -1,21 +1,20 @@
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<!--
-   Copyright 2008 The Apache Software Foundation
-
-   Licensed 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.
--->
+  <!--
+    Copyright 2009 The Apache Software Foundation Licensed 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.
+  -->
 
 <suite name="Tapestry Test" annotations="1.5" verbose="2">
-    <!-- This avoids a build error when performing a non-clean build.  Just another Maven fuckup to be worked around. -->
-    <test name="Placeholder (no tests)"/>
+  <parameter name="tapestry.web-app-folder" value="src/test/webapp"/>
+  <test name="SeleniumLauncher and SeleniumTestBase">
+    <classes>
+      <class name="org.apache.tapestry5.test.SeleniumLauncher"/>
+      <class name="org.apache.tapestry5.test.SanityCheckTestSuite"/>
+    </classes>
+
+  </test>
 </suite>

Added: tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java?rev=890904&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java (added)
+++ tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java Tue Dec 15 17:46:59 2009
@@ -0,0 +1,44 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed 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.
+
+package org.apache.tapestry5.test;
+
+import org.testng.annotations.Test;
+
+public class SanityCheckTestSuite extends SeleniumTestCase
+{
+    @Test
+    public void sanity_check()
+    {
+        openBaseURL();
+
+        assertText("//h1", "Tapestry Test");
+    }
+
+    @Test
+    public void invalid_assertion()
+    {
+        openBaseURL();
+
+        try
+        {
+            assertText("//h1", "XYZ");
+            unreachable();
+        }
+        catch (AssertionError ex)
+        {
+            assertEquals(ex.getMessage(), "//h1 was 'Tapestry Test' not 'XYZ'");
+        }
+    }
+}

Propchange: tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry5/trunk/tapestry-test/src/test/webapp/index.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/test/webapp/index.html?rev=890904&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/test/webapp/index.html (added)
+++ tapestry/tapestry5/trunk/tapestry-test/src/test/webapp/index.html Tue Dec 15 17:46:59 2009
@@ -0,0 +1,11 @@
+<html>
+  <head>
+    <title>Tapestry-Test</title>
+  </head>
+  <body>
+    <h1>Tapestry Test</h1>
+
+    <p>
+      A simple page to prove that the Selenium testing APIs are capable of starting up.</p>
+  </body>
+</html>
\ No newline at end of file

Propchange: tapestry/tapestry5/trunk/tapestry-test/src/test/webapp/index.html
------------------------------------------------------------------------------
    svn:eol-style = native