Author: jdonnerstag
Date: Thu May 21 11:19:53 2009
New Revision: 777069
URL: http://svn.apache.org/viewvc?rev=777069&view=rev
Log:
fixed: MockHttpServletRequest is broken when used with
CryptedUrlWebRequestCodingStrategy
Issue: WICKET-2281
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.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=777069&r1=777068&r2=777069&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
Thu May 21 11:19:53 2009
@@ -1255,37 +1255,38 @@
.get(clazz);
String auto =
component.getRequestCycle().urlFor(component, rli).toString();
- int idx =
auto.indexOf(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
- if (idx >= 0)
+
+ // check for crypted strategy
+ if (auto.startsWith("?x="))
{
- auto = auto.substring(idx +
-
WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME.length() + 1);
+ auto = auto.substring(3);
+ parameters.put("x", auto);
+
parameters.remove(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
}
else
{
- // additional check for crypted strategy
- idx = auto.indexOf("x=6*");
+ int idx =
auto.indexOf(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
if (idx >= 0)
{
- auto = auto.substring(idx + 4);
+ auto = auto.substring(idx +
+
WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME.length() + 1);
}
+ else
+ {
+ idx = auto.indexOf("&");
+ if (idx >= 0)
+ {
+ auto =
auto.substring(0, idx);
+ }
+ }
+
parameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, auto);
}
-
- 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,
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java?rev=777069&view=auto
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
(added)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
Thu May 21 11:19:53 2009
@@ -0,0 +1,75 @@
+/*
+ * 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.protocol.http.request;
+
+import junit.framework.TestCase;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.SimplePage;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
+import org.apache.wicket.request.IRequestCodingStrategy;
+import org.apache.wicket.request.IRequestCycleProcessor;
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Simple test using the WicketTester
+ */
+public class CryptedUrlWebRequestCodingStrategyTest extends TestCase
+{
+ private WicketTester tester;
+
+ WebApplication _app = new WebApplication()
+ {
+ @Override
+ public Class<WebPage> getHomePage()
+ {
+ return null;
+ }
+
+ @Override
+ protected IRequestCycleProcessor newRequestCycleProcessor()
+ {
+ return new WebRequestCycleProcessor()
+ {
+ @Override
+ protected IRequestCodingStrategy
newRequestCodingStrategy()
+ {
+ return new
CryptedUrlWebRequestCodingStrategy(super.newRequestCodingStrategy());
+ }
+ };
+ }
+ };
+
+ @Override
+ public void setUp()
+ {
+ tester = new WicketTester(_app);
+ }
+
+ /**
+ *
+ */
+ public void testClientBidListPage()
+ {
+ WebPage page = new SimplePage();
+ WebPage p = (WebPage)tester.startPage(page);
+ assertEquals(page.getClass(), p.getClass());
+ }
+
+
+}
\ No newline at end of file