Author: ivaynberg
Date: Mon Mar  1 22:37:53 2010
New Revision: 917764

URL: http://svn.apache.org/viewvc?rev=917764&view=rev
Log:
test fixes

Added:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java  
 (contents, props changed)
      - copied, changed from r917565, 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java 
  (contents, props changed)
      - copied, changed from r917565, 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ResourceReferenceMapper.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ResourceTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java Mon 
Mar  1 22:37:53 2010
@@ -928,7 +928,7 @@
                sharedResources = newSharedResources(resourceReferenceRegistry);
 
                // set up default request mapper
-               setRootRequestMapper(new SystemMapper(getResourceSettings()));
+               setRootRequestMapper(new SystemMapper(this));
 
                pageFactory = newPageFactory();
 

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java Mon 
Mar  1 22:37:53 2010
@@ -23,7 +23,7 @@
 import org.apache.wicket.ng.request.mapper.ResourceReferenceMapper;
 import org.apache.wicket.ng.request.mapper.ThreadsafeCompoundRequestMapper;
 import 
org.apache.wicket.ng.request.mapper.parameters.SimplePageParametersEncoder;
-import org.apache.wicket.settings.IResourceSettings;
+import org.apache.wicket.util.IProvider;
 
 
 /**
@@ -37,14 +37,31 @@
        /**
         * Constructor
         */
-       public SystemMapper(IResourceSettings settings)
+       public SystemMapper(Application application)
        {
                register(RestartResponseAtInterceptPageException.MAPPER);
                register(new HomePageMapper());
                register(new PageInstanceMapper());
                register(new BookmarkableMapper());
                register(new ResourceReferenceMapper(new 
SimplePageParametersEncoder(),
-                       settings.getParentFolderPlaceholder()));
+                       new ParentFolderPlaceholderProvider(application)));
                register(new BufferedResponseMapper());
        }
