tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject svn commit: r918009 - in /tapestry/tapestry5/trunk: tapestry-core/src/test/conf/ tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/ tapestry-test/src/main/java/org/apache/tapestry5/test/
Date Tue, 02 Mar 2010 12:53:14 GMT
Author: uli
Date: Tue Mar  2 12:53:13 2010
New Revision: 918009

URL: http://svn.apache.org/viewvc?rev=918009&view=rev
Log:
TAP5-1038: Rewrite live reload integration tests to use new SeleniumTestCase instead of deprecated
AbstractIntegrationTestSuite

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/ReloadTests.java
    tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java
    tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java
    tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.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=918009&r1=918008&r2=918009&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml Tue Mar  2 12:53:13 2010
@@ -108,6 +108,9 @@
     <packages>
       <package name="org.apache.tapestry5.integration.reload"/>
     </packages>
+    <classes>
+      <class name="org.apache.tapestry5.test.SeleniumLauncher"/>
+    </classes>
   </test>
   
   <test name="PageTester Tests" enabled="true">

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/ReloadTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/ReloadTests.java?rev=918009&r1=918008&r2=918009&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/ReloadTests.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/ReloadTests.java
Tue Mar  2 12:53:13 2010
@@ -1,4 +1,4 @@
-// Copyright 2008, 2009 The Apache Software Foundation
+// Copyright 2008, 2009, 2010 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.
@@ -27,25 +27,28 @@
 import javassist.CtMethod;
 import javassist.NotFoundException;
 
+import org.apache.tapestry5.integration.TapestryCoreTestCase;
 import org.apache.tapestry5.internal.TapestryInternalUtils;
-import org.apache.tapestry5.test.AbstractIntegrationTestSuite;
+import org.apache.tapestry5.test.TapestryTestConstants;
+import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
+import org.testng.xml.XmlTest;
 
 /**
  * Integration tests designed to test Tapestry's ability to dynamically reload component
classes,
- * templates and message
- * catalogs.
+ * templates and message catalogs.
  */
