You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/06/19 16:25:52 UTC
svn commit: r548736 - in /tapestry/tapestry5/trunk:
tapestry-core/src/test/conf/
tapestry-core/src/test/java/org/apache/tapestry/integration/
tapestry-spring/src/test/conf/
tapestry-spring/src/test/java/org/apache/tapestry/spring/
tapestry-test/src/mai...
Author: hlship
Date: Tue Jun 19 07:25:50 2007
New Revision: 548736
URL: http://svn.apache.org/viewvc?view=rev&rev=548736
Log:
TAPESTRY-1572: AbstractIntegrationTestSuite should mark setup() and cleanup() as alwaysRun
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-spring/src/test/conf/testng.xml
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringIntegrationTest.java
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry/test/AbstractIntegrationTestSuite.java
tapestry/tapestry5/trunk/tapestry-test/src/site/apt/index.apt
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?view=diff&rev=548736&r1=548735&r2=548736
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/conf/testng.xml Tue Jun 19 07:25:50 2007
@@ -16,7 +16,6 @@
-->
<suite name="Tapestry Core" parallel="tests" thread-count="5" annotations="1.5" verbose="0">
- <parameter name="tapestry.integration-webapp" value="src/test/app1"/>
<test name="Integration Tests">
<packages>
<package name="org.apache.tapestry.integration"/>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=548736&r1=548735&r2=548736
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Tue Jun 19 07:25:50 2007
@@ -34,6 +34,11 @@
{ "integration" })
public class IntegrationTests extends AbstractIntegrationTestSuite
{
+ public IntegrationTests()
+ {
+ super("src/test/app1");
+ }
+
@Test
public void assets() throws Exception
{
Modified: tapestry/tapestry5/trunk/tapestry-spring/src/test/conf/testng.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/conf/testng.xml?view=diff&rev=548736&r1=548735&r2=548736
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/test/conf/testng.xml Tue Jun 19 07:25:50 2007
@@ -17,8 +17,7 @@
<suite name="Tapesty Spring Integration" parallel="false" thread-count="10" annotations="1.5" verbose="2">
<test name="Tapestry Spring Integration">
- <parameter name="tapestry.integration-webapp" value="src/test/webapp"/>
- <packages>
+ <packages>
<package name="org.apache.tapestry.spring"/>
</packages>
</test>
Modified: tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringIntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringIntegrationTest.java?view=diff&rev=548736&r1=548735&r2=548736
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringIntegrationTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringIntegrationTest.java Tue Jun 19 07:25:50 2007
@@ -19,6 +19,11 @@
public class TapestrySpringIntegrationTest extends AbstractIntegrationTestSuite
{
+ public TapestrySpringIntegrationTest()
+ {
+ super("src/test/webapp");
+ }
+
@Test
public void integration_test() throws Exception
{
Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry/test/AbstractIntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry/test/AbstractIntegrationTestSuite.java?view=diff&rev=548736&r1=548735&r2=548736
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry/test/AbstractIntegrationTestSuite.java (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry/test/AbstractIntegrationTestSuite.java Tue Jun 19 07:25:50 2007
@@ -20,7 +20,6 @@
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Parameters;
import com.thoughtworks.selenium.CommandProcessor;
import com.thoughtworks.selenium.DefaultSelenium;
@@ -44,461 +43,484 @@
*/
public abstract class AbstractIntegrationTestSuite extends Assert implements Selenium
{
+ /**
+ * Default directory containing the web application to be tested (this conforms to Maven's
+ * default folder).
+ */
+ public static final String DEFAULT_WEB_APP_ROOT = "src/main/webapp";
- /** 60 seconds */
- public static final String PAGE_LOAD_TIMEOUT = "600000";
+ /** 60 seconds */
+ public static final String PAGE_LOAD_TIMEOUT = "600000";
- /** The port on which the internal copy of Jetty is executed. */
- public static final int JETTY_PORT = 9999;
+ /** The port on which the internal copy of Jetty is executed. */
+ public static final int JETTY_PORT = 9999;
- // This is likely to be a problem, since may want to test with a context path, rather than as
- // root.
- public static final String BASE_URL = format("http://localhost:%d/", JETTY_PORT);
-
- private JettyRunner _jettyRunner;
-
- private Selenium _selenium;
-
- private SeleniumServer _server;
-
- protected final void assertSourcePresent(String... expected)
- {
- String source = _selenium.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 + "'.");
- }
- }
-
- 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(),
- _selenium.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));
- }
-
- protected final void assertTextPresent(String... text)
- {
- for (String item : text)
- {
- if (isTextPresent(item)) return;
-
- System.err.printf("Text pattern '%s' not found in:\n%s\n\n", item, _selenium.getHtmlSource());
-
- throw new AssertionError("Page did not contain '" + item + "'.");
- }
- }
-
- protected final void assertFieldValue(String locator, String expected)
- {
- assertEquals(getValue(locator), expected);
- }
-
- protected final void clickAndWait(String link)
- {
- click(link);
- waitForPageToLoad(PAGE_LOAD_TIMEOUT);
- }
-
- protected final void assertTextSeries(String idFormat, int startIndex, String... values)
- {
- for (int i = 0; i < values.length; i++)
- {
- String id = format(idFormat, startIndex + i);
-
- assertText(id, values[i]);
- }
- }
-
- @AfterClass
- public void cleanup() throws Exception
- {
- _selenium.stop();
- _selenium = null;
-
- _server.stop();
- _server = null;
-
- _jettyRunner.stop();
- _jettyRunner = null;
- }
-
- @Parameters(
- { "tapestry.integration-webapp" })
- @BeforeClass
- public void setup(String webappRoot) throws Exception
- {
- _jettyRunner = new JettyRunner("/", JETTY_PORT, webappRoot);
-
- _server = new SeleniumServer();
-
- _server.start();
-
- CommandProcessor cp = new HttpCommandProcessor("localhost", SeleniumServer.DEFAULT_PORT,
- "*firefox", BASE_URL);
-
- _selenium = new DefaultSelenium(new ErrorReportingCommandProcessor(cp));
-
- _selenium.start();
- }
-
- public void addSelection(String locator, String optionLocator)
- {
- _selenium.addSelection(locator, optionLocator);
- }
-
- public void answerOnNextPrompt(String answer)
- {
- _selenium.answerOnNextPrompt(answer);
- }
-
- public void check(String locator)
- {
- _selenium.check(locator);
- }
-
- public void chooseCancelOnNextConfirmation()
- {
- _selenium.chooseCancelOnNextConfirmation();
- }
-
- public void click(String locator)
- {
- _selenium.click(locator);
- }
-
- public void close()
- {
- _selenium.close();
- }
-
- public void fireEvent(String locator, String eventName)
- {
- _selenium.fireEvent(locator, eventName);
- }
-
- public String getAlert()
- {
- return _selenium.getAlert();
- }
-
- public String[] getAllButtons()
- {
- return _selenium.getAllButtons();
- }
-
- public String[] getAllFields()
- {
- return _selenium.getAllFields();
- }
-
- public String[] getAllLinks()
- {
- return _selenium.getAllLinks();
- }
-
- public String getAttribute(String attributeLocator)
- {
- return _selenium.getAttribute(attributeLocator);
- }
-
- public String getBodyText()
- {
- return _selenium.getBodyText();
- }
-
- public String getConfirmation()
- {
- return _selenium.getConfirmation();
- }
-
- public Number getCursorPosition(String locator)
- {
- return _selenium.getCursorPosition(locator);
- }
-
- public String getEval(String script)
- {
- return _selenium.getEval(script);
- }
-
- public String getExpression(String expression)
- {
- return _selenium.getExpression(expression);
- }
-
- public String getHtmlSource()
- {
- return _selenium.getHtmlSource();
- }
-
- public String getLocation()
- {
- return _selenium.getLocation();
- }
-
- public String getPrompt()
- {
- return _selenium.getPrompt();
- }
-
- public String getSelectedId(String selectLocator)
- {
- return _selenium.getSelectedId(selectLocator);
- }
-
- public String[] getSelectedIds(String selectLocator)
- {
- return _selenium.getSelectedIds(selectLocator);
- }
-
- public String getSelectedIndex(String selectLocator)
- {
- return _selenium.getSelectedIndex(selectLocator);
- }
-
- public String[] getSelectedIndexes(String selectLocator)
- {
- return _selenium.getSelectedIndexes(selectLocator);
- }
-
- public String getSelectedLabel(String selectLocator)
- {
- return _selenium.getSelectedLabel(selectLocator);
- }
-
- public String[] getSelectedLabels(String selectLocator)
- {
- return _selenium.getSelectedLabels(selectLocator);
- }
-
- public String getSelectedValue(String selectLocator)
- {
- return _selenium.getSelectedValue(selectLocator);
- }
-
- public String[] getSelectedValues(String selectLocator)
- {
- return _selenium.getSelectedValues(selectLocator);
- }
-
- public String[] getSelectOptions(String selectLocator)
- {
- return _selenium.getSelectOptions(selectLocator);
- }
-
- public String getTable(String tableCellAddress)
- {
- return _selenium.getTable(tableCellAddress);
- }
-
- public String getText(String locator)
- {
- return _selenium.getText(locator);
- }
-
- public String getTitle()
- {
- return _selenium.getTitle();
- }
-
- public String getValue(String locator)
- {
- return _selenium.getValue(locator);
- }
-
- public void goBack()
- {
- _selenium.goBack();
- }
-
- public boolean isAlertPresent()
- {
- return _selenium.isAlertPresent();
- }
-
- public boolean isChecked(String locator)
- {
- return _selenium.isChecked(locator);
- }
-
- public boolean isConfirmationPresent()
- {
- return _selenium.isConfirmationPresent();
- }
-
- public boolean isEditable(String locator)
- {
- return _selenium.isEditable(locator);
- }
-
- public boolean isElementPresent(String locator)
- {
- return _selenium.isElementPresent(locator);
- }
-
- public boolean isPromptPresent()
- {
- return _selenium.isPromptPresent();
- }
-
- public boolean isSomethingSelected(String selectLocator)
- {
- return _selenium.isSomethingSelected(selectLocator);
- }
-
- public boolean isTextPresent(String pattern)
- {
- return _selenium.isTextPresent(pattern);
- }
-
- public boolean isVisible(String locator)
- {
- return _selenium.isVisible(locator);
- }
-
- public void keyDown(String locator, String keycode)
- {
- _selenium.keyDown(locator, keycode);
- }
-
- public void keyPress(String locator, String keycode)
- {
- _selenium.keyPress(locator, keycode);
- }
-
- public void keyUp(String locator, String keycode)
- {
- _selenium.keyUp(locator, keycode);
- }
-
- public void mouseDown(String locator)
- {
- _selenium.mouseDown(locator);
- }
-
- public void mouseOver(String locator)
- {
- _selenium.mouseOver(locator);
- }
-
- public void open(String url)
- {
- _selenium.open(url);
-
- waitForPageToLoad(PAGE_LOAD_TIMEOUT);
- }
-
- public void refresh()
- {
- _selenium.refresh();
- }
-
- public void removeSelection(String locator, String optionLocator)
- {
- _selenium.removeSelection(locator, optionLocator);
- }
-
- public void select(String selectLocator, String optionLocator)
- {
- _selenium.select(selectLocator, optionLocator);
- }
-
- public void selectWindow(String windowID)
- {
- _selenium.selectWindow(windowID);
- }
-
- public void setContext(String context, String logLevelThreshold)
- {
- _selenium.setContext(context, logLevelThreshold);
- }
-
- public void setCursorPosition(String locator, String position)
- {
- _selenium.setCursorPosition(locator, position);
- }
-
- public void setTimeout(String timeout)
- {
- _selenium.setTimeout(timeout);
- }
-
- public void start()
- {
- _selenium.start();
- }
-
- public void stop()
- {
- _selenium.stop();
- }
-
- public void submit(String formLocator)
- {
- _selenium.submit(formLocator);
- }
-
- public void type(String locator, String value)
- {
- _selenium.type(locator, value);
- }
-
- public void uncheck(String locator)
- {
- _selenium.uncheck(locator);
- }
-
- public void waitForCondition(String script, String timeout)
- {
- _selenium.waitForCondition(script, timeout);
- }
-
- public void waitForPageToLoad(String timeout)
- {
- _selenium.waitForPageToLoad(timeout);
- }
-
- /**
- * Waits the default time for the page to load.
- */
- public void waitForPageToLoad()
- {
- waitForPageToLoad(PAGE_LOAD_TIMEOUT);
- }
-
- public void waitForPopUp(String windowID, String timeout)
- {
- _selenium.waitForPopUp(windowID, timeout);
- }
+ // This is likely to be a problem, since may want to test with a context path, rather than as
+ // root.
+ public static final String BASE_URL = format("http://localhost:%d/", JETTY_PORT);
+
+ private final String _webappRoot;
+
+ private JettyRunner _jettyRunner;
+
+ private Selenium _selenium;
+
+ private SeleniumServer _server;
+
+ /**
+ * Initializes the suite using {@link #DEFAULT_WEB_APP_ROOT}.
+ */
+ public AbstractIntegrationTestSuite()
+ {
+ this(DEFAULT_WEB_APP_ROOT);
+ }
+
+ /**
+ * @param webAppRoot
+ * the directory containing the web application to be tested.
+ */
+ protected AbstractIntegrationTestSuite(String webAppRoot)
+ {
+ _webappRoot = webAppRoot;
+ }
+
+ protected final void assertSourcePresent(String... expected)
+ {
+ String source = _selenium.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 + "'.");
+ }
+ }
+
+ 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(),
+ _selenium.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));
+ }
+
+ protected final void assertTextPresent(String... text)
+ {
+ for (String item : text)
+ {
+ if (isTextPresent(item)) return;
+
+ System.err.printf("Text pattern '%s' not found in:\n%s\n\n", item, _selenium
+ .getHtmlSource());
+
+ throw new AssertionError("Page did not contain '" + item + "'.");
+ }
+ }
+
+ protected final void assertFieldValue(String locator, String expected)
+ {
+ assertEquals(getValue(locator), expected);
+ }
+
+ protected final void clickAndWait(String link)
+ {
+ click(link);
+ waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+ }
+
+ protected final void assertTextSeries(String idFormat, int startIndex, String... values)
+ {
+ for (int i = 0; i < values.length; i++)
+ {
+ String id = format(idFormat, startIndex + i);
+
+ assertText(id, values[i]);
+ }
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void cleanup() throws Exception
+ {
+ _selenium.stop();
+ _selenium = null;
+
+ _server.stop();
+ _server = null;
+
+ _jettyRunner.stop();
+ _jettyRunner = null;
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void setup() throws Exception
+ {
+ _jettyRunner = new JettyRunner("/", JETTY_PORT, _webappRoot);
+
+ _server = new SeleniumServer();
+
+ _server.start();
+
+ CommandProcessor cp = new HttpCommandProcessor("localhost", SeleniumServer.DEFAULT_PORT,
+ "*firefox", BASE_URL);
+
+ _selenium = new DefaultSelenium(new ErrorReportingCommandProcessor(cp));
+
+ _selenium.start();
+ }
+
+ public void addSelection(String locator, String optionLocator)
+ {
+ _selenium.addSelection(locator, optionLocator);
+ }
+
+ public void answerOnNextPrompt(String answer)
+ {
+ _selenium.answerOnNextPrompt(answer);
+ }
+
+ public void check(String locator)
+ {
+ _selenium.check(locator);
+ }
+
+ public void chooseCancelOnNextConfirmation()
+ {
+ _selenium.chooseCancelOnNextConfirmation();
+ }
+
+ public void click(String locator)
+ {
+ _selenium.click(locator);
+ }
+
+ public void close()
+ {
+ _selenium.close();
+ }
+
+ public void fireEvent(String locator, String eventName)
+ {
+ _selenium.fireEvent(locator, eventName);
+ }
+
+ public String getAlert()
+ {
+ return _selenium.getAlert();
+ }
+
+ public String[] getAllButtons()
+ {
+ return _selenium.getAllButtons();
+ }
+
+ public String[] getAllFields()
+ {
+ return _selenium.getAllFields();
+ }
+
+ public String[] getAllLinks()
+ {
+ return _selenium.getAllLinks();
+ }
+
+ public String getAttribute(String attributeLocator)
+ {
+ return _selenium.getAttribute(attributeLocator);
+ }
+
+ public String getBodyText()
+ {
+ return _selenium.getBodyText();
+ }
+
+ public String getConfirmation()
+ {
+ return _selenium.getConfirmation();
+ }
+
+ public Number getCursorPosition(String locator)
+ {
+ return _selenium.getCursorPosition(locator);
+ }
+
+ public String getEval(String script)
+ {
+ return _selenium.getEval(script);
+ }
+
+ public String getExpression(String expression)
+ {
+ return _selenium.getExpression(expression);
+ }
+
+ public String getHtmlSource()
+ {
+ return _selenium.getHtmlSource();
+ }
+
+ public String getLocation()
+ {
+ return _selenium.getLocation();
+ }
+
+ public String getPrompt()
+ {
+ return _selenium.getPrompt();
+ }
+
+ public String getSelectedId(String selectLocator)
+ {
+ return _selenium.getSelectedId(selectLocator);
+ }
+
+ public String[] getSelectedIds(String selectLocator)
+ {
+ return _selenium.getSelectedIds(selectLocator);
+ }
+
+ public String getSelectedIndex(String selectLocator)
+ {
+ return _selenium.getSelectedIndex(selectLocator);
+ }
+
+ public String[] getSelectedIndexes(String selectLocator)
+ {
+ return _selenium.getSelectedIndexes(selectLocator);
+ }
+
+ public String getSelectedLabel(String selectLocator)
+ {
+ return _selenium.getSelectedLabel(selectLocator);
+ }
+
+ public String[] getSelectedLabels(String selectLocator)
+ {
+ return _selenium.getSelectedLabels(selectLocator);
+ }
+
+ public String getSelectedValue(String selectLocator)
+ {
+ return _selenium.getSelectedValue(selectLocator);
+ }
+
+ public String[] getSelectedValues(String selectLocator)
+ {
+ return _selenium.getSelectedValues(selectLocator);
+ }
+
+ public String[] getSelectOptions(String selectLocator)
+ {
+ return _selenium.getSelectOptions(selectLocator);
+ }
+
+ public String getTable(String tableCellAddress)
+ {
+ return _selenium.getTable(tableCellAddress);
+ }
+
+ public String getText(String locator)
+ {
+ return _selenium.getText(locator);
+ }
+
+ public String getTitle()
+ {
+ return _selenium.getTitle();
+ }
+
+ public String getValue(String locator)
+ {
+ return _selenium.getValue(locator);
+ }
+
+ public void goBack()
+ {
+ _selenium.goBack();
+ }
+
+ public boolean isAlertPresent()
+ {
+ return _selenium.isAlertPresent();
+ }
+
+ public boolean isChecked(String locator)
+ {
+ return _selenium.isChecked(locator);
+ }
+
+ public boolean isConfirmationPresent()
+ {
+ return _selenium.isConfirmationPresent();
+ }
+
+ public boolean isEditable(String locator)
+ {
+ return _selenium.isEditable(locator);
+ }
+
+ public boolean isElementPresent(String locator)
+ {
+ return _selenium.isElementPresent(locator);
+ }
+
+ public boolean isPromptPresent()
+ {
+ return _selenium.isPromptPresent();
+ }
+
+ public boolean isSomethingSelected(String selectLocator)
+ {
+ return _selenium.isSomethingSelected(selectLocator);
+ }
+
+ public boolean isTextPresent(String pattern)
+ {
+ return _selenium.isTextPresent(pattern);
+ }
+
+ public boolean isVisible(String locator)
+ {
+ return _selenium.isVisible(locator);
+ }
+
+ public void keyDown(String locator, String keycode)
+ {
+ _selenium.keyDown(locator, keycode);
+ }
+
+ public void keyPress(String locator, String keycode)
+ {
+ _selenium.keyPress(locator, keycode);
+ }
+
+ public void keyUp(String locator, String keycode)
+ {
+ _selenium.keyUp(locator, keycode);
+ }
+
+ public void mouseDown(String locator)
+ {
+ _selenium.mouseDown(locator);
+ }
+
+ public void mouseOver(String locator)
+ {
+ _selenium.mouseOver(locator);
+ }
+
+ public void open(String url)
+ {
+ _selenium.open(url);
+
+ waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+ }
+
+ public void refresh()
+ {
+ _selenium.refresh();
+ }
+
+ public void removeSelection(String locator, String optionLocator)
+ {
+ _selenium.removeSelection(locator, optionLocator);
+ }
+
+ public void select(String selectLocator, String optionLocator)
+ {
+ _selenium.select(selectLocator, optionLocator);
+ }
+
+ public void selectWindow(String windowID)
+ {
+ _selenium.selectWindow(windowID);
+ }
+
+ public void setContext(String context, String logLevelThreshold)
+ {
+ _selenium.setContext(context, logLevelThreshold);
+ }
+
+ public void setCursorPosition(String locator, String position)
+ {
+ _selenium.setCursorPosition(locator, position);
+ }
+
+ public void setTimeout(String timeout)
+ {
+ _selenium.setTimeout(timeout);
+ }
+
+ public void start()
+ {
+ _selenium.start();
+ }
+
+ public void stop()
+ {
+ _selenium.stop();
+ }
+
+ public void submit(String formLocator)
+ {
+ _selenium.submit(formLocator);
+ }
+
+ public void type(String locator, String value)
+ {
+ _selenium.type(locator, value);
+ }
+
+ public void uncheck(String locator)
+ {
+ _selenium.uncheck(locator);
+ }
+
+ public void waitForCondition(String script, String timeout)
+ {
+ _selenium.waitForCondition(script, timeout);
+ }
+
+ public void waitForPageToLoad(String timeout)
+ {
+ _selenium.waitForPageToLoad(timeout);
+ }
+
+ /**
+ * Waits the default time for the page to load.
+ */
+ public void waitForPageToLoad()
+ {
+ waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+ }
+
+ public void waitForPopUp(String windowID, String timeout)
+ {
+ _selenium.waitForPopUp(windowID, timeout);
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-test/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/site/apt/index.apt?view=diff&rev=548736&r1=548735&r2=548736
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/site/apt/index.apt Tue Jun 19 07:25:50 2007
@@ -24,26 +24,14 @@
as a copy of Selenium Server. It also implements the
{{{http://release.openqa.org/selenium-remote-control/0.9.0/doc/java/}Selenium}} interface.
- You must inform the suite about the location of your web application. This is done inside your TestNG configuration file:
+ You must inform the suite about the location of your web application. The default location is
+ <<<src/main/webapp>>> (as this is the default directory for storing a web application when building
+ using Maven). This can be changed by provided a public constructor for your test suite.
-+---+
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="My Tapestry Application" parallel="false" thread-count="10" annotations="1.5" verbose="2">
- <test name="Integration Tests">
- <parameter name="tapestry.integration-webapp" value="src/main/webapp"/>
- <packages>
- <package name="org.example.myapp"/>
- </packages>
- </test>
-</suite>
-+---+
-
- The \<parameter\> element is the necessary part. This will usually be src/main/webapp.
-
- The other part is to create a unit test suite. Here's an example from one of the Tapestry modules:
+ Here's an example from one of the Tapestry modules:
-+---+
+----
package org.apache.tapestry.spring;
import org.apache.tapestry.test.AbstractIntegrationTestSuite;
@@ -51,18 +39,31 @@
public class TapestrySpringIntegrationTest extends AbstractIntegrationTestSuite
{
- @Test
- public void integration_test() throws Exception
- {
- open(BASE_URL);
-
- type("input", "paris in the springtime");
- clickAndWait("//input[@value='Convert']");
+ public TapestrySpringIntegrationTest()
+ {
+ super("src/test/webapp");
+ }
+
+ @Test
+ public void integration_test() throws Exception
+ {
+ open(BASE_URL);
+
+ type("input", "paris in the springtime");
+ clickAndWait("//input[@value='Convert']");
+
+ assertFieldValue("input", "PARIS IN THE SPRINGTIME");
+ }
+
+ @Test
+ public void access_to_spring_context() throws Exception
+ {
+ open(BASE_URL);
- assertFieldValue("input", "PARIS IN THE SPRINGTIME");
- }
+ assertTextPresent("[upcase]");
+ }
}
-+---+
+----
This is a very simple example, and demonstrates a mix of Selenium methods (such as open() and type()) and
methods added by the AbstractIntegrationTestSuite base class (clickAndWait() and assertFieldValue()).
@@ -70,6 +71,6 @@
Of course, a real integration test would contain many methods, and may need to single thread their execution, or
even specify an execution order.
- In addition, the base class extends the normal exception reporting; when a failure occurs inside Selenium server,
+ In addition, the AbstractIntegrationTestSuite base class extends the normal exception reporting provided by Selenium; when a failure occurs inside Selenium server,
a more detailed message, including the current page's HTML source, is reported to System.err.