Author: frankbille
Date: Sun May 25 13:37:49 2008
New Revision: 660029

URL: http://svn.apache.org/viewvc?rev=660029&view=rev
Log:
Added some unit tests to see if I could reproduce WICKET-1658. But I haven't 
been able to so far, but I might as well push the unit tests.

Added:
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
   (with props)
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
   (with props)
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
   (with props)
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
   (with props)
Modified:
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java?rev=660029&r1=660028&r2=660029&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
 Sun May 25 13:37:49 2008
@@ -41,6 +41,8 @@
 import org.apache.wicket.util.tester.apps_1.MyMockApplication;
 import org.apache.wicket.util.tester.apps_1.SuccessPage;
 import org.apache.wicket.util.tester.apps_1.ViewBook;
+import org.apache.wicket.util.tester.apps_6.LinkPage;
+import org.apache.wicket.util.tester.apps_6.ResultPage;
 
 /**
  * 
@@ -161,6 +163,34 @@
        /**
         * @throws Exception
         */
+       public void testClickLink_setResponsePageClass() throws Exception
+       {
+               tester.startPage(LinkPage.class);
+               tester.assertRenderedPage(LinkPage.class);
+
+               // Set the response page class in the link callback
+               tester.clickLink("linkWithSetResponsePageClass");
+               tester.assertRenderedPage(ResultPage.class);
+               tester.assertLabel("label", "No Parameter");
+       }
+
+       /**
+        * @throws Exception
+        */
+       public void testClickLink_setResponsePage() throws Exception
+       {
+               tester.startPage(LinkPage.class);
+               tester.assertRenderedPage(LinkPage.class);
+
+               // Set the response page instance in the link callback
+               tester.clickLink("linkWithSetResponsePage");
+               tester.assertRenderedPage(ResultPage.class);
+               tester.assertLabel("label", "A special label");
+       }
+
+       /**
+        * @throws Exception
+        */
        public void testPageConstructor() throws Exception
        {
                Book mockBook = new Book("xxId", "xxName");

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html?rev=660029&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
 Sun May 25 13:37:49 2008
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Click Link Test Page</title>
+</head>
+<body>
+<a wicket:id="linkWithSetResponsePageClass">Standard Link which calls 
setResponsePage with page class</a>
+<a wicket:id="linkWithSetResponsePage">Standard Link which calls 
setResponsePage with page instance</a>
+</body>
+</html>
\ No newline at end of file

Propchange: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java?rev=660029&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
 Sun May 25 13:37:49 2008
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.tester.apps_6;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Different kinds of links, to be test the [EMAIL PROTECTED] 
WicketTester#clickLink(String, boolean)} method.
+ * 
+ * Add more links when needed.
+ */
+public class LinkPage extends WebPage<Void>
+{
+       /**
+        * Construct.
+        */
+       public LinkPage()
+       {
+               add(new Link<Void>("linkWithSetResponsePageClass")
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public void onClick()
+                       {
+                               
getRequestCycle().setResponsePage(ResultPage.class);
+                       }
+               });
+
+               add(new Link<Void>("linkWithSetResponsePage")
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public void onClick()
+                       {
+                               getRequestCycle().setResponsePage(new 
ResultPage("A special label"));
+                       }
+               });
+       }
+}

Propchange: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html?rev=660029&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
 Sun May 25 13:37:49 2008
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Insert title here</title>
+</head>
+<body>
+<span wicket:id="label"></span>
+</body>
+</html>
\ No newline at end of file

Propchange: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java?rev=660029&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
 Sun May 25 13:37:49 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.tester.apps_6;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.Model;
+
+/**
+ * Result page
+ */
+public class ResultPage extends WebPage<String>
+{
+       /**
+        * Construct.
+        */
+       public ResultPage()
+       {
+               this("No Parameter");
+       }
+
+       /**
+        * Construct.
+        * 
+        * @param label
+        */
+       public ResultPage(String label)
+       {
+               super(new Model<String>(label));
+
+               add(new Label<String>("label", getModel()));
+       }
+}

Propchange: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to