Author: ivaynberg
Date: Sat Sep 27 01:31:04 2008
New Revision: 699604

URL: http://svn.apache.org/viewvc?rev=699604&view=rev
Log:
WICKET-861

Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebRequestProcessorTest.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java?rev=699604&r1=699603&r2=699604&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
 Sat Sep 27 01:31:04 2008
@@ -49,6 +49,7 @@
 import org.apache.wicket.IRedirectListener;
 import org.apache.wicket.IResourceListener;
 import org.apache.wicket.Page;
+import org.apache.wicket.RequestListenerInterface;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.FormComponent;
@@ -1210,10 +1211,40 @@
                                                component.getClass());
                        }
 
+                       // manually create the url using default strategy and 
format
                        
parameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, pageMapName + 
':' +
                                component.getPath() + ':' + (version == 0 ? "" 
: "" + version) + ':' +
                                Classes.simpleName(clazz) + "::");
 
+                       // see if we can replace our manual listener url with a 
properly generated one...
+
+                       try
+                       {
+                               RequestListenerInterface rli = 
(RequestListenerInterface)clazz.getField("INTERFACE")
+                                       .get(clazz);
+
+                               String auto = 
component.getRequestCycle().urlFor(component, rli).toString();
+                               int idx = 
auto.indexOf(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
+                               if (idx >= 0)
+                               {
+                                       auto = auto.substring(idx +
+                                               
WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME.length() + 1);
+                               }
+                               idx = auto.indexOf("&");
+                               if (idx >= 0)
+                               {
+                                       auto = auto.substring(0, idx);
+                               }
+
+                               
parameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, auto);
+
+                       }
+                       catch (Exception e)
+                       {
+                               // noop
+                       }
+
+
                        if (component.isStateless() && 
component.getPage().isBookmarkable())
                        {
                                
parameters.put(WebRequestCodingStrategy.BOOKMARKABLE_PAGE_PARAMETER_NAME,

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebRequestProcessorTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebRequestProcessorTest.java?rev=699604&r1=699603&r2=699604&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebRequestProcessorTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebRequestProcessorTest.java
 Sat Sep 27 01:31:04 2008
@@ -18,7 +18,10 @@
 
 import junit.framework.TestCase;
 
+import org.apache.wicket.Page;
+import org.apache.wicket.PageParameters;
 import org.apache.wicket.request.IRequestCycleProcessor;
+import org.apache.wicket.util.tester.ITestPageSource;
 import org.apache.wicket.util.tester.WicketTester;
 import org.apache.wicket.util.tester.WicketTester.DummyWebApplication;
 
@@ -32,6 +35,7 @@
        /**
         * @see junit.framework.TestCase#setUp()
         */
+       @Override
        protected void setUp() throws Exception
        {
                super.setUp();
@@ -41,6 +45,7 @@
                        /**
                         * Special overwrite to have url compressing for this 
example.
                         */
+                       @Override
                        protected IRequestCycleProcessor 
newRequestCycleProcessor()
                        {
                                return new UrlCompressingWebRequestProcessor();
@@ -61,8 +66,8 @@
         */
        public void test2()
        {
-               // @TODO Johan, why does this fail with a NumberException????
-               // tester.startPage(new MyPage());
+
+               tester.startPage(new MyPage());
        }
 
        /**
@@ -70,17 +75,16 @@
         */
        public void test3()
        {
-               // @TODO Johan, why does this fail with a NumberException????
-// tester.startPage(new ITestPageSource()
-// {
-// private static final long serialVersionUID = 1L;
-//
-// public Page getTestPage()
-// {
-// PageParameters params = new PageParameters();
-// params.add("0", "param");
-// return new MyPage();
-// }
-// });
+               tester.startPage(new ITestPageSource()
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       public Page getTestPage()
+                       {
+                               PageParameters params = new PageParameters();
+                               params.add("0", "param");
+                               return new MyPage();
+                       }
+               });
        }
 }


Reply via email to