You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2018/07/22 16:42:48 UTC

[2/2] wicket git commit: WICKET-6568 added test

WICKET-6568 added test


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

Branch: refs/heads/WICKET-6563
Commit: 409cef886cfd5ae70261dfcbb369038796a9767a
Parents: f6a195d
Author: Sven Meier <sv...@apache.org>
Authored: Sun Jul 22 17:35:27 2018 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Sun Jul 22 17:36:09 2018 +0200

----------------------------------------------------------------------
 .../wicket/ajax/AjaxRequestHandlerTest.java     | 21 ++++++++++
 .../java/org/apache/wicket/ajax/FocusPage.html  |  6 +++
 .../java/org/apache/wicket/ajax/FocusPage.java  | 40 ++++++++++++++++++++
 3 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/409cef88/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
index 90b35f6..8c90304 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
@@ -18,6 +18,7 @@ package org.apache.wicket.ajax;
 
 import java.io.IOException;
 import java.lang.reflect.Constructor;
+import java.nio.charset.Charset;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -30,6 +31,7 @@ import org.apache.wicket.event.IEvent;
 import org.apache.wicket.markup.IMarkupResourceStreamProvider;
 import org.apache.wicket.markup.html.WebComponent;
 import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.util.encoding.UrlEncoder;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.StringResourceStream;
 import org.apache.wicket.util.tester.DiffUtil;
@@ -181,6 +183,25 @@ public class AjaxRequestHandlerTest extends WicketTestCase
 	}
 
 	/**
+	 * WICKET-6568
+	 */
+	@Test
+	public void lastFocusedEncoding()
+	{
+		FocusPage page = new FocusPage();
+		
+		tester.startPage(page);
+
+		// wicket-ajax-jquery encodes non ASCII id
+		String encoded = UrlEncoder.QUERY_INSTANCE.encode("€uro", Charset.forName("UTF-8"));
+		tester.getRequest().setHeader("Wicket-FocusedElementId", encoded);
+		
+		tester.executeAjaxEvent("link", "click");
+
+		assertEquals("€uro", page.lastFocusedElementId);
+	}
+
+	/**
 	 * WICKET-2543
 	 */
 	@Test

http://git-wip-us.apache.org/repos/asf/wicket/blob/409cef88/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html
new file mode 100644
index 0000000..b6b9b35
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html
@@ -0,0 +1,6 @@
+<html>
+    <body>
+        <a wicket:id="link"></a>
+    </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/wicket/blob/409cef88/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java
new file mode 100644
index 0000000..8f94d73
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ */
+public class FocusPage extends WebPage
+{
+	private static final long serialVersionUID = 1L;
+	
+	public String lastFocusedElementId;
+
+	public FocusPage( ) {
+		add(new AjaxLink<Void>("link")
+		{
+			@Override
+			public void onClick(AjaxRequestTarget target)
+			{
+				lastFocusedElementId = target.getLastFocusedElementId();
+			}
+		});
+	}
+}