Author: hlship
Date: Tue Oct 19 18:48:06 2010
New Revision: 1024354
URL: http://svn.apache.org/viewvc?rev=1024354&view=rev
Log:
TAP5-1314: Make the CommandProcessor available to test code
Modified:
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.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=1024354&r1=1024353&r2=1024354&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:48:06 2010
@@ -16,7 +16,6 @@ package org.apache.tapestry5.test;
import java.io.File;
import java.lang.reflect.Method;
-import java.util.Map;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
@@ -28,8 +27,6 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
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;
@@ -153,18 +150,21 @@ public class SeleniumTestCase extends As
String baseURL = String.format("http://localhost:%d%s/", port,
contextPath);
- CommandProcessor cp = new HttpCommandProcessor("localhost",
RemoteControlConfiguration.DEFAULT_PORT,
+ CommandProcessor httpCommandProcessor = new
HttpCommandProcessor("localhost", RemoteControlConfiguration.DEFAULT_PORT,
browserStartCommand, baseURL);
- ErrorReporter errorReporter = new ErrorReporterImpl(cp, testContext);
+ ErrorReporter errorReporter = new
ErrorReporterImpl(httpCommandProcessor, testContext);
- final Selenium selenium = new DefaultSelenium(new
ErrorReportingCommandProcessor(cp, errorReporter));
+ ErrorReportingCommandProcessor commandProcessor = new
ErrorReportingCommandProcessor(httpCommandProcessor, errorReporter);
+
+ final Selenium selenium = new DefaultSelenium(commandProcessor);
selenium.start();
testContext.setAttribute(TapestryTestConstants.BASE_URL_ATTRIBUTE,
baseURL);
testContext.setAttribute(TapestryTestConstants.SELENIUM_ATTRIBUTE,
selenium);
testContext.setAttribute(TapestryTestConstants.ERROR_REPORTER_ATTRIBUTE,
errorReporter);
+
testContext.setAttribute(TapestryTestConstants.COMMAND_PROCESSOR_ATTRIBUTE,
commandProcessor);
testContext.setAttribute(TapestryTestConstants.SHUTDOWN_ATTRIBUTE, new
Runnable()
{
@@ -182,6 +182,7 @@ public class SeleniumTestCase extends As
testContext.removeAttribute(TapestryTestConstants.BASE_URL_ATTRIBUTE);
testContext.removeAttribute(TapestryTestConstants.SELENIUM_ATTRIBUTE);
testContext.removeAttribute(TapestryTestConstants.ERROR_REPORTER_ATTRIBUTE);
+
testContext.removeAttribute(TapestryTestConstants.COMMAND_PROCESSOR_ATTRIBUTE);
testContext.removeAttribute(TapestryTestConstants.SHUTDOWN_ATTRIBUTE);
}
}
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=1024354&r1=1024353&r2=1024354&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 Oct 19 18:48:06 2010
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import org.testng.ITestContext;
import org.testng.xml.XmlTest;
+import com.thoughtworks.selenium.CommandProcessor;
import com.thoughtworks.selenium.Selenium;
public class TapestryTestConstants
@@ -66,6 +67,15 @@ public class TapestryTestConstants
public static final String SHUTDOWN_ATTRIBUTE = "tapestry.shutdown";
/**
+ * The {...@link ITestContext} attribute holding an instance of {...@link
CommandProcessor}, with
+ * enhanced exception reporting control. This allows tests that wish to,
to bypass the {...@link Selenium} interface
+ * and execute commands directly on the Selenium RC server.
+ *
+ * @since 5.2.0
+ */
+ public static final String COMMAND_PROCESSOR_ATTRIBUTE =
"tapestry.command-processor";
+
+ /**
* {...@link ITestContext} attribute holding the application's base URL.
*
* @see SeleniumLauncher#startup(String, String, int, String, ITestContext)
Modified:
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=1024354&r1=1024353&r2=1024354&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-test/src/test/java/org/apache/tapestry5/test/SanityCheckTestSuite.java
Tue Oct 19 18:48:06 2010
@@ -4,7 +4,7 @@
// 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
+// 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,
@@ -14,6 +14,7 @@
package org.apache.tapestry5.test;
+import org.testng.ITestContext;
import org.testng.annotations.Test;
public class SanityCheckTestSuite extends SeleniumTestCase
@@ -41,4 +42,10 @@ public class SanityCheckTestSuite extend
assertEquals(ex.getMessage(), "//h1 was 'Tapestry Test' not
'XYZ'");
}
}
+
+ @Test
+ public void command_processor_available(ITestContext context)
+ {
+
assertNotNull(context.getAttribute(TapestryTestConstants.COMMAND_PROCESSOR_ATTRIBUTE));
+ }
}