+
+       private static class ParentFolderPlaceholderProvider implements 
IProvider<String>
+       {
+               private final Application application;
+
+               public ParentFolderPlaceholderProvider(Application application)
+               {
+                       this.application = application;
+               }
+
+               public String get()
+               {
+                       return 
application.getResourceSettings().getParentFolderPlaceholder();
+               }
+
+
+       }
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java Mon 
Mar  1 22:37:53 2010
@@ -277,6 +277,17 @@
        public void setQueryParameter(String name, Object value)
        {
                removeQueryParameters(name);
+               addQueryParameter(name, value);
+       }
+
+       /**
+        * Convenience method that removes adds a query parameter with given 
name
+        * 
+        * @param name
+        * @param value
+        */
+       public void addQueryParameter(String name, Object value)
+       {
                if (value != null)
                {
                        QueryParameter parameter = new QueryParameter(name, 
value.toString());

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ResourceReferenceMapper.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ResourceReferenceMapper.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ResourceReferenceMapper.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ResourceReferenceMapper.java
 Mon Mar  1 22:37:53 2010
@@ -24,6 +24,9 @@
 import org.apache.wicket.ng.request.mapper.parameters.IPageParametersEncoder;
 import 
org.apache.wicket.ng.request.mapper.parameters.SimplePageParametersEncoder;
 import org.apache.wicket.ng.resource.ResourceReference;
+import org.apache.wicket.util.IProvider;
+import org.apache.wicket.util.NullProvider;
+import org.apache.wicket.util.lang.Checks;
 import org.apache.wicket.util.lang.Classes;
 
 /**
@@ -44,7 +47,7 @@
 public class ResourceReferenceMapper extends AbstractResourceReferenceMapper
 {
        private final IPageParametersEncoder pageParametersEncoder;
-       private final String relativePathPartEscapeSequence;
+       private final IProvider<String> relativePathPartEscapeSequence;
 
        /**
         * Construct.
@@ -53,8 +56,9 @@
         * @param relativePathPartEscapeSequence
         */
        public ResourceReferenceMapper(IPageParametersEncoder 
pageParametersEncoder,
-               String relativePathPartEscapeSequence)
+               IProvider<String> relativePathPartEscapeSequence)
        {
+               Checks.argumentNotNull("relativePathPartEscapeSequence", 
"relativePathPartEscapeSequence");
                this.pageParametersEncoder = pageParametersEncoder;
                this.relativePathPartEscapeSequence = 
relativePathPartEscapeSequence;
        }
@@ -64,7 +68,7 @@
         */
        public ResourceReferenceMapper()
        {
-               this(new SimplePageParametersEncoder(), null);
+               this(new SimplePageParametersEncoder(), new 
NullProvider<String>());
        }
 
        /**
@@ -74,11 +78,11 @@
        {
                Url url = request.getUrl();
 
-               if (relativePathPartEscapeSequence != null)
+               if (relativePathPartEscapeSequence.get() != null)
                {
                        for (int i = 0; i < url.getSegments().size(); i++)
                        {
-                               if 
(url.getSegments().get(i).equals(relativePathPartEscapeSequence))
+                               if 
(url.getSegments().get(i).equals(relativePathPartEscapeSequence.get()))
                                {
                                        url.getSegments().set(i, "..");
                                }
@@ -159,13 +163,13 @@
                                url = encodePageParameters(url, parameters, 
pageParametersEncoder);
                        }
 
-                       if (relativePathPartEscapeSequence != null)
+                       if (relativePathPartEscapeSequence.get() != null)
                        {
                                for (int i = 0; i < url.getSegments().size(); 
i++)
                                {
                                        if 
("..".equals(url.getSegments().get(i)))
                                        {
-                                               url.getSegments().set(i, 
relativePathPartEscapeSequence);
+                                               url.getSegments().set(i, 
relativePathPartEscapeSequence.get());
                                        }
                                }
                        }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
 Mon Mar  1 22:37:53 2010
@@ -33,6 +33,7 @@
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -48,7 +49,7 @@
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.ng.mock.MockRequestParameters;
 import org.apache.wicket.ng.request.Url;
-import org.apache.wicket.protocol.http.RequestUtils;
+import org.apache.wicket.ng.request.Url.QueryParameter;
 import org.apache.wicket.protocol.http.WicketURLDecoder;
 import org.apache.wicket.protocol.http.WicketURLEncoder;
 import org.apache.wicket.util.file.File;
@@ -162,7 +163,7 @@
 
        private String method;
 
-       private final ValueMap parameters = new ValueMap();
+       private final LinkedHashMap<String, String[]> parameters = new 
LinkedHashMap<String, String[]>();
 
        private String path;
 
@@ -385,6 +386,23 @@
                return "/context";
        }
 
+       public Cookie getCookie(String name)
+       {
+               Cookie[] cookies = getCookies();
+               if (cookies == null)
+               {
+                       return null;
+               }
+               for (Cookie cookie : cookies)
+               {
+                       if (cookie.getName().equals(name))
+                       {
+                               return cookie;
+                       }
+               }
+               return null;
+       }
+
        /**
         * Get all of the cookies for this request.
         * 
@@ -607,7 +625,15 @@
         */
        public String getParameter(final String name)
        {
-               return parameters.getString(name);
+               String[] param = parameters.get(name);
+               if (param == null)
+               {
+                       return null;
+               }
+               else
+               {
+                       return param[0];
+               }
        }
 
        /**
@@ -617,7 +643,9 @@
         */
        public Map<String, Object> getParameterMap()
        {
-               return parameters;
+               Map<String, Object> map = new HashMap<String, Object>();
+               map.putAll(parameters);
+               return Collections.unmodifiableMap(map);
        }
 
        /**
@@ -704,7 +732,7 @@
                        for (Iterator<String> iterator = 
parameters.keySet().iterator(); iterator.hasNext();)
                        {
                                final String name = iterator.next();
-                               final String value = parameters.getString(name);
+                               final String value = getParameter(name);
                                if (name != null)
                                {
                                        
buf.append(WicketURLEncoder.QUERY_INSTANCE.encode(name));
@@ -1121,7 +1149,34 @@
         */
        public void setParameter(final String name, final String value)
        {
-               parameters.put(name, value);
+               if (value == null)
+               {
+                       parameters.remove(name);
+               }
+               else
+               {
+                       parameters.put(name, new String[] { value });
+               }
+       }
+
+       public void addParameter(final String name, final String value)
+       {
+               if (value == null)
+               {
+                       return;
+               }
+               String[] val = parameters.get(name);
+               if (val == null)
+               {
+                       parameters.put(name, new String[] { value });
+               }
+               else
+               {
+                       String[] newval = new String[val.length + 1];
+                       System.arraycopy(val, 0, newval, 0, val.length);
+                       newval[val.length] = value;
+                       parameters.put(name, newval);
+               }
        }
 
        /**
@@ -1182,9 +1237,12 @@
                        setPath(url.substring(0, index));
 
                        String queryString = url.substring(index + 1);
-                       Map<String, String[]> params = new HashMap<String, 
String[]>();
-                       RequestUtils.decodeUrlParameters(queryString, params);
-                       parameters.putAll(params);
+
+                       parameters.clear();
+                       for (QueryParameter parameter : Url.parse("?" + 
queryString).getQueryParameters())
+                       {
+                               addParameter(parameter.getName(), 
parameter.getValue());
+                       }
                }
        }
 
@@ -1349,39 +1407,6 @@
 // }
 
        /**
-        * Initialize the request parameters from the given redirect string 
that redirects back to a
-        * particular component for display.
-        * 
-        * @param redirect
-        *            The redirect string to display from
-        */
-       public void setRequestToRedirectString(final String redirect)
-       {
-               parameters.clear();
-
-               int queryStringPos = redirect.indexOf('?');
-
-               // Decode the parameters
-               if (queryStringPos != -1)
-               {
-                       final String queryString = 
redirect.substring(queryStringPos + 1);
-                       RequestUtils.decodeParameters(queryString, parameters);
-               }
-
-               // We need to absolutize the redirect URL as we are not as 
smart as a web-browser
-               // (WICKET-702)
-               url = redirect;
-               if ((url.length() == 0) || (url.charAt(0) != '/'))
-               {
-                       url = getContextPath() + getServletPath() + "/" + 
redirect;
-               }
-
-               // Remove occurrences of ".." from the path
-               url = RequestUtils.removeDoubleDots(url);
-               log.info("Redirecting to " + url);
-       }
-
-       /**
         * Helper method to create some default headers for the request
         */
        private void setDefaultHeaders()
@@ -1424,7 +1449,11 @@
                        for (Iterator<String> iterator = 
post.getParameterNames().iterator(); iterator.hasNext();)
                        {
                                final String name = iterator.next();
-                               url.setQueryParameter(name, 
post.getParameterValue(name.toString()));
+                               List<org.apache.wicket.util.string.StringValue> 
values = post.getParameterValues(name);
+                               for (org.apache.wicket.util.string.StringValue 
value : values)
+                               {
+                                       url.addQueryParameter(name, 
value.toString());
+                               }
                        }
                        String body = url.toString().substring(1);
                        return body.getBytes();

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
 Mon Mar  1 22:37:53 2010
@@ -23,7 +23,6 @@
 import java.text.DateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Collection;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
@@ -35,7 +34,6 @@
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.wicket.protocol.http.RequestUtils;
 import org.apache.wicket.util.value.ValueMap;
 
 
@@ -57,8 +55,6 @@
 
        private String characterEncoding = "UTF-8";
 
-       private int code = HttpServletResponse.SC_OK;
-
        private final List<Cookie> cookies = new ArrayList<Cookie>();
 
        private String errorMessage = null;
@@ -264,22 +260,13 @@
                return characterEncoding;
        }
 
-       /**
-        * Get the response code for this request.
-        * 
-        * @return The response code
-        */
-       public int getCode()
-       {
-               return code;
-       }
 
        /**
         * Get all of the cookies that have been added to the response.
         * 
         * @return The collection of cookies
         */
-       public Collection<Cookie> getCookies()
+       public List<Cookie> getCookies()
        {
                return cookies;
        }
@@ -382,7 +369,7 @@
         * 
         * @return The status code
         */
-       public int getStatus()
+       public Integer getStatus()
        {
                return status;
        }
@@ -411,7 +398,6 @@
        {
                cookies.clear();
                headers.clear();
-               code = HttpServletResponse.SC_OK;
                errorMessage = null;
                redirectLocation = null;
                status = HttpServletResponse.SC_OK;
@@ -462,7 +448,7 @@
         */
        public boolean isError()
        {
-               return (code != HttpServletResponse.SC_OK);
+               return (status != HttpServletResponse.SC_OK);
        }
 
        /**
@@ -508,7 +494,7 @@
         */
        public void sendError(final int code) throws IOException
        {
-               this.code = code;
+               status = code;
                errorMessage = null;
        }
 
@@ -524,7 +510,7 @@
         */
        public void sendError(final int code, final String msg) throws 
IOException
        {
-               this.code = code;
+               status = code;
                errorMessage = msg;
        }
 
@@ -580,24 +566,6 @@
         */
        public void sendRedirect(String location) throws IOException
        {
-               // If the location starts with ../
-               if (location.startsWith("../"))
-               {
-                       // Test if the current url has a / in it. (a mount)
-                       String url = getURL();
-                       int index = url.lastIndexOf("/");
-                       if (index != -1)
-                       {
-                               // Then we have to recalculate what the real 
redirect is for the next request
-                               // which is just getContext() + 
getServletPath() + "/" + location;
-                               url = url.substring(0, index + 1) + location;
-                               url = RequestUtils.removeDoubleDots(url);
-
-                               // stril the servlet path again from it.
-                               index = url.indexOf("/");
-                               location = url.substring(index + 1);
-                       }
-               }
                redirectLocation = location;
        }
 
@@ -817,4 +785,27 @@
        {
                setStatus(status);
        }
+
+       /**
+        * @deprecated use {...@link #getDocument()}
+        * @return
+        */
+       @Deprecated
+       public String getTextResponse()
+       {
+               return getDocument();
+       }
+
+       public String getBinaryResponse()
+       {
+               String ctheader = getHeader("Content-Length");
+               if (ctheader == null)
+               {
+                       return getDocument();
+               }
+               else
+               {
+                       return getDocument().substring(0, 
Integer.valueOf(ctheader));
+               }
+       }
 }
