You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2014/08/04 12:24:52 UTC

[1/3] git commit: WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Repository: wicket
Updated Branches:
  refs/heads/master b793f99f6 -> 304e0f427


WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Remove the newly introduced CookieUtils#loadValues() method.
At http://markmail.org/message/6t5gaeb3c2h24r36 we decided to deprecate all multivalue related methods in 6.x and remove them in 7.x

(cherry picked from commit 89ce5c41be76ea7a7c9c4679e419c15d83aaed07)


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/388b150e
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/388b150e
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/388b150e

Branch: refs/heads/master
Commit: 388b150ea0764ee5ac32c99c3582322f5561e07e
Parents: b793f99
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Aug 4 12:09:52 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Aug 4 12:21:09 2014 +0200

----------------------------------------------------------------------
 .../apache/wicket/util/cookies/CookieUtils.java  | 19 -------------------
 .../wicket/util/cookies/CookieUtilsTest.java     | 18 ------------------
 2 files changed, 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/388b150e/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
index af2d26e..0f1f315 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
@@ -123,25 +123,6 @@ public class CookieUtils
 	}
 
 	/**
-	 * Retrieve an array of the cookie value split by {@link org.apache.wicket.markup.html.form.FormComponent#VALUE_SEPARATOR}.
-	 *
-	 * @param key
-	 *          The cookie name
-	 * @return The cookie value split by {@link org.apache.wicket.markup.html.form.FormComponent#VALUE_SEPARATOR}.
-	 */
-	public final String[] loadValues(final String key)
-	{
-		final Cookie cookie = getCookie(key);
-		if (cookie != null)
-		{
-			String value = cookie.getValue();
-			String[] values = splitValue(value);
-			return values;
-		}
-		return null;
-	}
-
-	/**
 	 * Retrieve the cookie value associated with the formComponent and load the model object with
 	 * the cookie value.
 	 * 

http://git-wip-us.apache.org/repos/asf/wicket/blob/388b150e/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
index 2068cf4..9e6cf40 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
@@ -17,10 +17,8 @@
 package org.apache.wicket.util.cookies;
 
 import static org.hamcrest.Matchers.arrayContaining;
-import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.emptyArray;
 import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.equalToIgnoringCase;
 import static org.hamcrest.Matchers.is;
 
 import java.util.Arrays;
@@ -35,8 +33,6 @@ import org.apache.wicket.WicketTestCase;
 import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.util.cookies.CookieValuePersisterTestPage.TestForm;
-import org.apache.wicket.util.string.Strings;
-import org.hamcrest.Matchers;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -192,20 +188,6 @@ public class CookieUtilsTest extends WicketTestCase
 	}
 
 	@Test
-	public void saveLoadValues()
-	{
-		CookieUtils utils = new CookieUtils();
-		String value1 = "value one";
-		String value2 = "value two";
-		String value3 = "value three";
-		String key = "key";
-		utils.save(key, value1, value2, value3);
-		before(); // execute a request cycle, so the response cookie is send with the next request
-		String[] result = utils.loadValues(key);
-		assertThat(result, is(Matchers.arrayContaining(value1, value2, value3)));
-	}
-
-	@Test
 	public void defaults()
 	{
 		CookieDefaults defaults = new CookieDefaults();


[3/3] git commit: WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Posted by mg...@apache.org.
WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Remove the multivalue related methods


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/304e0f42
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/304e0f42
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/304e0f42

Branch: refs/heads/master
Commit: 304e0f427e3e01f182e1f916834a209281127448
Parents: b590d19
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Aug 4 12:23:18 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Aug 4 12:23:18 2014 +0200

----------------------------------------------------------------------
 .../apache/wicket/util/cookies/CookieUtils.java | 33 ++-----------
 .../wicket/util/cookies/CookieUtilsTest.java    | 49 --------------------
 2 files changed, 3 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/304e0f42/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
index 1859d96..987db75 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
@@ -141,43 +141,16 @@ public class CookieUtils
 	}
 
 	/**
-	 * Split the loaded Cookie value
-	 * 
-	 * @param value
-	 * @return The cookie's value split into fragments
-	 * @deprecated Cookies with multiple values are no more supported (WICKET-5648). This method will be removed in Wicket 7.x
-	 */
-	@Deprecated
-	protected String[] splitValue(final String value)
-	{
-		return Strings.split(value, FormComponent.VALUE_SEPARATOR.charAt(0));
-	}
-
-	/**
-	 * Join all fragments into one Cookie value
-	 * 
-	 * @param values
-	 * @return The cookie's value split into its constituent parts
-	 * @deprecated Cookies with multiple values are no more supported (WICKET-5648). This method will be removed in Wicket 7.x
-	 */
-	@Deprecated
-	protected String joinValues(final String... values)
-	{
-		return Strings.join(FormComponent.VALUE_SEPARATOR, values);
-	}
-
-	/**
 	 * Create a Cookie with key and value and save it in the browser with the next response
 	 * 
 	 * @param key
 	 *          The cookie name
-	 * @param values
-	 *          The cookie values
+	 * @param value
+	 *          The cookie value
 	 */
-	public final void save(String key, final String... values)
+	public final void save(String key, final String value)
 	{
 		key = getSaveKey(key);
-		String value = joinValues(values);
 		Cookie cookie = getCookie(key);
 		if (cookie == null)
 		{

http://git-wip-us.apache.org/repos/asf/wicket/blob/304e0f42/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
index 9e6cf40..f32c882 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.wicket.util.cookies;
 
-import static org.hamcrest.Matchers.arrayContaining;
-import static org.hamcrest.Matchers.emptyArray;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.is;
 
@@ -30,7 +28,6 @@ import javax.servlet.http.Cookie;
 
 import org.apache.wicket.Page;
 import org.apache.wicket.WicketTestCase;
-import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.util.cookies.CookieValuePersisterTestPage.TestForm;
 import org.junit.Before;
@@ -130,52 +127,6 @@ public class CookieUtilsTest extends WicketTestCase
 	}
 
 	@Test
-	public void splitValuesNullString()
-	{
-		CookieUtils utils = new CookieUtils();
-		String[] values = utils.splitValue(null);
-		assertArrayEquals(new String[0], values);
-	}
-
-	@Test
-	public void splitValuesEmptyString()
-	{
-		CookieUtils utils = new CookieUtils();
-		String[] values = utils.splitValue("");
-		assertThat(values, is(emptyArray()));
-	}
-
-	@Test
-	public void splitValuesSingleValue()
-	{
-		CookieUtils utils = new CookieUtils();
-		String value1 = "value one";
-		String[] values = utils.splitValue(value1);
-		assertThat(values, is(arrayContaining(value1)));
-	}
-
-	@Test
-	public void splitValuesManyValues()
-	{
-		CookieUtils utils = new CookieUtils();
-		String value1 = "value one";
-		String value2 = "value two";
-		String value = value1 + FormComponent.VALUE_SEPARATOR + value2;
-		String[] values = utils.splitValue(value);
-		assertThat(values, is(arrayContaining(value1, value2)));
-	}
-
-	@Test
-	public void joinValues()
-	{
-		CookieUtils utils = new CookieUtils();
-		String value1 = "value one";
-		String value2 = "value two";
-		String joined = utils.joinValues(value1, value2);
-		assertThat(joined, is(equalTo(value1 + FormComponent.VALUE_SEPARATOR + value2)));
-	}
-
-	@Test
 	public void saveLoadValue()
 	{
 		CookieUtils utils = new CookieUtils();


[2/3] git commit: WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Posted by mg...@apache.org.
WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Deprecate all multivalue related methods.
It is not possible to deprecate #save(Strng key, String... values) because most of the time it is used by the applications as #save(key, value)

(cherry picked from commit f7e66e61e3097d32b7767890208436b508747ef1)


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/b590d19b
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/b590d19b
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/b590d19b

Branch: refs/heads/master
Commit: b590d19bab446b2e8983b36d4f42c71e018d4bcd
Parents: 388b150
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Aug 4 12:12:34 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Aug 4 12:21:20 2014 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/util/cookies/CookieUtils.java    | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/b590d19b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
index 0f1f315..1859d96 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
@@ -135,7 +135,7 @@ public class CookieUtils
 		if (value != null)
 		{
 			// Assign the retrieved/persisted value to the component
-			formComponent.setModelValue(splitValue(value));
+			formComponent.setModelValue(new String[] {value});
 		}
 		return value;
 	}
@@ -145,7 +145,9 @@ public class CookieUtils
 	 * 
 	 * @param value
 	 * @return The cookie's value split into fragments
+	 * @deprecated Cookies with multiple values are no more supported (WICKET-5648). This method will be removed in Wicket 7.x
 	 */
+	@Deprecated
 	protected String[] splitValue(final String value)
 	{
 		return Strings.split(value, FormComponent.VALUE_SEPARATOR.charAt(0));
@@ -156,7 +158,9 @@ public class CookieUtils
 	 * 
 	 * @param values
 	 * @return The cookie's value split into its constituent parts
+	 * @deprecated Cookies with multiple values are no more supported (WICKET-5648). This method will be removed in Wicket 7.x
 	 */
+	@Deprecated
 	protected String joinValues(final String... values)
 	{
 		return Strings.join(FormComponent.VALUE_SEPARATOR, values);
@@ -255,18 +259,19 @@ public class CookieUtils
 
 		try
 		{
-			Cookie cookie = getWebRequest().getCookie(key);
+			WebRequest webRequest = getWebRequest();
+			Cookie cookie = webRequest.getCookie(key);
 			if (log.isDebugEnabled())
 			{
 				if (cookie != null)
 				{
 					log.debug("Found Cookie with name=" + key + " and request URI=" +
-						getWebRequest().getUrl().toString());
+							webRequest.getUrl().toString());
 				}
 				else
 				{
 					log.debug("Unable to find Cookie with name=" + key + " and request URI=" +
-						getWebRequest().getUrl().toString());
+							webRequest.getUrl().toString());
 				}
 			}