Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-04-01 21:22:33 +0000
committerChris Goldthorpe2010-04-01 21:22:33 +0000
commit5ae5529c9109d830b1e0bd2d5287e66f42afe3e7 (patch)
tree09fa83b7d8e8594cec9bc46f1ea0939305016c32 /org.eclipse.ua.tests
parentf919343dda7230ec1c1b08715a5cc4acc985afd0 (diff)
downloadeclipse.platform.ua-5ae5529c9109d830b1e0bd2d5287e66f42afe3e7.tar.gz
eclipse.platform.ua-5ae5529c9109d830b1e0bd2d5287e66f42afe3e7.tar.xz
eclipse.platform.ua-5ae5529c9109d830b1e0bd2d5287e66f42afe3e7.zip
Reduce encryption of scope cookie - [Webapp] Search scope cookie file reaches max size quickly, limits creation of new scopes
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java3
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/UrlCoderTest.java120
2 files changed, 122 insertions, 1 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java
index ca3442a23..c140469d1 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,6 +29,7 @@ public class AllWebappTests extends TestSuite {
suite.addTestSuite(TopicPathTest.class);
suite.addTestSuite(FilterTest.class);
suite.addTestSuite(PluginsRootReplacement.class);
+ suite.addTestSuite(UrlCoderTest.class);
suite.addTestSuite(UrlUtilsTests.class);
suite.addTestSuite(LocaleTest.class);
suite.addTestSuite(RestrictedTopicParameter.class);
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/UrlCoderTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/UrlCoderTest.java
new file mode 100644
index 000000000..4da540f1c
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/UrlCoderTest.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ua.tests.help.webapp;
+
+import junit.framework.TestCase;
+
+import org.eclipse.help.internal.util.URLCoder;
+
+public class UrlCoderTest extends TestCase {
+
+ private static final String SPECIAL_CHARACTERS = "!@#$%^&*()_+-={}[]:\";'<>,.?/'";
+ private static final String ALPHANUMERIC = "Bxz91r";
+ private static final String ALPHA = "acgrdft";
+ private static final String EMPTY_STRING = "";
+ private static final String ACCENTED = "seg\u00FAn cu\u00E1l oto\u00F1o";
+ private static final String CHINESE = "\u4ECA\u5929\u662F\u5929";
+
+ private void encodeDecode(String value) {
+ String encoded = URLCoder.encode(value);
+ assertEquals(value, URLCoder.decode(encoded));
+ }
+
+ private void compactEncodeDecode(String value) {
+ String encoded = URLCoder.compactEncode(value);
+ assertEquals(value, URLCoder.decode(encoded));
+ }
+
+ private boolean compactEncodingIsShorter(String value) {
+ String compactEncoded = URLCoder.compactEncode(value);
+ String encoded = URLCoder.encode(value);
+ return compactEncoded.length() < encoded.length();
+ }
+
+ public void testEncodeEmpty() {
+ encodeDecode(EMPTY_STRING);
+ }
+
+ public void testEncodeAlphabetic() {
+ encodeDecode(ALPHA);
+ }
+
+ public void testEncodeAlphaNumeric() {
+ encodeDecode(ALPHANUMERIC);
+ }
+
+ public void testEncodeSpecialCharacters() {
+ encodeDecode(SPECIAL_CHARACTERS);
+ }
+
+ public void testEncodeAccented() {
+ encodeDecode(ACCENTED);
+ }
+
+ public void testEncodeChinese() {
+ encodeDecode(CHINESE);
+ }
+
+ // Compact Encodings
+
+ public void testCompactEncodeEmpty() {
+ compactEncodeDecode(EMPTY_STRING);
+ }
+
+ public void testCompactEncodeAlphabetic() {
+ compactEncodeDecode(ALPHA);
+ }
+
+ public void testCompactEncodeAlphaNumeric() {
+ compactEncodeDecode(ALPHANUMERIC);
+ }
+
+ public void testCompactEncodeSpecialCharacters() {
+ compactEncodeDecode(SPECIAL_CHARACTERS);
+ }
+
+ public void testCompactEncodeAccented() {
+ compactEncodeDecode(ACCENTED);
+ }
+
+ public void testCompactEncodeChinese() {
+ compactEncodeDecode(CHINESE);
+ }
+
+ // Verify compaction
+
+
+ public void testCompactionEmpty() {
+ assertFalse(compactEncodingIsShorter(EMPTY_STRING));
+ }
+
+ public void testCompactionAlphabetic() {
+ assertTrue(compactEncodingIsShorter(ALPHA));
+ }
+
+ public void testCompactionAlphaNumeric() {
+ assertTrue(compactEncodingIsShorter(ALPHANUMERIC));
+ }
+
+ public void testCompactionSpecialCharacters() {
+ assertFalse(compactEncodingIsShorter(SPECIAL_CHARACTERS));
+ }
+
+ public void testCompactionAccented() {
+ assertTrue(compactEncodingIsShorter(ACCENTED));
+ }
+
+ public void testCompactionChinese() {
+ assertFalse(compactEncodingIsShorter(CHINESE));
+ }
+
+}

Back to the top