\ No newline at end of file

Copied: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java 
(from r917565, 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java)
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java&p1=wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java&r1=917565&r2=917764&rev=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
 (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java 
Mon Mar  1 22:37:53 2010
@@ -1,51 +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.redirect;
-
-import org.apache.wicket.WicketTestCase;
-
-public class RestartWithMountedPageTest extends WicketTestCase
-{
-
-       /**
-        * Construct.
-        */
-       public RestartWithMountedPageTest()
-       {
-               super();
-       }
-
-       /**
-        * Construct.
-        * 
-        * @param name
-        */
-       public RestartWithMountedPageTest(String name)
-       {
-               super(name);
-       }
-
-       /**
-        * Tests that a protected page can redirect to a login page from 
mounted pages.
-        */
-       public void testWithMountedLoginPage()
-       {
-               tester.getApplication().mountBookmarkablePage("/login", 
LoginPage.class);
-               tester.startPage(ProtectedPage.class);
-               tester.assertRenderedPage(LoginPage.class);
-       }
-}
+/*
+ * 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;
+
+/**
+ * Provider that provides {...@code null}s. Convenient to have to avoid a 
double {...@code null} check for
+ * the provider and its provided instance.
+ * 
+ * @author igor.vaynberg
+ * @param <T>
+ */
+public class NullProvider<T> implements IProvider<T>
+{
+
+       public T get()
+       {
+               return null;
+       }
+
+}

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/NullProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java 
(from r917565, 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java)
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java&p1=wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java&r1=917565&r2=917764&rev=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
 (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java 
Mon Mar  1 22:37:53 2010
@@ -1,51 +1,45 @@
-/*
- * 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.redirect;
-
-import org.apache.wicket.WicketTestCase;
-
-public class RestartWithMountedPageTest extends WicketTestCase
-{
-
-       /**
-        * Construct.
-        */
-       public RestartWithMountedPageTest()
-       {
-               super();
-       }
-
-       /**
-        * Construct.
-        * 
-        * @param name
-        */
-       public RestartWithMountedPageTest(String name)
-       {
-               super(name);
-       }
-
-       /**
-        * Tests that a protected page can redirect to a login page from 
mounted pages.
-        */
-       public void testWithMountedLoginPage()
-       {
-               tester.getApplication().mountBookmarkablePage("/login", 
LoginPage.class);
-               tester.startPage(ProtectedPage.class);
-               tester.assertRenderedPage(LoginPage.class);
-       }
-}
+/*
+ * 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;
+
+/**
+ * Provider that always provides the specified value.
+ * 
+ * @author igor.vaynberg
+ * @param <T>
+ */
+public class ValueProvider<T> implements IProvider<T>
+{
+       private final T value;
+
+       /**
+        * Construct.
+        * 
+        * @param value
+        *            value to provide
+        */
+       public ValueProvider(T value)
+       {
+               this.value = value;
+       }
+
+       public T get()
+       {
+               return value;
+       }
+
+}

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/ValueProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 Mon Mar  1 22:37:53 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.util.tester;
 
+import java.io.IOException;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
@@ -67,7 +68,6 @@
 import org.apache.wicket.ng.mock.MockApplication;
 import org.apache.wicket.ng.mock.MockPageManager;
 import org.apache.wicket.ng.mock.MockSessionStore;
-import org.apache.wicket.ng.mock.MockWebResponse;
 import org.apache.wicket.ng.request.IRequestMapper;
 import org.apache.wicket.ng.request.Url;
 import org.apache.wicket.ng.request.component.PageParameters;
@@ -86,8 +86,10 @@
 import org.apache.wicket.protocol.http.MockServletContext;
 import org.apache.wicket.protocol.http.WebApplication;
 import org.apache.wicket.protocol.http.mock.MockHttpServletRequest;
+import org.apache.wicket.protocol.http.mock.MockHttpServletResponse;
 import org.apache.wicket.protocol.http.mock.MockHttpSession;
 import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+import org.apache.wicket.protocol.http.servlet.ServletWebResponse;
 import org.apache.wicket.session.ISessionStore;
 import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
 import org.apache.wicket.util.IProvider;
@@ -151,17 +153,17 @@
        private int redirectCount;
 
        private MockHttpServletRequest lastRequest;
-       private MockWebResponse lastResponse;
+       private MockHttpServletResponse lastResponse;
 
        private final List<MockHttpServletRequest> previousRequests = new 
ArrayList<MockHttpServletRequest>();
-       private final List<MockWebResponse> previousResponses = new 
ArrayList<MockWebResponse>();
+       private final List<MockHttpServletResponse> previousResponses = new 
ArrayList<MockHttpServletResponse>();
 
        private final ThreadContext oldThreadContext;
 
        /** current request */
        private MockHttpServletRequest request;
        /** current response */
-       private MockWebResponse response;
+       private MockHttpServletResponse response;
 
        /** current session */
        private Session session;
@@ -265,11 +267,11 @@
        {
                request = new MockHttpServletRequest(application, hsession, 
servletContext);
                request.setURL(request.getContextPath() + 
request.getServletPath() + "/");
-               response = new MockWebResponse();
+               response = new MockHttpServletResponse(request);
 
 
-               requestCycle = application.createRequestCycle(new 
ServletWebRequest(request,
-                       request.getFilterPrefix()), response);
+               requestCycle = 
application.createRequestCycle(createServletWebRequest(),
+                       createServletWebResponse());
                requestCycle.setCleanupFeedbackMessagesOnDetach(false);
                ThreadContext.setRequestCycle(requestCycle);
 
@@ -282,6 +284,38 @@
 
 
        /**
+        * @return
+        */
+       private ServletWebResponse createServletWebResponse()
+       {
+               return new ServletWebResponse(request, response)
+               {
+                       @Override
+                       public void sendRedirect(String url)
+                       {
+                               super.sendRedirect(url);
+                               try
+                               {
+                                       
getHttpServletResponse().sendRedirect(url);
+                               }
+                               catch (IOException e)
+                               {
+                                       throw new RuntimeException(e);
+                               }
+                       }
+               };
+       }
+
+       /**
+        * @return
+        */
+       private ServletWebRequest createServletWebRequest()
+       {
+               return new ServletWebRequest(request, 
request.getFilterPrefix());
+       }
+
+
+       /**
         * 
         */
        private void createNewSession()
@@ -299,7 +333,7 @@
        public void setRequest(MockHttpServletRequest request)
        {
                this.request = request;
-               requestCycle.setRequest(new ServletWebRequest(request, 
request.getServletPath()));
+               applyRequest();
        }
 
 
@@ -424,13 +458,15 @@
                                }
                        }
 
-                       requestCycle.setRequest(new ServletWebRequest(request, 
request.getFilterPrefix()));
+                       applyRequest();
+                       requestCycle.scheduleRequestHandlerAfterCurrent(null);
 
                        if (!requestCycle.processRequestAndDetach())
                        {
                                return false;
                        }
 
+
                        recordRequestResponse();
                        setupNextRequestCycle();
 
@@ -443,7 +479,8 @@
                                                "Possible infinite redirect 
detected. Bailing out.");
                                }
                                ++redirectCount;
-                               Url newUrl = 
Url.parse(lastResponse.getRedirectUrl());
+                               Url newUrl = 
Url.parse(lastResponse.getRedirectLocation());
+
                                if (newUrl.isAbsolute())
                                {
                                        throw new WicketRuntimeException("Can 
not follow absolute redirect URL.");
@@ -524,14 +561,14 @@
        /**
         * @return last response or <code>null</code>> if no response has been 
produced yet.
         */
-       public MockWebResponse getLastResponse()
+       public MockHttpServletResponse getLastResponse()
        {
                return lastResponse;
        }
 
        public String getLastResponseAsString()
        {
-               return lastResponse.getTextResponse().toString();
+               return lastResponse.getDocument();
        }
 
        /**
@@ -545,7 +582,7 @@
        /**
         * @return list of prior responses
         */
-       public List<MockWebResponse> getPreviousResponses()
+       public List<MockHttpServletResponse> getPreviousResponses()
        {
                return Collections.unmodifiableList(previousResponses);
        }
@@ -965,10 +1002,8 @@
         */
        public Result ifContains(String pattern)
        {
-               return isTrue("pattern '" + pattern + "' not found in:\n" +
-                       getLastResponse().getTextResponse(), 
getLastResponse().getTextResponse()
-                       .toString()
-                       .matches("(?s).*" + pattern + ".*"));
+               return isTrue("pattern '" + pattern + "' not found in:\n" + 
getLastResponseAsString(),
+                       getLastResponseAsString().toString().matches("(?s).*" + 
pattern + ".*"));
        }
 
        /**
@@ -1197,7 +1232,7 @@
        public void assertResultPage(final Class<?> pageClass, final String 
filename) throws Exception
        {
                // Validate the document
-               String document = 
getLastResponse().getTextResponse().toString();
+               String document = getLastResponseAsString();
                DiffUtil.validatePage(document, pageClass, filename, true);
        }
 
@@ -1213,7 +1248,7 @@
        public Result isResultPage(final String expectedDocument) throws 
Exception
        {
                // Validate the document
-               String document = 
getLastResponse().getTextResponse().toString();
+               String document = getLastResponseAsString();
                return isTrue("expected rendered page equals", 
document.equals(expectedDocument));
        }
 
@@ -1275,7 +1310,7 @@
         */
        public void dumpPage()
        {
-               log.info(getLastResponse().getTextResponse().toString());
+               log.info(getLastResponseAsString());
        }
 
        /**
@@ -1338,7 +1373,7 @@
                }
 
                // Get the AJAX response
-               String ajaxResponse = 
getLastResponse().getTextResponse().toString();
+               String ajaxResponse = getLastResponseAsString();
 
                // Test that the previous response was actually a AJAX response
                failMessage = "The Previous response was not an AJAX response. "
@@ -1515,8 +1550,7 @@
         */
        public TagTester getTagByWicketId(String wicketId)
        {
-               return 
TagTester.createTagByAttribute(getLastResponse().getTextResponse().toString(),
-                       "wicket:id", wicketId);
+               return 
TagTester.createTagByAttribute(getLastResponseAsString(), "wicket:id", 
wicketId);
        }
 
        /**
@@ -1527,8 +1561,8 @@
         */
        public List<TagTester> getTagsByWicketId(String wicketId)
        {
-               return 
TagTester.createTagsByAttribute(getLastResponse().getTextResponse().toString(),
-                       "wicket:id", wicketId, false);
+               return 
TagTester.createTagsByAttribute(getLastResponseAsString(), "wicket:id", 
wicketId,
+                       false);
        }
 
        /**
@@ -1541,8 +1575,7 @@
         */
        public TagTester getTagById(String id)
        {
-               return 
TagTester.createTagByAttribute(getLastResponse().getTextResponse().toString(), 
"id",
-                       id);
+               return 
TagTester.createTagByAttribute(getLastResponseAsString(), "id", id);
        }
 
        /**
@@ -1621,6 +1654,19 @@
                return getLastResponse().getHeader("Content-Disposition");
        }
 
+       /**
+        * Rebuilds {...@link ServletWebRequest} used by wicket from the mock 
request used to build
+        * requests. Sometimes this method is useful when changes need to be 
checked without processing
+        * a request.
+        */
+       public void applyRequest()
+       {
+               ServletWebRequest req = createServletWebRequest();
+               requestCycle.setRequest(req);
+               requestCycle.getUrlRenderer().setBaseUrl(req.getUrl());
+
+       }
+
        private Result isTrue(String message, boolean condition)
        {
                if (condition)
@@ -1671,7 +1717,7 @@
                return requestCycle;
        }
 
-       public MockWebResponse getResponse()
+       public MockHttpServletResponse getResponse()
        {
                return response;
        }
@@ -1829,4 +1875,5 @@
 
        }
 
+
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
 Mon Mar  1 22:37:53 2010
@@ -416,7 +416,7 @@
        @Override
        public void assertResultPage(final Class<?> clazz, final String 
filename) throws Exception
        {
-               String document = 
getLastResponse().getTextResponse().toString();
+               String document = getLastResponseAsString();
                DiffUtil.validatePage(document, clazz, filename, true);
        }
 
@@ -431,7 +431,7 @@
        public void assertResultPage(final String expectedDocument) throws 
Exception
        {
                // Validate the document
-               String document = 
getLastResponse().getTextResponse().toString();
+               String document = getLastResponseAsString();
                Assert.assertEquals(expectedDocument, document);
        }
 

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java
 Mon Mar  1 22:37:53 2010
@@ -72,7 +72,7 @@
        public void testComponentTagAttributeModification() throws Exception
        {
                // Validate the document
-               String document = 
tester.getLastResponse().getTextResponse().toString();
+               String document = tester.getLastResponseAsString();
                log.info(document);
                Assert.assertTrue(validateDocument(document));
        }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/ResourceTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ResourceTest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/ResourceTest.java 
(original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ResourceTest.java Mon 
Mar  1 22:37:53 2010
@@ -23,6 +23,7 @@
 
 import org.apache.wicket.ng.resource.IResource;
 import org.apache.wicket.ng.resource.ResourceStreamResource;
+import org.apache.wicket.protocol.http.mock.MockHttpServletResponse;
 import org.apache.wicket.util.resource.FileResourceStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,7 +64,7 @@
                                        null, null, true)));
                tester.processRequest();
 
-               assertEquals(String.valueOf(testFile.lastModified()),
+               
assertEquals(MockHttpServletResponse.formatDate(testFile.lastModified()),
                        tester.getLastModifiedFromResponseHeader());
                assertEquals(TEST_STRING.length(), 
tester.getContentLengthFromResponseHeader());
        }

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
 Mon Mar  1 22:37:53 2010
@@ -161,26 +161,26 @@
 
                
tester.getRequest().getPostParameters().setParameterValue(group.getInputName(),
                        String.valueOf(choice1.getValue()));
+               tester.applyRequest();
                form.onFormSubmitted();
                assertTrue("running with choice1 selected - model must only 
contain value of check1",
                        modelObject.getProp1().size() == 1 && 
modelObject.getProp1().contains(check1));
 
                
tester.getRequest().getPostParameters().setParameterValue(group.getInputName(),
                        String.valueOf(choice2.getValue()));
+               tester.applyRequest();
                form.onFormSubmitted();
                assertTrue("running with choice2 selected - model must only 
contain value of check2",
                        modelObject.getProp1().size() == 1 && 
modelObject.getProp1().contains(check2));
 
                // throw in some nulls into the request param to make sure they 
are
                // ignored
-               tester.getRequest()
-                       .getPostParameters()
-                       .addParameterValue(group.getInputName(), null);
+               
tester.getRequest().getPostParameters().addParameterValue(group.getInputName(), 
null);
                
tester.getRequest().getPostParameters().addParameterValue(group.getInputName(),
                        String.valueOf(choice1.getValue()));
                
tester.getRequest().getPostParameters().addParameterValue(group.getInputName(),
                        String.valueOf(choice2.getValue()));
-
+               tester.applyRequest();
                form.onFormSubmitted();
 
                assertTrue(
@@ -190,6 +190,7 @@
 
                
tester.getRequest().getPostParameters().setParameterValue(group.getInputName(),
                        "some weird choice uuid to test error");
+               tester.applyRequest();
                try
                {
                        form.onFormSubmitted();

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTest.java
 Mon Mar  1 22:37:53 2010
@@ -152,6 +152,9 @@
                        choice1.getValue());
                
tester.getRequest().getPostParameters().setParameterValue(group2.getInputName(),
                        choice3.getValue());
+
+               tester.applyRequest();
+
                form.onFormSubmitted();
                assertEquals("group: running with choice1 selected - model must 
be set to value of radio1",
                        modelObject.getProp1(), 
choice1.getDefaultModelObject());
@@ -161,12 +164,14 @@
 
                
tester.getRequest().getPostParameters().setParameterValue(group.getInputName(),
                        choice2.getValue());
+               tester.applyRequest();
                form.onFormSubmitted();
                assertEquals("group: running with choice2 selected - model must 
be set to value of radio2",
                        modelObject.getProp1(), 
choice2.getDefaultModelObject());
 
                
tester.getRequest().getPostParameters().setParameterValue(group2.getInputName(),
                        choice1.getValue());
+               tester.applyRequest();
                try
                {
                        form.onFormSubmitted();

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_1.html?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
 Mon Mar  1 22:37:53 2010
@@ -27,7 +27,7 @@
 <link 
href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test.css?-myStyle"/>
 <link 
href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test2.css?-myStyle"/>
 <link 
href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/test3.css?de_DE-myStyle"/>
-<link 
href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/../../html/link/test2.css?-myStyle"/>
+<link 
href="../resource/org.apache.wicket.markup.html.link.AutolinkPage_1/$up$/$up$/html/link/test2.css?-myStyle"/>
 <a href="/root/test.html">Home</a>
 <a href="org.apache.wicket.markup.html.link.Page1">Home</a>
   <a href="http://www.google.com";>Google</a>

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/RestartWithMountedPageTest.java
 Mon Mar  1 22:37:53 2010
@@ -22,24 +22,6 @@
 {
 
        /**
-        * Construct.
-        */
-       public RestartWithMountedPageTest()
-       {
-               super();
-       }
-
-       /**
-        * Construct.
-        * 
-        * @param name
-        */
-       public RestartWithMountedPageTest(String name)
-       {
-               super(name);
-       }
-
-       /**
         * Tests that a protected page can redirect to a login page from 
mounted pages.
         */
        public void testWithMountedLoginPage()

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentTest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentTest.java
 Mon Mar  1 22:37:53 2010
@@ -57,7 +57,7 @@
                executeTest(StatelessComponentPage.class, 
"StatelessComponentPage_mount_result.html");
                tester.getRequest()
                        .setUrl(
-                               
Url.parse("stateless?0-1.ILinkListener-link&amp;testParam1=testValue1&amp;testParam2=testValue2"));
+                               
Url.parse("stateless?0-1.ILinkListener-link&testParam1=testValue1&testParam2=testValue2"));
                try
                {
                        tester.processRequest();

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java?rev=917764&r1=917763&r2=917764&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
 Mon Mar  1 22:37:53 2010
@@ -16,7 +16,9 @@
  */
 package org.apache.wicket.util.cookies;
 
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import javax.servlet.http.Cookie;
@@ -70,21 +72,21 @@
 
                // Save the input field's value (add it to the response's 
cookie list)
                persister.save(textField);
-               assertNull(getRequestCookies());
+               assertTrue(getRequestCookies().isEmpty());
                assertEquals(1, getResponseCookies().size());
                assertEquals("test", (getResponseCookies().get(0)).getValue());
                assertEquals("form.input", 
(getResponseCookies().get(0)).getName());
-               
assertEquals("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication",
+               assertEquals(tester.getRequest().getContextPath() + 
tester.getRequest().getServletPath(),
                        (getResponseCookies().get(0)).getPath());
 
                // To remove a cookie means to add a cookie with maxAge=0. 
Provided a cookie with the same
                // name has been provided in the request. Thus, no changes in 
our test case
                persister.remove(textField);
-               assertNull(getRequestCookies());
+               assertEquals(0, getRequestCookies().size());
                assertEquals(1, getResponseCookies().size());
                assertEquals("test", (getResponseCookies().get(0)).getValue());
                assertEquals("form.input", 
(getResponseCookies().get(0)).getName());
-               
assertEquals("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication",
+               assertEquals(tester.getRequest().getContextPath() + 
tester.getRequest().getServletPath(),
                        (getResponseCookies().get(0)).getPath());
 
                // Try to load it. Because there is no Cookie matching the 
textfield's name the model's
@@ -127,11 +129,18 @@
 
        private Collection<Cookie> getRequestCookies()
        {
-               return tester.getRequest().getCookies();
+               if (tester.getRequest().getCookies() == null)
+               {
+                       return Collections.emptyList();
+               }
+               else
+               {
+                       return Arrays.asList(tester.getRequest().getCookies());
+               }
        }
 
        private List<Cookie> getResponseCookies()
        {
-               return tester.getLastResponse().getCookies();
+               return tester.getResponse().getCookies();
        }
 }


Reply via email to