Author: jdonnerstag
Date: Mon Jun  1 19:37:46 2009
New Revision: 780797

URL: http://svn.apache.org/viewvc?rev=780797&view=rev
Log:
fixed and added test case: wicketTester.executeAjaxEvent(combo, "onchange"); 
works with 1.4-rc1 but not anymore with 1.4-rc2
Issue: WICKET-2261

Added:
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.html
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.html
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.html
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.java
Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WebResponseExceptionsTest.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java?rev=780797&r1=780796&r2=780797&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
 Mon Jun  1 19:37:46 2009
@@ -544,7 +544,22 @@
                                cycle = createRequestCycle();
                                cycle.request();
                        }
+                       else
+                       {
+                               String url = 
httpResponse.getHeader("Ajax-Location");
+                               if (url != null)
+                               {
+                                       MockHttpServletRequest newHttpRequest = 
new MockHttpServletRequest(application,
+                                               servletSession, 
application.getServletContext());
+                                       
newHttpRequest.setRequestToRedirectString(url);
+                                       wicketRequest = 
application.newWebRequest(newHttpRequest);
+
+                                       cycle = createRequestCycle();
+                                       cycle.request();
+                               }
+                       }
                }
+
                lastRenderedPage = generateLastRenderedPage(cycle);
 
                Session.set(getWicketSession());

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.html?rev=780797&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.html 
(added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.html 
Mon Jun  1 19:37:46 2009
@@ -0,0 +1,16 @@
+<html>
+    <head>
+        <title>Wicket Quickstart Archetype Homepage</title>
+    </head>
+    <body>
+        <strong>Wicket Quickstart Archetype Homepage</strong>
+        <br/><br/>
+        <span wicket:id="message">message will be here</span>
+        
+        <form wicket:id="form">
+          <select wicket:id="select"></select>
+        </form>
+        
+    </body>
+</html>
+

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.java?rev=780797&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.java 
(added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/HomePage.java 
Mon Jun  1 19:37:46 2009
@@ -0,0 +1,68 @@
+/*
+ * 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.form;
+
+import java.util.Collections;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.model.Model;
+
+/**
+ * Homepage
+ */
+public class HomePage extends WebPage
+{
+       private static final long serialVersionUID = 1L;
+
+       int rows = 1;
+
+       /**
+        */
+       public HomePage()
+       {
+               this(true, 0);
+       }
+
+       /**
+        * @param enableInputField
+        * @param newPageId
+        */
+       @SuppressWarnings("serial")
+       public HomePage(boolean enableInputField, int newPageId)
+       {
+               add(new Label("message",
+                       "If you see this message wicket is properly configured 
and running"));
+
+               Form<Void> form = new Form<Void>("form");
+               // WebMarkupContainer form = new WebMarkupContainer("form"); 
Both ways do not work
+               add(form);
+               DropDownChoice<Void> select;
+               form.add(select = new DropDownChoice<Void>("select", new 
Model(), Collections.EMPTY_LIST));
+               select.add(new OnChangeAjaxBehavior()
+               {
+                       @Override
+                       protected void onUpdate(AjaxRequestTarget target)
+                       {
+                               setResponsePage(SecondPage.class);
+                       }
+               });
+       }
+}

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTest.java?rev=780797&r1=780796&r2=780797&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTest.java
 Mon Jun  1 19:37:46 2009
@@ -57,4 +57,24 @@
                        "OnChangeAjaxBehaviorTestPage_expected.html");
        }
 
+       /**
+        * 
+        */
+       public void testAjaxSubmitWhileAnotherButtonIsNotVisible()
+       {
+               // start and render the test page
+               tester.startPage(HomePage.class);
+               // assert rendered page class
+               tester.assertRenderedPage(HomePage.class);
+               // assert rendered label component
+               tester.assertLabel("message",
+                       "If you see this message wicket is properly configured 
and running");
+
+               tester.executeAjaxEvent("form:select", "onchange");
+
+               // assert rendered page class
+               tester.assertRenderedPage(ThirdPage.class);
+               tester.assertLabel("label", "Hello world.");
+               tester.assertContains("And just plain text");
+       }
 }

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.html?rev=780797&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.html 
(added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.html 
Mon Jun  1 19:37:46 2009
@@ -0,0 +1,8 @@
+<html>
+    <head>
+        <title>Wicket Quickstart Archetype Homepage</title>
+    </head>
+    <body>
+    </body>
+</html>
+

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.java?rev=780797&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.java 
(added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/SecondPage.java 
Mon Jun  1 19:37:46 2009
@@ -0,0 +1,33 @@
+/*
+ * 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.form;
+
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ * 
+ */
+public class SecondPage extends WebPage
+{
+       /**
+        * Construct.
+        */
+       public SecondPage()
+       {
+               setResponsePage(ThirdPage.class);
+       }
+}

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.html?rev=780797&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.html 
(added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.html 
Mon Jun  1 19:37:46 2009
@@ -0,0 +1,10 @@
+<html>
+    <head>
+        <title>Wicket Quickstart Archetype Homepage</title>
+    </head>
+    <body>
+        <label wicket:id="label"></label>
+        <p>And just plain text</p>
+    </body>
+</html>
+

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.java?rev=780797&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.java 
(added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/ThirdPage.java 
Mon Jun  1 19:37:46 2009
@@ -0,0 +1,34 @@
+/*
+ * 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.form;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * 
+ */
+public class ThirdPage extends WebPage
+{
+       /**
+        * Construct.
+        */
+       public ThirdPage()
+       {
+               add(new Label("label", "Hello world."));
+       }
+}

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WebResponseExceptionsTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WebResponseExceptionsTest.java?rev=780797&r1=780796&r2=780797&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WebResponseExceptionsTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WebResponseExceptionsTest.java
 Mon Jun  1 19:37:46 2009
@@ -105,12 +105,13 @@
                try
                {
                        tester.executeAjaxEvent(link, "onclick");
-                       assertTrue("Excepted an error message to be thrown", 
false);
+                       fail("Excepted an error message to be thrown");
                }
                catch (IllegalStateException ex)
                {
                        // expected exception
-                       tester.assertAjaxLocation();
+                       assertEquals(500, 
((MockHttpServletResponse)tester.getWicketResponse()
+                               .getHttpServletResponse()).getStatus());
                }
 
                tester.startPage(TestErrorPage.class);
@@ -118,12 +119,12 @@
                try
                {
                        tester.clickLink("link");
-                       assertTrue("Excepted an error message to be thrown", 
false);
+                       fail("Excepted an error message to be thrown");
                }
                catch (IllegalStateException ex)
                {
-                       // expected exception
-                       tester.assertAjaxLocation();
+                       assertEquals(500, 
((MockHttpServletResponse)tester.getWicketResponse()
+                               .getHttpServletResponse()).getStatus());
                }
        }
 }


Reply via email to