-public class ReloadTests extends AbstractIntegrationTestSuite
+public class ReloadTests extends TapestryCoreTestCase
 {
-    private final File webappDir;
-    private final File webinfDir;
-    private final File classesDir;
-    private final File pagesDir;
+    private File webappDir;
+    private File webinfDir;
+    private File classesDir;
+    private File pagesDir;
 
     private static final String PACKAGE = "org.apache.tapestry5.integration.reload.pages";
-
-    public ReloadTests() throws Exception
+    
+    @BeforeTest(groups = { "beforeStartup" })
+    public void beforeStartup(XmlTest xmlTest) throws Exception
     {
         String uid = Long.toHexString(System.currentTimeMillis());
 
@@ -64,8 +67,9 @@
         copy("Index.1.properties", pagesDir, "Index.properties");
 
         createIndexClass(100);
-
-        setWebappRoot(webappDir.getAbsolutePath());
+        
+        // overwrite the web-app-folder parameter
+        xmlTest.addParameter(TapestryTestConstants.WEB_APP_FOLDER_PARAMETER, webappDir.getAbsolutePath());
 
         System.err.println("Created: " + webappDir);
     }
@@ -123,13 +127,13 @@
     @Test
     public void reload_class() throws Exception
     {
-        open(BASE_URL);
+        openBaseURL();
 
         assertText("property", "100");
 
         createIndexClass(200);
 
-        open(BASE_URL);
+        openBaseURL();
 
         assertText("property", "200");
     }
@@ -137,13 +141,13 @@
     @Test
     public void reload_template() throws Exception
     {
-        open(BASE_URL);
+        openBaseURL();
 
         assertText("template", "Initial Template Version");
 
         copy("Index.2.tml", webappDir, "Index.tml");
 
-        open(BASE_URL);
+        openBaseURL();
 
         assertText("template", "Updated Template Version");
     }
@@ -151,13 +155,13 @@
     @Test
     public void reload_message_catalog() throws Exception
     {
-        open(BASE_URL);
+        openBaseURL();
 
         assertText("message", "Initial Message");
 
         copy("Index.2.properties", pagesDir, "Index.properties");
 
-        open(BASE_URL);
+        openBaseURL();
 
         assertText("message", "Updated Message");
     }

Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java?rev=918009&r1=918008&r2=918009&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java
Tue Mar  2 12:53:13 2010
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2010 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.
@@ -77,7 +77,8 @@
 
     /**
      * Needed inside Maven multi-projects to expand a path relative to the module to a complete
-     * path.
+     * path. If the path already is absolute and points to an existing directory, it will
be used
+     * unchanged.
      * 
      * @param moduleLocalPath
      * @return expanded path
@@ -85,6 +86,12 @@
      */
     protected String expand(String moduleLocalPath)
     {
+        File path = new File(moduleLocalPath);
+
+        // Don't expand if the path provided already exists.
+        if(path.isAbsolute() && path.isDirectory())
+            return moduleLocalPath;
+        
         return new File(TapestryTestConstants.MODULE_BASE_DIR, moduleLocalPath).getPath();
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java?rev=918009&r1=918008&r2=918009&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java
Tue Mar  2 12:53:13 2010
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2010 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.
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry5.test;
 
+import java.util.Map;
+
 import org.openqa.selenium.server.RemoteControlConfiguration;
 import org.openqa.selenium.server.SeleniumServer;
 import org.testng.ITestContext;
@@ -21,6 +23,7 @@
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Optional;
 import org.testng.annotations.Parameters;
+import org.testng.xml.XmlTest;
 
 import com.thoughtworks.selenium.CommandProcessor;
 import com.thoughtworks.selenium.DefaultSelenium;
@@ -108,6 +111,10 @@
      * </tr>
      * </table>
      * 
+     * Tests in the <em>beforeStartup</em> group will be run before the start
of Selenium. This
+     * can be used to programmatically override the above parameter values. For an example
see
+     * {@link org.apache.tapestry5.integration.reload.ReloadTests#beforeStartup}. 
+     * 
      * @param webAppFolder
      * @param contextPath
      * @param port
@@ -120,9 +127,10 @@
     // setup() will invoke
     // shutdown(). Best to be safe!
     @Parameters(
-    { "tapestry.web-app-folder", "tapestry.context-path", "tapestry.port",
-            "tapestry.browser-start-command" })
-    @BeforeTest
+    { TapestryTestConstants.WEB_APP_FOLDER_PARAMETER, TapestryTestConstants.CONTEXT_PATH_PARAMTER,
+            TapestryTestConstants.PORT_PARAMETER,
+            TapestryTestConstants.BROWSER_START_COMMAND_PARAMETER })
+    @BeforeTest(dependsOnGroups = { "beforeStartup" })
     public synchronized void startup(
 
     @Optional("src/main/webapp")
@@ -135,8 +143,24 @@
     int port,
 
     @Optional("*firefox")
-    String browserStartCommand, ITestContext testContext) throws Exception
+    String browserStartCommand, ITestContext testContext, XmlTest xmlTest) throws Exception
     {
+        // If a parameter is overridden in another test method, TestNG won't pass the
+        // updated value but the original (coming from testng.xml or the default).
+        Map<String, String> testParameters = xmlTest.getParameters();
+        
+        if(testParameters.containsKey(TapestryTestConstants.WEB_APP_FOLDER_PARAMETER))
+            webAppFolder = testParameters.get(TapestryTestConstants.WEB_APP_FOLDER_PARAMETER);
+        
+        if(testParameters.containsKey(TapestryTestConstants.CONTEXT_PATH_PARAMTER))
+            contextPath = testParameters.get(TapestryTestConstants.CONTEXT_PATH_PARAMTER);
+        
+        if(testParameters.containsKey(TapestryTestConstants.PORT_PARAMETER))
+            port = Integer.parseInt(testParameters.get(TapestryTestConstants.PORT_PARAMETER));
+        
+        if(testParameters.containsKey(TapestryTestConstants.BROWSER_START_COMMAND_PARAMETER))
+            browserStartCommand = testParameters.get(TapestryTestConstants.BROWSER_START_COMMAND_PARAMETER);
+        
         stopWebServer = launchWebServer(webAppFolder, contextPath, port);
 
         seleniumServer = new SeleniumServer();

Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java?rev=918009&r1=918008&r2=918009&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
Tue Mar  2 12:53:13 2010
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2010 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.
@@ -18,6 +18,7 @@
 import java.lang.reflect.Method;
 
 import org.testng.ITestContext;
+import org.testng.xml.XmlTest;
 
 import com.thoughtworks.selenium.Selenium;
 
@@ -73,4 +74,25 @@
      * (as a {@link Method} instance).
      */
     public static final String CURRENT_TEST_METHOD_ATTRIBUTE = "tapestry.current-test-method";
+    
+    /**
+     * {@link XmlTest} parameter holding an absolute or relative path to a web app
+     * folder.
+     */
+    public static final String WEB_APP_FOLDER_PARAMETER = "tapestry.web-app-folder";
+    
+    /**
+     * {@link XmlTest} parameter holding the context path.
+     */
+    public static final String CONTEXT_PATH_PARAMTER = "tapestry.context-path";
+    
+    /**
+     * {@link XmlTest} parameter holding the web server port.
+     */
+    public static final String PORT_PARAMETER = "tapestry.port";
+    
+    /**
+     * {@link XmlTest} parameter holding the browser command to pass to Selenium.
+     */
+    public static final String BROWSER_START_COMMAND_PARAMETER = "tapestry.browser-start-command";
 }



Mime
View raw message