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:08 UTC

svn commit: r890906 - in /tapestry/tapestry5/trunk: tapestry-core/src/test/conf/ tapestry-core/src/test/java/org/apache/tapestry5/integration/ tapestry-core/src/test/java/org/apache/tapestry5/integration/core/ tapestry-test/src/main/java/org/apache/tap...

Author: hlship
Date: Tue Dec 15 17:47:07 2009
New Revision: 890906

URL: http://svn.apache.org/viewvc?rev=890906&view=rev
Log:
Begin moving tests into proper suites

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java   (with props)
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java   (with props)
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml?rev=890906&r1=890905&r2=890906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml Tue Dec 15 17:47:07 2009
@@ -1,62 +1,67 @@
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<!-- 
-   Copyright 2008 The Apache Software Foundation
+  <!--
+    Copyright 2008, 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.
+  -->
 
-   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.
--->
-
-<!-- The suite may no longer be run in parallel, because of some tricky issues related to locking of class loaders. Running in parallel causes thread deadlocks, when unmanaged
-tests run at the same time as Selenium-based integration tests.  See TAPESTRY-2561. -->
+  <!--
+    The suite may no longer be run in parallel, because of some tricky issues related to locking of
+    class loaders. Running in parallel causes thread deadlocks, when unmanaged tests run at the same
+    time as Selenium-based integration tests. See TAPESTRY-2561.
+  -->
 <suite name="Tapestry Core" annotations="1.5" verbose="2">
-    <test name="Integration Tests">
-        <packages>
-            <package name="org.apache.tapestry5.integration.pagelevel"/>
-            <package name="org.apache.tapestry5.corelib.base"/>
-            <package name="org.apache.tapestry5.corelib.components"/>
-            <package name="org.apache.tapestry5.corelib.internal"/>
-        </packages>
-    </test>
-    <test name="Public APIs">
-        <packages>
-            <package name="org.apache.tapestry5"/>
-            <package name="org.apache.tapestry5.dom"/>
-            <package name="org.apache.tapestry5.json"/>
-            <package name="org.apache.tapestry5.runtime"/>
-            <package name="org.apache.tapestry5.services"/>
-            <package name="org.apache.tapestry5.urlrewriter"/>
-            <package name="org.apache.tapestry5.util"/>
-            <package name="org.apache.tapestry5.validator"/>
-        </packages>
-    </test>
-    <test name="Internal APIs">
-        <packages>
-            <package name="org.apache.tapestry5.internal"/>
-            <package name="org.apache.tapestry5.internal.beaneditor"/>
-            <package name="org.apache.tapestry5.internal.bindings"/>
-            <package name="org.apache.tapestry5.internal.grid"/>
-            <package name="org.apache.tapestry5.internal.model"/>
-            <package name="org.apache.tapestry5.internal.pageload"/>
-            <package name="org.apache.tapestry5.internal.services"/>
-            <package name="org.apache.tapestry5.internal.structure"/>
-            <package name="org.apache.tapestry5.internal.test"/>
-            <package name="org.apache.tapestry5.internal.transform"/>
-            <package name="org.apache.tapestry5.internal.translator"/>
-            <package name="org.apache.tapestry5.internal.util"/>
-        </packages>
-    </test>
-    <test name="Integration Tests">
-        <packages>
-            <package name="org.apache.tapestry5.integration"/>
-        </packages>
-    </test>
+  <test name="Component Unit Tests" enabled="false">
+    <packages>
+      <package name="org.apache.tapestry5.integration.pagelevel"/>
+      <package name="org.apache.tapestry5.corelib.base"/>
+      <package name="org.apache.tapestry5.corelib.components"/>
+      <package name="org.apache.tapestry5.corelib.internal"/>
+    </packages>
+  </test>
+  <test name="Public APIs" enabled="false">
+    <packages>
+      <package name="org.apache.tapestry5"/>
+      <package name="org.apache.tapestry5.dom"/>
+      <package name="org.apache.tapestry5.json"/>
+      <package name="org.apache.tapestry5.runtime"/>
+      <package name="org.apache.tapestry5.services"/>
+      <package name="org.apache.tapestry5.urlrewriter"/>
+      <package name="org.apache.tapestry5.util"/>
+      <package name="org.apache.tapestry5.validator"/>
+    </packages>
+  </test>
+  <test name="Internal APIs" enabled="false">
+    <packages>
+      <package name="org.apache.tapestry5.internal"/>
+      <package name="org.apache.tapestry5.internal.beaneditor"/>
+      <package name="org.apache.tapestry5.internal.bindings"/>
+      <package name="org.apache.tapestry5.internal.grid"/>
+      <package name="org.apache.tapestry5.internal.model"/>
+      <package name="org.apache.tapestry5.internal.pageload"/>
+      <package name="org.apache.tapestry5.internal.services"/>
+      <package name="org.apache.tapestry5.internal.structure"/>
+      <package name="org.apache.tapestry5.internal.test"/>
+      <package name="org.apache.tapestry5.internal.transform"/>
+      <package name="org.apache.tapestry5.internal.translator"/>
+      <package name="org.apache.tapestry5.internal.util"/>
+    </packages>
+  </test>
+  <!--  We break these out by which of the test applications they apply to. We have a bunch. -->
+  <!--
+    <test name="Integration Tests"> <packages> <package name="org.apache.tapestry5.integration"/>
+    </packages> </test>
+  -->
+  <test name="Core Integration Tests">
+    <parameter name="tapestry.web-app-folder" value="src/test/app1"/>
+    <classes>
+      <class name="org.apache.tapestry5.test.SeleniumLauncher"/>
+    </classes>
+    <packages>
+      <package name="org.apache.tapestry5.integration.core"/>
+    </packages>
+  </test>
 </suite>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=890906&r1=890905&r2=890906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Tue Dec 15 17:47:07 2009
