You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by gi...@apache.org on 2014/07/20 13:02:42 UTC

svn commit: r1612074 - in /santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax: c14n/Canonicalizer20010315Test.java transformer/TransformIdentityTest.java utils/UnixInputStream.java

Author: giger
Date: Sun Jul 20 11:02:41 2014
New Revision: 1612074

URL: http://svn.apache.org/r1612074
Log:
fix failing tests on windows

Added:
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/utils/UnixInputStream.java   (with props)
Modified:
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java?rev=1612074&r1=1612073&r2=1612074&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java Sun Jul 20 11:02:41 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.xml.security.test.stax.c14n;
 
+import org.apache.xml.security.test.stax.utils.UnixInputStream;
 import org.junit.Test;
 
 import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
@@ -393,7 +394,7 @@ public class Canonicalizer20010315Test e
 
         byte[] reference =
                 getBytesFromResource(this.getClass().getClassLoader().getResource(
-                        "org/apache/xml/security/c14n/in/default_ns_redefinition_c14n.xml"));
+                        "org/apache/xml/security/c14n/in/default_ns_redefinition_c14n.xml"), true);
         boolean equals = java.security.MessageDigest.isEqual(reference, baos.toByteArray());
 
         if (!equals) {
@@ -718,11 +719,17 @@ public class Canonicalizer20010315Test e
         assertTrue(result);
     }
 
-
     public static byte[] getBytesFromResource(URL resource) throws IOException {
+        return getBytesFromResource(resource, false);
+    }
+
+    public static byte[] getBytesFromResource(URL resource, boolean unix) throws IOException {
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         InputStream inputStream = resource.openStream();
+        if (unix) {
+            inputStream = new UnixInputStream(inputStream);
+        }
         try {
             byte buf[] = new byte[1024];
             int len;

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java?rev=1612074&r1=1612073&r2=1612074&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java Sun Jul 20 11:02:41 2014
@@ -25,6 +25,7 @@ import org.apache.xml.security.stax.ext.
 import org.apache.xml.security.stax.ext.XMLSecurityUtils;
 import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
 import org.apache.xml.security.stax.impl.transformer.TransformIdentity;
+import org.apache.xml.security.test.stax.utils.UnixInputStream;
 import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
 import org.junit.Assert;
 import org.junit.Before;
@@ -231,8 +232,8 @@ public class TransformIdentityTest exten
         final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
         transformIdentity.setOutputStream(byteArrayOutputStream);
 
-        transformIdentity.transform(this.getClass().getClassLoader().getResourceAsStream(
-                "ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/xml-stylesheet.b64"));
+        transformIdentity.transform(new UnixInputStream(this.getClass().getClassLoader().getResourceAsStream(
+                "ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/xml-stylesheet.b64")));
 
         Assert.assertEquals(17786, byteArrayOutputStream.size());
     }
@@ -277,8 +278,8 @@ public class TransformIdentityTest exten
 
         transformIdentity.setTransformer(transformer);
 
-        transformIdentity.transform(this.getClass().getClassLoader().getResourceAsStream(
-                "ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext-base64.xml"));
+        transformIdentity.transform(new UnixInputStream(this.getClass().getClassLoader().getResourceAsStream(
+                "ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext-base64.xml")));
 
         transformIdentity.doFinal();
 

Added: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/utils/UnixInputStream.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/utils/UnixInputStream.java?rev=1612074&view=auto
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/utils/UnixInputStream.java (added)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/utils/UnixInputStream.java Sun Jul 20 11:02:41 2014
@@ -0,0 +1,53 @@
+/**
+ * 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.xml.security.test.stax.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Simple and stupid dos/windows to unix line ending converter.
+ * It's used to convert testdata to unix style independent on the
+ * platform running on. This is just a workaround for "svn:eol-style" set
+ * to native
+ *
+ * It's inefficient and simply suppresses the output of '\r' which
+ * is not correct in every case. So do not use it in productive code.
+ *
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class UnixInputStream extends InputStream {
+
+    private InputStream inputStream;
+
+    public UnixInputStream(InputStream in) {
+        super();
+        this.inputStream = in;
+    }
+
+    @Override
+    public int read() throws IOException {
+        int read = inputStream.read();
+        if (read == '\r') {
+            return inputStream.read();
+        }
+        return read;
+    }
+}

Propchange: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/utils/UnixInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/utils/UnixInputStream.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision