You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by da...@apache.org on 2007/11/26 16:01:01 UTC
svn commit: r598301 - in /wicket/trunk/jdk-1.5/wicket-examples: ./
src/test/java/org/apache/wicket/examples/
src/test/java/org/apache/wicket/examples/ajax/prototype/
src/test/java/org/apache/wicket/examples/compref/
src/test/java/org/apache/wicket/exam...
Author: dashorst
Date: Mon Nov 26 07:01:00 2007
New Revision: 598301
URL: http://svn.apache.org/viewvc?rev=598301&view=rev
Log:
Use wicket tester instead of jwebunit, remove jwebunit dependency altogether
Modified:
wicket/trunk/jdk-1.5/wicket-examples/pom.xml
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/WicketWebTestCase.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/ajax/prototype/AjaxTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/compref/ComprefTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/encodings/EncodingTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/forminput/FormInputTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/images/ImagesTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/library/LibraryTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/linkomatic/LinkomaticTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/niceurl/NiceUrlTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/repeater/RepeaterTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/signin2/Signin2Test.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithFPTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithoutFPTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithFPTest.java
wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithoutFPTest.java
Modified: wicket/trunk/jdk-1.5/wicket-examples/pom.xml
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/pom.xml?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/pom.xml (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/pom.xml Mon Nov 26 07:01:00 2007
@@ -85,10 +85,6 @@
<artifactId>httpunit</artifactId>
</dependency>
<dependency>
- <groupId>net.sourceforge.jwebunit</groupId>
- <artifactId>jwebunit-htmlunit-plugin</artifactId>
- </dependency>
- <dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</dependency>
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/WicketWebTestCase.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/WicketWebTestCase.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/WicketWebTestCase.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/WicketWebTestCase.java Mon Nov 26 07:01:00 2007
@@ -17,27 +17,33 @@
package org.apache.wicket.examples;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
-import net.sourceforge.jwebunit.junit.WebTestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Node;
import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebResponse;
/**
- * Add XPATH based validation
+ * WebTestCase for tests that need to run inside Jetty to test for example the wicket filter using
+ * HttpUnit as the testing mechanism.
*
* @author Juergen Donnerstag
+ * @author Martijn Dashorst
*/
-public abstract class WicketWebTestCase extends WebTestCase
+public abstract class WicketWebTestCase extends TestCase
{
private static final Log logger = LogFactory.getLog(WicketWebTestCase.class);
+ /** The base url used to connect the conversation to */
+ private String baseUrl = "http://localhost:8098/";
+
+ /** The web conversation that keeps track of our requests. */
+ private WebConversation conversation;
+
/**
* Suite method.
*
@@ -75,95 +81,27 @@
*/
public WicketWebTestCase()
{
- super();
}
/**
- * @see junit.framework.TestCase#setUp()
+ * @param base
*/
- public void setUp() throws Exception
+ public void setBaseUrl(String base)
{
- getTestContext().setBaseUrl("http://localhost:8098/wicket-examples");
+ baseUrl = base;
}
/**
- * Select a single node based on the xpath expression
- *
- * @param xpath
- * @return Node
- * @throws Exception
- */
- public Node selectSingleNode(final String xpath) throws Exception
- {
- final String resp = this.getDialog().getPageText();
- final Document doc = DocumentHelper.parseText(resp);
- // String xml = doc.asXML();
- // System.out.print(xml);
- final Node node = doc.selectSingleNode(xpath);
- return node;
- }
-
- /**
- * Assert the value returned by the xpath matches 'assertValue'
- *
- * @param xpath
- * @param assertValue
- * @throws Exception
- */
- public void assertXPath(final String xpath, final String assertValue) throws Exception
- {
- final Node node = selectSingleNode(xpath);
- assertNotNull("Node not found: " + xpath, node);
- final String value;
- if (node instanceof Attribute)
- {
- value = ((Attribute)node).getValue();
- }
- else
- {
- value = node.getText();
- }
-
- assertTrue("xpath found, but values don't match: '" + value + "' != '" + assertValue + "'",
- value.matches(".*" + assertValue + ".*"));
- }
-
- /**
- * Assert the tag body of the tag identified by wicket:id="wicketId" matches 'assertValue'
- *
- * @param wicketId
- * @param assertValue
- * @throws Exception
- */
- public void assertWicketIdTagText(final String wicketId, final String assertValue)
- throws Exception
- {
- assertXPath("//*[@wicket:id='" + wicketId + "']", assertValue);
- }
-
- /**
- * Assert no node matching the xpath exists
- *
- * @param xpath
- * @throws Exception
+ * @see junit.framework.TestCase#setUp()
*/
- public void assertXpathNodeNotPresent(final String xpath) throws Exception
+ @Override
+ public void setUp() throws Exception
{
- final Node node = selectSingleNode(xpath);
- assertNull(node);
+ conversation = new WebConversation();
}
- /**
- * Assert the node matching the xpath exists
- *
- * @param xpath
- * @return Node
- * @throws Exception
- */
- public Node assertXpathNodePresent(final String xpath) throws Exception
+ protected WebResponse beginAt(String part) throws Exception
{
- final Node node = selectSingleNode(xpath);
- assertNotNull(node);
- return node;
+ return conversation.getResponse(baseUrl + part);
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/ajax/prototype/AjaxTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/ajax/prototype/AjaxTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/ajax/prototype/AjaxTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/ajax/prototype/AjaxTest.java Mon Nov 26 07:01:00 2007
@@ -16,45 +16,32 @@
*/
package org.apache.wicket.examples.ajax.prototype;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class AjaxTest extends WicketWebTestCase
+public class AjaxTest extends TestCase
{
/**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(AjaxTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public AjaxTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*
* @throws Exception
*/
public void test_1() throws Exception
{
- beginAt("/prototype");
- // this.dumpResponse(System.out);
- assertTitleEquals("Wicket Examples - Prototype.js / component render");
- assertTextInElement("counter", "0");
+ WicketTester tester = new WicketTester();
+ tester.getApplication().getMarkupSettings().setStripWicketTags(false);
+ tester.startPage(Index.class);
+ tester.assertContains("Wicket Examples - Prototype.js / component render");
+ tester.assertModelValue("counter", 0);
+ tester.executeListener(tester.getComponentFromLastRenderedPage("link"));
+ tester.assertModelValue("counter", 1);
+ tester.assertResultPage("<span wicket:id=\"counter\">1</span>");
+ tester.executeListener(tester.getComponentFromLastRenderedPage("link"));
+ tester.assertModelValue("counter", 2);
+ tester.assertResultPage("<span wicket:id=\"counter\">2</span>");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/compref/ComprefTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/compref/ComprefTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/compref/ComprefTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/compref/ComprefTest.java Mon Nov 26 07:01:00 2007
@@ -16,43 +16,25 @@
*/
package org.apache.wicket.examples.compref;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class ComprefTest extends WicketWebTestCase
+public class ComprefTest extends TestCase
{
/**
- * @return Test
- */
- public static Test suite()
- {
- return suite(ComprefTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public ComprefTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*
* @throws Exception
*/
public void test_1() throws Exception
{
- beginAt("/compref");
- // this.dumpResponse(System.out);
- assertTitleEquals("Wicket Examples - component reference");
+ WicketTester tester = new WicketTester();
+ tester.startPage(Index.class);
+
+ tester.assertContains("Wicket Examples - component reference");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/encodings/EncodingTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/encodings/EncodingTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/encodings/EncodingTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/encodings/EncodingTest.java Mon Nov 26 07:01:00 2007
@@ -16,44 +16,25 @@
*/
package org.apache.wicket.examples.encodings;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class EncodingTest extends WicketWebTestCase
+public class EncodingTest extends TestCase
{
/**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(EncodingTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public EncodingTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*
* @throws Exception
*/
public void test_1() throws Exception
{
- beginAt("/encodings");
- assertTitleEquals("Wicket Examples - encodings");
- assertTextPresent("Hello world! Test: ���");
+ WicketTester tester = new WicketTester();
+ tester.startPage(Home.class);
+ tester.assertContains("Wicket Examples - encodings");
+ tester.assertContains("Hello world! Test: ���");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/forminput/FormInputTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/forminput/FormInputTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/forminput/FormInputTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/forminput/FormInputTest.java Mon Nov 26 07:01:00 2007
@@ -16,41 +16,23 @@
*/
package org.apache.wicket.examples.forminput;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class FormInputTest extends WicketWebTestCase
+public class FormInputTest extends TestCase
{
/**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(FormInputTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public FormInputTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*/
public void test_1()
{
- beginAt("/forminput");
- assertTitleEquals("Wicket Examples - forminput");
+ WicketTester tester = new WicketTester();
+ tester.startPage(FormInput.class);
+
+ tester.assertContains("Wicket Examples - forminput");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/images/ImagesTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/images/ImagesTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/images/ImagesTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/images/ImagesTest.java Mon Nov 26 07:01:00 2007
@@ -16,43 +16,24 @@
*/
package org.apache.wicket.examples.images;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class ImagesTest extends WicketWebTestCase
+public class ImagesTest extends TestCase
{
/**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(ImagesTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public ImagesTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*
* @throws Exception
*/
- public void testHelloWorld() throws Exception
+ public void testImages() throws Exception
{
- beginAt("/images");
- assertTitleEquals("Wicket Examples - images");
+ WicketTester tester = new WicketTester(new ImagesApplication());
+ tester.startPage(Home.class);
+ tester.assertContains("Wicket Examples - images");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/library/LibraryTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/library/LibraryTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/library/LibraryTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/library/LibraryTest.java Mon Nov 26 07:01:00 2007
@@ -16,51 +16,35 @@
*/
package org.apache.wicket.examples.library;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class LibraryTest extends WicketWebTestCase
+public class LibraryTest extends TestCase
{
/**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(LibraryTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public LibraryTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*
* @throws Exception
*/
public void test_1() throws Exception
{
- beginAt("/library");
- assertTitleEquals("Wicket Examples - library");
- assertTextPresent("Username and password are both");
+ WicketTester tester = new WicketTester(new LibraryApplication());
+ tester.startPage(SignIn.class);
+ tester.assertContains("Wicket Examples - library");
+ tester.assertContains("Username and password are both");
+
+ FormTester formTester = tester.newFormTester("signInPanel:signInForm");
+ formTester.setValue("username", "wicket");
+ formTester.setValue("password", "wicket");
+ formTester.submit();
- this.setFormElement("username", "wicket");
- this.setFormElement("password", "wicket");
- this.submit("submit");
- // this.dumpResponse(System.out);
- assertTitleEquals("Wicket Examples - library");
- assertTextPresent("Effective Java (Joshua Bloch)");
+ tester.assertRenderedPage(Home.class);
+ tester.assertContains("Wicket Examples - library");
+ tester.assertLabel("books:0:author", "Effective Java (Joshua Bloch)");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/linkomatic/LinkomaticTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/linkomatic/LinkomaticTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/linkomatic/LinkomaticTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/linkomatic/LinkomaticTest.java Mon Nov 26 07:01:00 2007
@@ -16,41 +16,22 @@
*/
package org.apache.wicket.examples.linkomatic;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class LinkomaticTest extends WicketWebTestCase
+public class LinkomaticTest extends TestCase
{
/**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(LinkomaticTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public LinkomaticTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*/
- public void testHelloWorld()
+ public void testLinkomatic()
{
- beginAt("/linkomatic");
- assertTitleEquals("Wicket Examples - linkomatic");
+ WicketTester tester = new WicketTester();
+ tester.startPage(Home.class);
+ tester.assertContains("Wicket Examples - linkomatic");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/niceurl/NiceUrlTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/niceurl/NiceUrlTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/niceurl/NiceUrlTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/niceurl/NiceUrlTest.java Mon Nov 26 07:01:00 2007
@@ -16,33 +16,37 @@
*/
package org.apache.wicket.examples.niceurl;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class NiceUrlTest extends WicketWebTestCase
+public class NiceUrlTest extends TestCase
{
+ private WicketTester tester;
+
/**
- *
- * @return Test
+ * @see junit.framework.TestCase#setUp()
*/
- public static Test suite()
+ @Override
+ protected void setUp() throws Exception
{
- return suite(NiceUrlTest.class);
+ super.setUp();
+ tester = new WicketTester(new NiceUrlApplication());
+ tester.startPage(Home.class);
}
/**
- * Construct.
+ * Test page.
*
- * @param name
- * name of test
+ * @throws Exception
*/
- public NiceUrlTest(String name)
+ public void testHomePage() throws Exception
{
- super(name);
+ tester.assertContains("Wicket Examples - niceurl");
+ tester.assertContains("This example displays how you can work with 'nice' urls for bookmarkable pages.");
}
/**
@@ -50,33 +54,80 @@
*
* @throws Exception
*/
- public void testHelloWorld() throws Exception
+ public void testPage1() throws Exception
{
- beginAt("/niceurl");
- assertTitleEquals("Wicket Examples - niceurl");
- assertTextPresent("This example displays how you can work with 'nice' urls for bookmarkable pages.");
+ tester.clickLink("page1Link");
+ tester.assertRenderedPage(Page1.class);
+ tester.clickLink("homeLink");
+ tester.assertRenderedPage(Home.class);
+ }
- this.clickLinkWithText("Click this BookmarkablePageLink to go to Page 1");
- assertTitleEquals("Wicket Examples - niceurl");
+ /**
+ * Test page.
+ *
+ * @throws Exception
+ */
+ public void testPage2() throws Exception
+ {
+ tester.clickLink("page2Link");
+ tester.assertRenderedPage(Page2.class);
+ tester.clickLink("refreshLink");
+ tester.assertRenderedPage(Page2.class);
+ tester.clickLink("homeLink");
+ tester.assertRenderedPage(Home.class);
+ }
- this.clickLinkWithText("[go back]");
- assertTitleEquals("Wicket Examples - niceurl");
- this.clickLinkWithText("Click this BookmarkablePageLink to go to Page 2");
- assertTitleEquals("Wicket Examples - niceurl");
+ /**
+ * Test page.
+ *
+ * @throws Exception
+ */
+ public void testPage2QP() throws Exception
+ {
+ tester.clickLink("page2LinkQP");
+ tester.assertRenderedPage(Page2QP.class);
+ tester.clickLink("refreshLink");
+ tester.assertRenderedPage(Page2QP.class);
+ tester.clickLink("homeLink");
+ tester.assertRenderedPage(Home.class);
+ }
- this.clickLinkWithText("[go back]");
- assertTitleEquals("Wicket Examples - niceurl");
- this.clickLinkWithText("Click this BookmarkablePageLink to go to Page 3");
- assertTitleEquals("Wicket Examples - niceurl");
+ /**
+ * Test page.
+ *
+ * @throws Exception
+ */
+ public void testPage3() throws Exception
+ {
+ tester.clickLink("page3Link");
+ tester.assertRenderedPage(org.apache.wicket.examples.niceurl.mounted.Page3.class);
+ tester.clickLink("homeLink");
+ tester.assertRenderedPage(Home.class);
+ }
- this.clickLinkWithText("[go back]");
- assertTitleEquals("Wicket Examples - niceurl");
- this.clickLinkWithText("Click this BookmarkablePageLink to go to Page 4");
- assertTitleEquals("Wicket Examples - niceurl");
+ /**
+ * Test page.
+ *
+ * @throws Exception
+ */
+ public void testPage4() throws Exception
+ {
+ tester.clickLink("page4Link");
+ tester.assertRenderedPage(org.apache.wicket.examples.niceurl.mounted.Page4.class);
+ tester.clickLink("homeLink");
+ tester.assertRenderedPage(Home.class);
+ }
- this.clickLinkWithText("[go back]");
- assertTitleEquals("Wicket Examples - niceurl");
- this.clickLinkWithText("Click this BookmarkablePageLink to go to Page 5");
- assertTitleEquals("Wicket Examples - niceurl");
+ /**
+ * Test page.
+ *
+ * @throws Exception
+ */
+ public void testPage5() throws Exception
+ {
+ tester.clickLink("page5Link");
+ tester.assertRenderedPage(org.apache.wicket.examples.niceurl.mounted.Page5.class);
+ tester.clickLink("homeLink");
+ tester.assertRenderedPage(Home.class);
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/repeater/RepeaterTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/repeater/RepeaterTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/repeater/RepeaterTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/repeater/RepeaterTest.java Mon Nov 26 07:01:00 2007
@@ -16,102 +16,43 @@
*/
package org.apache.wicket.examples.repeater;
-import org.apache.wicket.examples.WicketWebTestCase;
+import junit.framework.TestCase;
-import junit.framework.Test;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class RepeaterTest extends WicketWebTestCase
+public class RepeaterTest extends TestCase
{
/**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(RepeaterTest.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public RepeaterTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*
* @throws Exception
*/
public void testHelloWorld() throws Exception
{
- beginAt("/repeater");
- assertTitleEquals("Wicket Examples - repeater views");
-
- this.clickLinkWithText("OrderedRepeatingView Example - basic example of a repeater view");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
-
- this.clickLinkWithText("[go back]");
- this
- .clickLinkWithText("RefreshingView Example - basic view that recreates its items every request");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
-
- this.clickLinkWithText("[go back]");
- this.clickLinkWithText("Simple DataView Example - simple example of a dataview");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
-
- this.clickLinkWithText("[go back]");
- this
- .clickLinkWithText("Paging DataView Example - builds on previous to demonstrate paging and page navigation");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
-
- this.clickLinkWithText("[go back]");
- this
- .clickLinkWithText("Sorting DataView Example - builds on previous to demonstrate sorting");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
-
- this.clickLinkWithText("[go back]");
- this
- .clickLinkWithText("DataView and optimized item removal - demonstrates a dataview with a different IItemReuseStrategy implementation");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
-
- this.clickLinkWithText("[go back]");
- this
- .clickLinkWithText("DataGridView Example - a view that generates grids where rows are representing by items of the data provider and columns are represented by an array of ICellPopulators objects");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
-
- this.clickLinkWithText("[go back]");
- this
- .clickLinkWithText("DataTable Example - demonstrates data table component that wraps dataview to offer easy paging and sorting");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
+ WicketTester tester = new WicketTester(new RepeaterApplication());
+ tester.startPage(Index.class);
+ tester.assertContains("Wicket Examples - repeater views");
+
+ checkPage(tester, RepeatingPage.class);
+ checkPage(tester, RefreshingPage.class);
+ checkPage(tester, FormPage.class);
+ checkPage(tester, SimplePage.class);
+ checkPage(tester, PagingPage.class);
+ checkPage(tester, SortingPage.class);
+ checkPage(tester, OIRPage.class);
+ checkPage(tester, DataGridPage.class);
+ checkPage(tester, GridViewPage.class);
+ checkPage(tester, AjaxDataTablePage.class);
+ }
- this.clickLinkWithText("[go back]");
- this.clickLinkWithText("GridView Example - demonstrates a grid view");
- assertTitleEquals("Wicket Examples - repeater views");
- assertTextPresent("Selected Contact: ");
- assertTextPresent("No Contact Selected");
+ private void checkPage(WicketTester tester, Class page)
+ {
+ tester.startPage(page);
+ tester.assertContains("Wicket Examples - repeater views");
+ tester.assertContains("Selected Contact: ");
+ tester.assertContains("No Contact Selected");
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/signin2/Signin2Test.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/signin2/Signin2Test.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/signin2/Signin2Test.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/signin2/Signin2Test.java Mon Nov 26 07:01:00 2007
@@ -16,56 +16,39 @@
*/
package org.apache.wicket.examples.signin2;
-import junit.framework.Test;
+import java.util.Collection;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.wicket.examples.WicketWebTestCase;
+import javax.servlet.http.Cookie;
+
+import junit.framework.TestCase;
+
+import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
/**
* jWebUnit test for Hello World.
*/
-public class Signin2Test extends WicketWebTestCase
+public class Signin2Test extends TestCase
{
- private final static Log log = LogFactory.getLog(Signin2Test.class);
-
- /**
- *
- * @return Test
- */
- public static Test suite()
- {
- return suite(Signin2Test.class);
- }
-
- /**
- * Construct.
- *
- * @param name
- * name of test
- */
- public Signin2Test(String name)
- {
- super(name);
- }
-
/**
* Test page.
*/
public void testSignIn2()
{
- beginAt("/signin2");
- assertTitleEquals("Wicket Examples - signin2");
+ WicketTester tester = new WicketTester(new SignIn2Application());
+
+ tester.startPage(Home.class);
- this.setFormElement("username", "wicket");
- this.setFormElement("password", "wicket");
- this.checkCheckbox("rememberMeRow:rememberMe");
- log.debug("Submit Login screen");
- this.submit("submit");
+ tester.assertRenderedPage(SignIn2.class);
+
+ FormTester formTester = tester.newFormTester("signInPanel:signInForm");
+ formTester.setValue("username", "wicket");
+ formTester.setValue("password", "wicket");
+ formTester.setValue("rememberMeRow:rememberMe", "true");
+ formTester.submit();
+ tester.assertRenderedPage(Home.class);
- // this.dumpResponse(System.err);
- assertTitleEquals("Wicket Examples - signin2");
// a) With wicket submitting a form will result in a temporary redirect,
// with the redirect setting the Cookie.
// b) jWebUnits Cookie test methods are all using the http response
@@ -81,22 +64,20 @@
// this.dumpCookies(System.err);
// this.assertCookiePresent("signInPanel.signInForm.username");
// this.assertCookiePresent("signInPanel.signInForm.password");
- log.debug("Click 'Sign Out'");
- this.clickLinkWithText("Sign Out");
- assertTitleEquals("Wicket Examples - signin2");
- log.debug("Click 'Home'");
- this.clickLinkWithText("Home");
- /*
- * jWebUnit is missing assertCookieNotPresent() try { // jWebUnit does not offer an
- * assertCookieNotPresent this.assertCookiePresent("signInPanel.signInForm.username");
- * assertTrue("Should have thrown an excpetion", false); } catch (AssertionFailedError ex) { ; //
- * ok }
- *
- * try { // jWebUnit does not offer an assertCookieNotPresent
- * this.assertCookiePresent("signInPanel.signInForm.password"); assertTrue("Should have
- * thrown an excpetion", false); } catch (AssertionFailedError ex) { ; // ok }
- */
- assertTitleEquals("Wicket Examples - signin2");
+ Collection<Cookie> cookies = tester.getServletResponse().getCookies();
+ for (Cookie cookie : cookies)
+ {
+ if ("signInPanel.signInForm.username".equals(cookie.getName()))
+ {
+ assertEquals("wicket", cookie.getValue());
+ }
+ }
+
+ tester.startPage(SignOut.class);
+ tester.assertRenderedPage(SignOut.class);
+
+ tester.startPage(Home.class);
+ tester.assertRenderedPage(SignIn2.class);
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithFPTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithFPTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithFPTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithFPTest.java Mon Nov 26 07:01:00 2007
@@ -19,6 +19,7 @@
import junit.framework.Test;
import org.apache.wicket.examples.JettyTestCaseDecorator;
+import org.apache.wicket.examples.WicketWebTestCase;
/**
@@ -30,17 +31,11 @@
/**
* @see junit.framework.TestCase#setUp()
*/
+ @Override
public void setUp() throws Exception
{
- getTestContext().setBaseUrl("http://localhost:8098/somecontext");
- }
-
- /**
- * @param name
- */
- public WithCPWithFPTest(String name)
- {
- super(name);
+ setBaseUrl("http://localhost:8098/somecontext");
+ super.setUp();
}
/**
@@ -49,7 +44,7 @@
*/
public static Test suite()
{
- JettyTestCaseDecorator deco = (JettyTestCaseDecorator)suite(WithCPWithFPTest.class);
+ JettyTestCaseDecorator deco = (JettyTestCaseDecorator)WicketWebTestCase.suite(WithCPWithFPTest.class);
deco.setContextPath("/somecontext");
String basedir = System.getProperty("basedir");
String path = "";
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithoutFPTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithoutFPTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithoutFPTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithoutFPTest.java Mon Nov 26 07:01:00 2007
@@ -25,21 +25,14 @@
*/
public class WithCPWithoutFPTest extends WithoutCPWithoutFPTest
{
-
/**
* @see junit.framework.TestCase#setUp()
*/
+ @Override
public void setUp() throws Exception
{
- getTestContext().setBaseUrl("http://localhost:8098/somecontext");
- }
-
- /**
- * @param name
- */
- public WithCPWithoutFPTest(String name)
- {
- super(name);
+ setBaseUrl("http://localhost:8098/somecontext");
+ super.setUp();
}
/**
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithFPTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithFPTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithFPTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithFPTest.java Mon Nov 26 07:01:00 2007
@@ -16,32 +16,25 @@
*/
package org.apache.wicket.filtertest;
+import junit.framework.Test;
+
import org.apache.wicket.examples.JettyTestCaseDecorator;
import org.apache.wicket.examples.WicketWebTestCase;
-import junit.framework.Test;
+import com.meterware.httpunit.WebResponse;
/**
* jWebUnit test for Hello World.
*/
public class WithoutCPWithFPTest extends WicketWebTestCase
{
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- getTestContext().setBaseUrl("http://localhost:8098/");
- }
-
/**
*
* @return Test
*/
public static Test suite()
{
- JettyTestCaseDecorator deco = (JettyTestCaseDecorator)suite(WithoutCPWithFPTest.class);
+ JettyTestCaseDecorator deco = (JettyTestCaseDecorator)WicketWebTestCase.suite(WithoutCPWithFPTest.class);
deco.setContextPath("");
String basedir = System.getProperty("basedir");
String path = "";
@@ -53,34 +46,22 @@
}
/**
- * Construct.
- *
- * @param name
- * name of test
- */
- public WithoutCPWithFPTest(String name)
- {
- super(name);
- }
-
- /**
* Test page.
*
* @throws Exception
*/
public void testHelloWorld() throws Exception
{
- beginAt("/filtertest/hello/message/Test");
- dumpHtml();
- assertTitleEquals("Wicket Examples - helloworld");
- assertTextInElement("message", "Message is: 'Test'");
+ WebResponse response = beginAt("/filtertest/hello/message/Test");
+ assertEquals("Wicket Examples - helloworld", response.getTitle());
+ assertEquals("Message is: 'Test'", response.getElementWithID("message").getText());
}
public void testWithSlash() throws Exception
{
- beginAt("/filtertest/hello/message/Test%2FWith%20a%20Slash");
- dumpHtml();
- assertTitleEquals("Wicket Examples - helloworld");
- assertTextInElement("message", "Message is: 'Test/With a Slash'");
+ WebResponse response = beginAt("/filtertest/hello/message/Test%2FWith%20a%20Slash");
+ assertEquals("Wicket Examples - helloworld", response.getTitle());
+ assertEquals("Message is: 'Test/With a Slash'", response.getElementWithID("message")
+ .getText());
}
}
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithoutFPTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithoutFPTest.java?rev=598301&r1=598300&r2=598301&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithoutFPTest.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithoutFPTest.java Mon Nov 26 07:01:00 2007
@@ -16,25 +16,18 @@
*/
package org.apache.wicket.filtertest;
+import junit.framework.Test;
+
import org.apache.wicket.examples.JettyTestCaseDecorator;
import org.apache.wicket.examples.WicketWebTestCase;
-import junit.framework.Test;
+import com.meterware.httpunit.WebResponse;
/**
* jWebUnit test for Hello World.
*/
public class WithoutCPWithoutFPTest extends WicketWebTestCase
{
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- getTestContext().setBaseUrl("http://localhost:8098/");
- }
-
/**
*
* @return Test
@@ -53,14 +46,15 @@
}
/**
- * Construct.
+ * Test page.
*
- * @param name
- * name of test
+ * @throws Exception
*/
- public WithoutCPWithoutFPTest(String name)
+ public void testHelloWorld() throws Exception
{
- super(name);
+ WebResponse response = beginAt("/hello/message/Test");
+ assertEquals("Wicket Examples - helloworld", response.getTitle());
+ assertEquals("Message is: 'Test'", response.getElementWithID("message").getText());
}
/**
@@ -68,19 +62,11 @@
*
* @throws Exception
*/
- public void testHelloWorld() throws Exception
- {
- beginAt("/hello/message/Test");
- dumpHtml();
- assertTitleEquals("Wicket Examples - helloworld");
- assertTextInElement("message", "Message is: 'Test'");
- }
-
public void testWithSlash() throws Exception
{
- beginAt("/hello/message/Test%2FWith%20a%20Slash");
- dumpHtml();
- assertTitleEquals("Wicket Examples - helloworld");
- assertTextInElement("message", "Message is: 'Test/With a Slash'");
+ WebResponse response = beginAt("/hello/message/Test%2FWith%20a%20Slash");
+ assertEquals("Wicket Examples - helloworld", response.getTitle());
+ assertEquals("Message is: 'Test/With a Slash'", response.getElementWithID("message")
+ .getText());
}
}