aboutsummaryrefslogtreecommitdiff
path: root/common/src/test/java/test/at/gv/egovernment/moa/util/URLEncoderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/test/java/test/at/gv/egovernment/moa/util/URLEncoderTest.java')
-rw-r--r--common/src/test/java/test/at/gv/egovernment/moa/util/URLEncoderTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/common/src/test/java/test/at/gv/egovernment/moa/util/URLEncoderTest.java b/common/src/test/java/test/at/gv/egovernment/moa/util/URLEncoderTest.java
new file mode 100644
index 000000000..f5fbf4537
--- /dev/null
+++ b/common/src/test/java/test/at/gv/egovernment/moa/util/URLEncoderTest.java
@@ -0,0 +1,58 @@
+/*
+* Copyright 2003 Federal Chancellery Austria
+*
+* Licensed 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 test.at.gv.egovernment.moa.util;
+
+import at.gv.egovernment.moa.util.FileUtils;
+import at.gv.egovernment.moa.util.URLDecoder;
+import at.gv.egovernment.moa.util.URLEncoder;
+import junit.framework.TestCase;
+
+/*
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class URLEncoderTest extends TestCase {
+
+ public void testUnchangedString() throws Exception {
+ String s = "AZaz0123456789.-*_";
+ String senc = URLEncoder.encode(s, "UTF-8");
+ assertEquals(s, senc);
+ }
+ public void testAumlUTF8() throws Exception {
+ String s = "ä";
+ String senc = URLEncoder.encode(s, "UTF-8");
+ assertEquals("%C3%A4", senc);
+ }
+ public void testEncodeDecode() throws Exception {
+ String s = "AZaz09.-*_ <>%=$%&/()@?{}[]\\\"'äöüÄÖÜߧ";
+ String senc = URLEncoder.encode(s, "UTF-8");
+ String sdec = URLDecoder.decode(senc, "UTF-8");
+ assertEquals(s, sdec);
+ }
+ public void testCertInfo() throws Exception {
+ String s = new String(FileUtils.readFile("data/test/xml/VerifyXMLSignature/CertInfoVerifyXMLSignatureRequest.xml", "UTF-8"));
+ String senc = URLEncoder.encode(s, "UTF-8");
+ String sdec = URLDecoder.decode(senc, "UTF-8");
+ assertEquals(s, sdec);
+ }
+ /*public void testJDK14() throws Exception {
+ String s = new String(FileUtils.readFile("data/test/xml/VerifyXMLSignature/CertInfoVerifyXMLSignatureRequest.xml", "UTF-8"));
+ String senc = URLEncoder.encode(s, "UTF-8");
+ String senc14 = java.net.URLEncoder.encode(s, "UTF-8");
+ assertEquals(senc, senc14);
+ }*/
+
+}