Author: hlship
Date: Tue Oct 19 18:34:46 2010
New Revision: 1024350
URL: http://svn.apache.org/viewvc?rev=1024350&view=rev
Log:
TAP5-1315: Simplify testSetup() to get all test parameters from the XMLTest
object (rather than via method parameters)
Modified:
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
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=1024350&r1=1024349&r2=1024350&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 Oct 19 18:34:46 2010
@@ -112,36 +112,13 @@ public class SeleniumTestCase extends As
* This method will be invoked in <em>each</em> subclass, but is set up to
only startup the servers once (it checks
* the {...@link ITestContext} to see if the necessary keys are already
present).
*
- * @param webAppFolder
- * @param contextPath
- * @param port
- * @param browserStartCommand
* @param testContext
* Used to share objects between the launcher and the test
suites
* @throws Exception
*/
- @Parameters(
- { TapestryTestConstants.WEB_APP_FOLDER_PARAMETER,
TapestryTestConstants.CONTEXT_PATH_PARAMETER,
- TapestryTestConstants.PORT_PARAMETER,
TapestryTestConstants.SSL_PORT_PARAMETER,
- TapestryTestConstants.BROWSER_START_COMMAND_PARAMETER })
@BeforeTest(dependsOnGroups =
{ "beforeStartup" })
- public void testStartup(
-
- @Optional("src/main/webapp")
- String webAppFolder,
-
- @Optional("")
- String contextPath,
-
- @Optional("9090")
- int port,
-
- @Optional("8443")
- int sslPort,
-
- @Optional("*firefox")
- String browserStartCommand, final ITestContext testContext, XmlTest
xmlTest) throws Exception
+ public void testStartup(final ITestContext testContext, XmlTest xmlTest)
throws Exception
{
// This is not actually necessary, because TestNG will only invoke
this method once
// even when multiple test cases within the test extend from
SeleniumTestCase. TestNG
@@ -154,19 +131,14 @@ public class SeleniumTestCase extends As
// updated value via a parameter, but still passes the original
(coming from testng.xml or the default).
// Seems like a TestNG bug.
- Map<String, String> testParameters = xmlTest.getParameters();
+ // 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_PARAMETER))
- contextPath =
testParameters.get(TapestryTestConstants.CONTEXT_PATH_PARAMETER);
-
- 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);
+ String webAppFolder = getParameter(xmlTest,
TapestryTestConstants.WEB_APP_FOLDER_PARAMETER, "src/main/webapp");
+ String contextPath = getParameter(xmlTest,
TapestryTestConstants.CONTEXT_PATH_PARAMETER, "");
+ int port = Integer.parseInt(getParameter(xmlTest,
TapestryTestConstants.PORT_PARAMETER, "9090"));
+ int sslPort = Integer.parseInt(getParameter(xmlTest,
TapestryTestConstants.SSL_PORT_PARAMETER, "8443"));
+ String browserStartCommand = getParameter(xmlTest,
TapestryTestConstants.BROWSER_START_COMMAND_PARAMETER,
+ "*firefox");
final Runnable stopWebServer = launchWebServer(webAppFolder,
contextPath, port, sslPort);
@@ -216,6 +188,13 @@ public class SeleniumTestCase extends As
});
}
+ private final String getParameter(XmlTest xmlTest, String key, String
defaultValue)
+ {
+ String value = xmlTest.getParameter(key);
+
+ return value != null ? value : defaultValue;
+ }
+
/**
* Like {...@link #testStartup(String, String, int, int, String,
ITestContext, XmlTest)}, this may
* be called multiple times against multiple instances, but only does work
the first time.