summaryrefslogtreecommitdiff
path: root/utils/src/test/java/at
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-09-29 17:36:06 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-09-29 17:36:06 +0000
commitbd070e82c276afb8c1c3a9ddc3b5712783760881 (patch)
treed33ea8232d66b339554b3fbf41cb5ca846efc1e3 /utils/src/test/java/at
parent9d4b3e9214f653d2556608958642d02814d4e7a3 (diff)
downloadmocca-bd070e82c276afb8c1c3a9ddc3b5712783760881.tar.gz
mocca-bd070e82c276afb8c1c3a9ddc3b5712783760881.tar.bz2
mocca-bd070e82c276afb8c1c3a9ddc3b5712783760881.zip
Logging issues fixed:
- Added possibility to configure logging of BKUWebstart. Logging is now configured from log4j configuration deployed with BKUWebstart in a first step. In a second step the webstart launcher looks for a log4j configuration file in the user's mooca configuration directory and updates the log4j configuration. - Logging of IAIK PKI properly initialized. IAIK PKI does not mess with the log4j configuration any longer. - Changed log4j accordingly (an appender is now needed as IAIK PKI does not reconfigure log4j any longer). Added css-stylesheet to ErrorResponses issued by the BKU to improve the presentation to the user. Changed dependencies of BKUWebStart (see Issue#469 https://egovlabs.gv.at/tracker/index.php?func=detail&aid=469&group_id=13&atid=134). DataURLConnection now uses the request encoding of SL < 1.2. application/x-www-form-urlencoded is now used as default encoding method. multipart/form-data is used only if transfer parameters are present in the request that require a Content-Type parameter. This can only be set with multipart/form-data. This is not in conformance with SL 1.2, however it should improve compatibility with applications. Therefore, removed the ability to configure the DataURLConnection implementation class. DataURLConnection now uses a streaming implementation for encoding of application/x-www-form-urlencoded requests. XWWWFormUrlImputDecoder now uses a streaming implementation for decoding of application/x-www-form-urlencoded requests. Fixed Bug in SLResultPart that caused a binary response to be provided as parameter "XMLResponse" in a multipart/form-data encoded request to DataURL. SLCommandFactory now supports unmarshalling of SL < 1.2 requests in order issue meaningful error messages. Therefore, the marshaling context for response marshaling had to be separated from the marshaling context for requests in order to avoid the marshaling of SL < 1.2 namespace prefixes in SL 1.2 responses. Target attribute in QualifiedProperties is now marshaled. (see Issue#470 https://egovlabs.gv.at/tracker/index.php?func=detail&aid=470&group_id=13&atid=134) Reporting of XML validation errors improved. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@510 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'utils/src/test/java/at')
-rw-r--r--utils/src/test/java/at/gv/egiz/bku/utils/URLEncodingOutputStreamTest.java147
1 files changed, 147 insertions, 0 deletions
diff --git a/utils/src/test/java/at/gv/egiz/bku/utils/URLEncodingOutputStreamTest.java b/utils/src/test/java/at/gv/egiz/bku/utils/URLEncodingOutputStreamTest.java
new file mode 100644
index 00000000..e92b9584
--- /dev/null
+++ b/utils/src/test/java/at/gv/egiz/bku/utils/URLEncodingOutputStreamTest.java
@@ -0,0 +1,147 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* 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 at.gv.egiz.bku.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class URLEncodingOutputStreamTest {
+
+ private static String buf;
+
+ private static Charset UTF_8 = Charset.forName("UTF-8");
+
+ @BeforeClass
+ public static void setUpClass() throws IOException {
+
+ ClassLoader cl = URLEncodingOutputStreamTest.class.getClassLoader();
+ InputStream is = cl.getResourceAsStream("BigRequest.xml");
+
+ assertNotNull(is);
+
+ InputStreamReader reader = new InputStreamReader(is, UTF_8);
+
+ StringBuilder sb = new StringBuilder();
+
+ char[] b = new char[512];
+ for (int l; (l = reader.read(b)) != -1;) {
+ sb.append(b, 0, l);
+ }
+
+ buf = sb.toString();
+
+ }
+
+ @Test
+ public void testCompareResults() throws IOException {
+
+ String out1;
+ String out2;
+
+ // new
+ StringWriter writer = new StringWriter();
+ URLEncodingOutputStream urlEnc = new URLEncodingOutputStream(writer);
+ OutputStreamWriter streamWriter = new OutputStreamWriter(urlEnc, UTF_8);
+ streamWriter.append(buf);
+ streamWriter.flush();
+ out1 = writer.toString();
+
+ // URLEncoder
+ out2 = URLEncoder.encode(buf, UTF_8.name());
+
+ for (int i = 0; i < out1.length(); i++) {
+ if (out1.charAt(i) != out2.charAt(i)) {
+ System.out.println(i + ": " + out1.substring(i));
+ System.out.println(i + ": " + out2.substring(i));
+ }
+ }
+
+ assertEquals(out1, out2);
+
+ }
+
+ @Ignore
+ @Test
+ public void testURLEncodingOutputStream() throws IOException {
+
+ NullWriter writer = new NullWriter();
+
+ URLEncodingOutputStream urlEnc = new URLEncodingOutputStream(writer);
+ OutputStreamWriter streamWriter = new OutputStreamWriter(urlEnc, UTF_8);
+
+ long t0, t1, dt = 0;
+ for (int run = 0; run < 1000; run++) {
+ t0 = System.currentTimeMillis();
+ streamWriter.append(buf);
+ t1 = System.currentTimeMillis();
+ if (run > 1) {
+ dt += t1 - t0;
+ }
+ }
+ System.out.println("Time " + dt + "ms");
+
+ }
+
+ @Ignore
+ @Test
+ public void testURLEncodingNaive() throws IOException {
+
+ String in = new String(buf);
+
+ long t0, t1, dt = 0;
+ for (int run = 0; run < 1000; run++) {
+ t0 = System.currentTimeMillis();
+ URLEncoder.encode(in, "UTF-8");
+ t1 = System.currentTimeMillis();
+ if (run > 1) {
+ dt += t1 - t0;
+ }
+ }
+ System.out.println("Time (naive) " + dt + "ms");
+
+ }
+
+ public class NullWriter extends Writer {
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public void flush() throws IOException {
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ }
+
+ }
+
+}