@@ -86,31 +86,6 @@
         assertEquals(downloaded, actual);
     }
 
-    /**
-     * Tests the ability to inject a Block, and the ability to use the block to
-     * control rendering.
-     */
-    @Test
-    public void block_rendering() throws Exception
-    {
-        start("BlockDemo");
-
-        assertTextPresent("[]");
-
-        select("//select[@id='blockName']", "fred");
-        waitForPageToLoad(PAGE_LOAD_TIMEOUT);
-
-        assertTextPresent("[Block fred.]");
-
-        select("//select[@id='blockName']", "barney");
-        waitForPageToLoad(PAGE_LOAD_TIMEOUT);
-
-        assertTextPresent("[Block barney.]");
-
-        // TAPESETRY-1583
-
-        assertTextPresent("before it is defined: [Block wilma].");
-    }
 
     @Test
     public void component_parameter_default_from_method() throws Exception

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java?rev=890906&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java Tue Dec 15 17:47:07 2009
@@ -0,0 +1,40 @@
+// 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.integration;
+
+import org.apache.tapestry5.test.SeleniumTestCase;
+
+public abstract class TapestryCoreTestCase extends SeleniumTestCase
+{
+    /**
+     * 15 seconds
+     */
+    public static final String PAGE_LOAD_TIMEOUT = "15000";
+
+    /**
+     * Opens the base URL, then clicks through a series of links to get to a desired application
+     * state.
+     */
+    public void clickThru(String... linkText)
+    {
+        openBaseURL();
+
+        for (String text : linkText)
+        {
+            click("link=" + text);
+            waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+        }
+    }
+}

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

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java?rev=890906&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java Tue Dec 15 17:47:07 2009
@@ -0,0 +1,56 @@
+// 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.integration.core;
+
+import org.apache.tapestry5.integration.TapestryCoreTestCase;
+import org.testng.annotations.Test;
+
+public class CoreBehaviorsTest extends TapestryCoreTestCase
+{
+
+    /**
+     * Tests the ability to inject a Block, and the ability to use the block to
+     * control rendering.
+     */
+    @Test
+    public void block_rendering() throws Exception
+    {
+        clickThru("BlockDemo");
+
+        assertTextPresent("[]");
+
+        select("//select[@id='blockName']", "fred");
+        waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+
+        assertTextPresent("[Block fred.]");
+
+        select("//select[@id='blockName']", "barney");
+        waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+
+        assertTextPresent("[Block barney.]");
+
+        // TAPESTRY-1583
+
+        assertTextPresent("before it is defined: [Block wilma].");
+    }
+
+    @Test
+    public void environmental()
+    {
+        clickThru("Environmental Annotation Usage");
+
+        assertSourcePresent("[<strong>A message provided by the RenderableProvider component.</strong>]");
+    }
+}

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

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=890906&r1=890905&r2=890906&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:47:07 2009
@@ -885,4 +885,38 @@
 
         throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
     }
+
+    protected final void assertTextPresent(String... text)
+    {
+        for (String item : text)
+        {
+            if (isTextPresent(item))
+                continue;
+
+            System.err.printf("Text pattern '%s' not found in:\n%s\n\n", item, getHtmlSource());
+
+            throw new AssertionError("Page did not contain '" + item + "'.");
+        }
+    }
+
+    /**
+     * Assets that each string provided is present somewhere in the current document.
+     * 
+     * @param expected
+     *            string expected to be present
+     */
+    protected final void assertSourcePresent(String... expected)
+    {
+        String source = getHtmlSource();
+
+        for (String snippet : expected)
+        {
+            if (source.contains(snippet))
+                continue;
+
+            System.err.printf("Source content '%s' not found in:\n%s\n\n", snippet, source);
+
+            throw new AssertionError("Page did not contain source '" + snippet + "'.");
+        }
+    }
 }