You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/04/16 07:18:29 UTC
svn commit: r529135 - in
/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink:
AjaxLinkPageToNormalPage.html AjaxLinkPageToNormalPage.java
AjaxLinkTest.java NormalPage.html NormalPage.java
Author: ehillenius
Date: Sun Apr 15 22:18:28 2007
New Revision: 529135
URL: http://svn.apache.org/viewvc?view=rev&rev=529135
Log:
added test for going from an ajax request to a normal request
Added:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.html
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.java
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.html
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.java
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkTest.java
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.html?view=auto&rev=529135
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.html (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.html Sun Apr 15 22:18:28 2007
@@ -0,0 +1,5 @@
+<html>
+<body>
+ <a href="#" wicket:id="ajaxLink">Go</a>
+</body>
+</html>
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.java?view=auto&rev=529135
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.java (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.java Sun Apr 15 22:18:28 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.ajax.markup.html.ajaxLink;
+
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ * Tests going from an ajax request to a normal request.
+ */
+public class AjaxLinkPageToNormalPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ */
+ public AjaxLinkPageToNormalPage()
+ {
+ add(new AjaxLink("ajaxLink")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onClick(AjaxRequestTarget target)
+ {
+ RequestCycle.get().setResponsePage(NormalPage.class);
+ }
+ });
+ }
+}
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkTest.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkTest.java?view=diff&rev=529135&r1=529134&r2=529135
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkTest.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkTest.java Sun Apr 15 22:18:28 2007
@@ -39,27 +39,46 @@
}
/**
- *
- * @throws Exception
+ * If the AjaxLink is attached to an "a" tag the href value should be
+ * replaced with "#" because we use the onclick to execute the javascript.
*/
- public void testRenderHomePage_1() throws Exception
+ public void testAnchorGetsHrefReplaced()
{
- executeTest(AjaxLinkPage.class, "AjaxLinkPageExpectedResult.html");
+ tester.startPage(AjaxLinkPage.class);
+
+ TagTester ajaxLink = tester.getTagByWicketId("ajaxLink");
+
+ // It was a link to google in the markup, but should be replaced to "#"
+ assertTrue(ajaxLink.getAttributeIs("href", "#"));
}
/**
- *
- * @throws Exception
+ * Tests setting the request target to a normal page request from an ajax
+ * request.
*/
- public void testRenderHomePage_2() throws Exception
+ public void testFromAjaxRequestToNormalPage()
{
- executeTest(AjaxLinkWithBorderPage.class, "AjaxLinkWithBorderPageExpectedResult.html");
-
+ tester.startPage(AjaxLinkPageToNormalPage.class);
+ tester.assertRenderedPage(AjaxLinkPageToNormalPage.class);
Page page = tester.getLastRenderedPage();
Component ajaxLink = page.get("ajaxLink");
AbstractAjaxBehavior behavior = (AbstractAjaxBehavior)ajaxLink.getBehaviors().get(0);
+ tester.executeBehavior(behavior);
+ tester.assertRenderedPage(NormalPage.class);
+ }
- executedBehavior(AjaxPage2.class, behavior, "AjaxLinkWithBorderPage-1ExpectedResult.html");
+ /**
+ * Test that the onclick on ajax link has "return !wcall;" at the end. This
+ * ensures that execution is not turned over to the href attribute, which
+ * would then append # to the url.
+ */
+ public void testJavascriptEndsWithReturn()
+ {
+ tester.startPage(AjaxLinkPage.class);
+
+ TagTester ajaxLink = tester.getTagByWicketId("ajaxLink");
+
+ assertTrue(ajaxLink.getAttributeEndsWith("onclick", "return !wcall;"));
}
/**
@@ -77,31 +96,28 @@
executedBehavior(AjaxPage2.class, behavior, "AjaxPage2-1_ExpectedResult.html");
}
+
/**
- * Test that the onclick on ajax link has "return !wcall;" at the end. This
- * ensures that execution is not turned over to the href attribute, which
- * would then append # to the url.
+ *
+ * @throws Exception
*/
- public void testJavascriptEndsWithReturn()
+ public void testRenderHomePage_1() throws Exception
{
- tester.startPage(AjaxLinkPage.class);
-
- TagTester ajaxLink = tester.getTagByWicketId("ajaxLink");
-
- assertTrue(ajaxLink.getAttributeEndsWith("onclick", "return !wcall;"));
+ executeTest(AjaxLinkPage.class, "AjaxLinkPageExpectedResult.html");
}
/**
- * If the AjaxLink is attached to an "a" tag the href value should be
- * replaced with "#" because we use the onclick to execute the javascript.
+ *
+ * @throws Exception
*/
- public void testAnchorGetsHrefReplaced()
+ public void testRenderHomePage_2() throws Exception
{
- tester.startPage(AjaxLinkPage.class);
+ executeTest(AjaxLinkWithBorderPage.class, "AjaxLinkWithBorderPageExpectedResult.html");
- TagTester ajaxLink = tester.getTagByWicketId("ajaxLink");
+ Page page = tester.getLastRenderedPage();
+ Component ajaxLink = page.get("ajaxLink");
+ AbstractAjaxBehavior behavior = (AbstractAjaxBehavior)ajaxLink.getBehaviors().get(0);
- // It was a link to google in the markup, but should be replaced to "#"
- assertTrue(ajaxLink.getAttributeIs("href", "#"));
+ executedBehavior(AjaxPage2.class, behavior, "AjaxLinkWithBorderPage-1ExpectedResult.html");
}
}
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.html?view=auto&rev=529135
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.html (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.html Sun Apr 15 22:18:28 2007
@@ -0,0 +1,7 @@
+<html>
+ <head>
+ </head>
+ <body>
+ Hello. Nothing important here.
+ </body>
+</html>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.java?view=auto&rev=529135
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.java (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/NormalPage.java Sun Apr 15 22:18:28 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.ajax.markup.html.ajaxLink;
+
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ * Simple page used to test redirecting to a normal request from an ajax
+ * request.
+ */
+public class NormalPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ */
+ public NormalPage()
+ {
+ }
+}