cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: Some minor fixes
Date Wed, 21 Oct 2015 13:05:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/master af7de1d82 -> 07297f3c7


Some minor fixes


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/07297f3c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/07297f3c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/07297f3c

Branch: refs/heads/master
Commit: 07297f3c75c3d16a6d81b423d545ababd714f5b9
Parents: af7de1d
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Oct 21 14:05:03 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Oct 21 14:05:17 2015 +0100

----------------------------------------------------------------------
 .../apache/cxf/configuration/jsse/SSLUtils.java | 48 ++++--------------
 .../saml/authorization/SubjectPrincipal.java    | 35 +++++++++++++
 .../cxf/rt/security/saml/claims/SAMLClaim.java  | 53 ++++++++++++++++++++
 .../transport/https/CertConstraintsTest.java    | 15 +++---
 .../ws/security/wss4j/CXFCallbackLookup.java    |  1 +
 ...ServerResourceCreatedSpringProviderTest.java |  1 +
 systests/kerberos/pom.xml                       |  6 ---
 .../jaxrs/kerberos/JAXRSKerberosBookTest.java   | 23 ++++-----
 .../systest/kerberos/ldap/LDAPClaimsTest.java   | 19 +++----
 .../wssec/kerberos/KerberosTokenTest.java       | 21 +++-----
 .../kerberos/wssec/spnego/SpnegoTokenTest.java  | 21 +++-----
 .../cxf/tools/common/ProcessorTestBase.java     | 22 +-------
 .../apache/cxf/tools/corba/WSDLToIDLTest.java   | 43 ++++++----------
 .../wsdlto/javascript/WSDLToJavaScriptTest.java | 24 +++++----
 .../cxf/tools/wsdlto/jaxws/CodeGenBugTest.java  | 16 +++---
 15 files changed, 177 insertions(+), 171 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
index 43f725b..b485f3e 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
@@ -20,12 +20,13 @@
 package org.apache.cxf.configuration.jsse;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.security.KeyManagementException;
 import java.security.KeyStore;
 import java.security.NoSuchAlgorithmException;
@@ -108,12 +109,8 @@ public final class SSLUtils {
         KeyStore ks = KeyStore.getInstance(keyStoreType);
         
         if (keyStoreType.equalsIgnoreCase(PKCS12_TYPE)) {
-            byte[] bytes = null;
-            try (FileInputStream fis = new FileInputStream(keyStoreLocation);
-                DataInputStream dis = new DataInputStream(fis)) {
-                bytes = new byte[dis.available()];
-                dis.readFully(bytes);
-            }
+            Path path = FileSystems.getDefault().getPath(keyStoreLocation);
+            byte[] bytes = Files.readAllBytes(path);
             ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
             
             if (keyStorePassword != null) {
@@ -125,7 +122,7 @@ public final class SSLUtils {
                                                 log);
             }
         } else {        
-            byte[] sslCert = loadClientCredential(keyStoreLocation);
+            byte[] sslCert = loadFile(keyStoreLocation);
             
             if (sslCert != null && sslCert.length > 0 && keyStorePassword
!= null) {
                 ByteArrayInputStream bin = new ByteArrayInputStream(sslCert);
@@ -233,7 +230,7 @@ public final class SSLUtils {
             
             trustedCertStore.load(null, "".toCharArray());
             CertificateFactory cf = CertificateFactory.getInstance(CERTIFICATE_FACTORY_TYPE);
-            byte[] caCert = loadCACert(trustStoreLocation);
+            byte[] caCert = loadFile(trustStoreLocation);
             try {
                 if (caCert != null) {
                     ByteArrayInputStream cabin = new ByteArrayInputStream(caCert);
@@ -258,37 +255,12 @@ public final class SSLUtils {
         return tmf.getTrustManagers();
     }
     
-    protected static byte[] loadClientCredential(String fileName) throws IOException {
+    protected static byte[] loadFile(String fileName) throws IOException {
         if (fileName == null) {
             return null;
         }
-        try (FileInputStream in = new FileInputStream(fileName);
-            ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-            byte[] buf = new byte[512];
-            int i = in.read(buf);
-            while (i  > 0) {
-                out.write(buf, 0, i);
-                i = in.read(buf);
-            }
-            return out.toByteArray();
-        }
-    }
-
-    protected static byte[] loadCACert(String fileName) throws IOException {
-        if (fileName == null) {
-            return null;
-        }
-        try (FileInputStream in = new FileInputStream(fileName);
-            ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-            byte[] buf = new byte[512];
-            int i = in.read(buf);
-        
-            while (i > 0) {
-                out.write(buf, 0, i);
-                i = in.read(buf);
-            }
-            return out.toByteArray();
-        }
+        Path path = FileSystems.getDefault().getPath(fileName);
+        return Files.readAllBytes(path);
     }
 
     public static String getKeystore(String keyStoreLocation, Logger log) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/authorization/SubjectPrincipal.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/authorization/SubjectPrincipal.java
b/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/authorization/SubjectPrincipal.java
index cbeecf5..02911d9 100644
--- a/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/authorization/SubjectPrincipal.java
+++ b/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/authorization/SubjectPrincipal.java
@@ -33,4 +33,39 @@ public class SubjectPrincipal extends SimplePrincipal {
     public Subject getSubject() {
         return subject;
     }
+    
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        
+        if (!super.equals(obj)) {
+            return false;
+        }
+        
+        if (!(obj instanceof SubjectPrincipal)) {
+            return false;
+        }
+        
+        if (subject == null && ((SubjectPrincipal)obj).getSubject() != null) {
+            return false;
+        } else if (subject != null
+            && !subject.equals(((SubjectPrincipal)obj).getSubject())) {
+            return false;
+        }
+        
+        return true;
+    }
+    
+    @Override
+    public int hashCode() {
+        int hashCode = super.hashCode();
+        if (subject != null) {
+            hashCode = 31 * hashCode + subject.hashCode();
+        }
+        
+        return hashCode;
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/rt/security-saml/src/main/java/org/apache/cxf/rt/security/saml/claims/SAMLClaim.java
----------------------------------------------------------------------
diff --git a/rt/security-saml/src/main/java/org/apache/cxf/rt/security/saml/claims/SAMLClaim.java
b/rt/security-saml/src/main/java/org/apache/cxf/rt/security/saml/claims/SAMLClaim.java
index 5fb080d..9fdac73 100644
--- a/rt/security-saml/src/main/java/org/apache/cxf/rt/security/saml/claims/SAMLClaim.java
+++ b/rt/security-saml/src/main/java/org/apache/cxf/rt/security/saml/claims/SAMLClaim.java
@@ -64,5 +64,58 @@ public class SAMLClaim extends Claim {
         this.friendlyName = friendlyName;
     }
     
+    @Override
+    public int hashCode() {
+        int hashCode = super.hashCode();
+        
+        if (nameFormat != null) {
+            hashCode = 31 * hashCode + nameFormat.hashCode();
+        }
+        if (name != null) {
+            hashCode = 31 * hashCode + name.hashCode();
+        }
+        if (friendlyName != null) {
+            hashCode = 31 * hashCode + friendlyName.hashCode();
+        }
+        
+        return hashCode;
+    }
     
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        
+        if (!super.equals(obj)) {
+            return false;
+        }
+        
+        if (!(obj instanceof SAMLClaim)) {
+            return false;
+        }
+        
+        if (nameFormat == null && ((SAMLClaim)obj).getNameFormat() != null) {
+            return false;
+        } else if (nameFormat != null
+            && !nameFormat.equals(((SAMLClaim)obj).getNameFormat())) {
+            return false;
+        }
+        
+        if (name == null && ((SAMLClaim)obj).getName() != null) {
+            return false;
+        } else if (name != null
+             && !name.equals(((SAMLClaim)obj).getName())) {
+            return false;
+        }
+        
+        if (friendlyName == null && ((SAMLClaim)obj).getFriendlyName() != null) {
+            return false;
+        } else if (friendlyName != null
+            && !friendlyName.equals(((SAMLClaim)obj).getFriendlyName())) {
+            return false;
+        }
+        
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/rt/transports/http/src/test/java/org/apache/cxf/transport/https/CertConstraintsTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/test/java/org/apache/cxf/transport/https/CertConstraintsTest.java
b/rt/transports/http/src/test/java/org/apache/cxf/transport/https/CertConstraintsTest.java
index dfa941f..964e556 100644
--- a/rt/transports/http/src/test/java/org/apache/cxf/transport/https/CertConstraintsTest.java
+++ b/rt/transports/http/src/test/java/org/apache/cxf/transport/https/CertConstraintsTest.java
@@ -21,8 +21,9 @@
 package org.apache.cxf.transport.https;
 
 import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.security.KeyStore;
 import java.security.cert.X509Certificate;
 
@@ -116,12 +117,10 @@ public class CertConstraintsTest extends org.junit.Assert {
         final String id
     ) throws Exception {
         final KeyStore store = KeyStore.getInstance(keystoreType);
-        FileInputStream fis = new FileInputStream(
-                "src/test/java/org/apache/cxf/transport/https/resources/" + keystoreFilename);
-        DataInputStream dis = new DataInputStream(fis);
-        byte[] bytes = new byte[dis.available()];
-        dis.readFully(bytes);
-        dis.close();
+        Path path = 
+            FileSystems.getDefault().getPath("src/test/java/org/apache/cxf/transport/https/resources/",

+                                             keystoreFilename);
+        byte[] bytes = Files.readAllBytes(path);
         ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
         store.load(bin, keystorePassword.toCharArray());
         for (java.util.Enumeration<String> aliases = store.aliases(); aliases.hasMoreElements();)
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CXFCallbackLookup.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CXFCallbackLookup.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CXFCallbackLookup.java
index be8dbe0..31b3ff6 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CXFCallbackLookup.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CXFCallbackLookup.java
@@ -34,6 +34,7 @@ public class CXFCallbackLookup extends DOMCallbackLookup {
     
     public CXFCallbackLookup(Document doc, Element soapBody) {
         super(doc);
+        this.doc = doc;
         this.soapBody = soapBody;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
index 1ccd4e9..ff99951 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
@@ -290,6 +290,7 @@ public class JAXRSClientServerResourceCreatedSpringProviderTest extends
Abstract
         httpUrlConnection.setRequestProperty("Connection",   "close");   
 
         OutputStream outputstream = httpUrlConnection.getOutputStream();
+        
         File inputFile = new File(getClass().getResource("resources/singleValPostBody.txt").toURI());
        
          
         byte[] tmp = new byte[4096];

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/systests/kerberos/pom.xml
----------------------------------------------------------------------
diff --git a/systests/kerberos/pom.xml b/systests/kerberos/pom.xml
index cd4ea37..0b2c54c 100644
--- a/systests/kerberos/pom.xml
+++ b/systests/kerberos/pom.xml
@@ -268,12 +268,6 @@
             </exclusions>
         </dependency>
         <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.4</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.springframework.ldap</groupId>
             <artifactId>spring-ldap-core</artifactId>
             <version>${cxf.spring.ldap.version}</version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
----------------------------------------------------------------------
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
index 2c06094..18079d1 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
@@ -20,10 +20,10 @@
 package org.apache.cxf.systest.kerberos.jaxrs.kerberos;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
@@ -109,21 +109,16 @@ public class JAXRSKerberosBookTest extends AbstractLdapTestUnit {
             if (basedir == null) {
                 basedir = new File(".").getCanonicalPath();
             }
-            
+
             // Read in krb5.conf and substitute in the correct port
-            File f = new File(basedir + "/src/test/resources/krb5.conf");
-            
-            FileInputStream inputStream = new FileInputStream(f);
-            String content = IOUtils.toString(inputStream, "UTF-8");
-            inputStream.close();
+            Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/krb5.conf");
+            String content = new String(Files.readAllBytes(path), "UTF-8");
             content = content.replaceAll("port", "" + super.getKdcServer().getTransports()[0].getPort());
             
-            File f2 = new File(basedir + "/target/test-classes/jaxrs.krb5.conf");
-            FileOutputStream outputStream = new FileOutputStream(f2);
-            IOUtils.write(content, outputStream, "UTF-8");
-            outputStream.close();
+            Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/jaxrs.krb5.conf");
+            Files.write(path2, content.getBytes());
             
-            System.setProperty("java.security.krb5.conf", f2.getPath());
+            System.setProperty("java.security.krb5.conf", path2.toString());
             
             portUpdated = true;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
----------------------------------------------------------------------
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
index a14e312..bdd2f80 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
@@ -21,10 +21,11 @@ package org.apache.cxf.systest.kerberos.ldap;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.net.URI;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
@@ -32,7 +33,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.rt.security.claims.Claim;
 import org.apache.cxf.rt.security.claims.ClaimCollection;
@@ -112,17 +112,12 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
             }
             
             // Read in ldap.xml and substitute in the correct port
-            File f = new File(basedir + "/src/test/resources/ldap.xml");
-            
-            FileInputStream inputStream = new FileInputStream(f);
-            String content = IOUtils.toString(inputStream, "UTF-8");
-            inputStream.close();
+            Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/ldap.xml");
+            String content = new String(Files.readAllBytes(path), "UTF-8");
             content = content.replaceAll("portno", "" + super.getLdapServer().getPort());
             
-            File f2 = new File(basedir + "/target/test-classes/ldapport.xml");
-            FileOutputStream outputStream = new FileOutputStream(f2);
-            IOUtils.write(content, outputStream, "UTF-8");
-            outputStream.close();
+            Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/ldapport.xml");
+            Files.write(path2, content.getBytes());
             
             portUpdated = true;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
----------------------------------------------------------------------
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
index db3f485..2ce3786 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
@@ -20,15 +20,15 @@
 package org.apache.cxf.systest.kerberos.wssec.kerberos;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.net.URL;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Service;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.kerberos.common.SecurityTestUtil;
@@ -124,19 +124,14 @@ public class KerberosTokenTest extends AbstractLdapTestUnit {
             }
             
             // Read in krb5.conf and substitute in the correct port
-            File f = new File(basedir + "/src/test/resources/krb5.conf");
-            
-            FileInputStream inputStream = new FileInputStream(f);
-            String content = IOUtils.toString(inputStream, "UTF-8");
-            inputStream.close();
+            Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/krb5.conf");
+            String content = new String(Files.readAllBytes(path), "UTF-8");
             content = content.replaceAll("port", "" + super.getKdcServer().getTransports()[0].getPort());
             
-            File f2 = new File(basedir + "/target/test-classes/wssec.kerberos.krb5.conf");
-            FileOutputStream outputStream = new FileOutputStream(f2);
-            IOUtils.write(content, outputStream, "UTF-8");
-            outputStream.close();
+            Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/wssec.kerberos.krb5.conf");
+            Files.write(path2, content.getBytes());
             
-            System.setProperty("java.security.krb5.conf", f2.getPath());
+            System.setProperty("java.security.krb5.conf", path2.toString());
             
             portUpdated = true;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
----------------------------------------------------------------------
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
index fa343ec..66f1f57 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
@@ -20,14 +20,14 @@
 package org.apache.cxf.systest.kerberos.wssec.spnego;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.net.URL;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.kerberos.common.SecurityTestUtil;
@@ -117,19 +117,14 @@ public class SpnegoTokenTest extends AbstractLdapTestUnit {
             }
             
             // Read in krb5.conf and substitute in the correct port
-            File f = new File(basedir + "/src/test/resources/krb5.conf");
-            
-            FileInputStream inputStream = new FileInputStream(f);
-            String content = IOUtils.toString(inputStream, "UTF-8");
-            inputStream.close();
+            Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/krb5.conf");
+            String content = new String(Files.readAllBytes(path), "UTF-8");
             content = content.replaceAll("port", "" + super.getKdcServer().getTransports()[0].getPort());
             
-            File f2 = new File(basedir + "/target/test-classes/wssec.spnego.krb5.conf");
-            FileOutputStream outputStream = new FileOutputStream(f2);
-            IOUtils.write(content, outputStream, "UTF-8");
-            outputStream.close();
+            Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/wssec.spnego.krb5.conf");
+            Files.write(path2, content.getBytes());
             
-            System.setProperty("java.security.krb5.conf", f2.getPath());
+            System.setProperty("java.security.krb5.conf", path2.toString());
             
             portUpdated = true;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
----------------------------------------------------------------------
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
b/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
index 40558f2..c203a19 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
@@ -20,7 +20,6 @@
 package org.apache.cxf.tools.common;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
@@ -48,7 +47,6 @@ import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.util.ToolsStaxUtils;
 import org.apache.ws.commons.schema.constants.Constants;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.ComparisonFailure;
@@ -200,25 +198,7 @@ public class ProcessorTestBase extends Assert {
     }
 
     public String getStringFromFile(File location) {
-        InputStream is = null;
-        String result = null;
-
-        try {
-            is = new FileInputStream(location);
-            result = FileUtils.normalizeCRLF(is);
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (Exception e) {
-                    //do nothing
-                }
-            }
-        }
-
-        return result;
+        return FileUtils.getStringFromFile(location);
     }
 
     public boolean assertXmlEquals(final File expected, final File source) throws Exception
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
----------------------------------------------------------------------
diff --git a/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java b/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
index 6316fcb..b338d75 100644
--- a/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
+++ b/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
@@ -19,16 +19,16 @@
 
 package org.apache.cxf.tools.corba;
 
-import java.io.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
 import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
@@ -171,14 +171,11 @@ public class WSDLToIDLTest extends ToolTestBase {
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed", noError, exc);
 
-        File f = new File(output, "simple-binding.idl");
-        assertTrue("simple-binding.idl should be generated", f.exists());
-        FileInputStream stream = new FileInputStream(f);            
-        BufferedInputStream bis = new BufferedInputStream(stream); 
-        DataInputStream dis = new DataInputStream(bis);
-        String line = dis.toString();
+        Path path = FileSystems.getDefault().getPath(output.getPath(), "simple-binding.idl");
+        assertTrue("simple-binding.idl should be generated", Files.isReadable(path));
+        
+        String line = new String(Files.readAllBytes(path), "UTF-8");
         assertTrue("Invalid Idl File Generated", line.length() > 0);
-        stream.close();       
     }   
     
     public void testIDLGenSpecifiedFile() throws Exception {
@@ -189,15 +186,11 @@ public class WSDLToIDLTest extends ToolTestBase {
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed in Idl Generation", noError, exc);
 
-        File f = new File(output, "simple-binding_gen.idl");
-        assertTrue("simple-binding_gen.idl should be generated", f.exists());
+        Path path = FileSystems.getDefault().getPath(output.getPath(), "simple-binding_gen.idl");
+        assertTrue("simple-binding_gen.idl should be generated", Files.isReadable(path));
 
-        FileInputStream stream = new FileInputStream(f);            
-        BufferedInputStream bis = new BufferedInputStream(stream); 
-        DataInputStream dis = new DataInputStream(bis);
-        String line = dis.toString();
+        String line = new String(Files.readAllBytes(path), "UTF-8");
         assertTrue("Invalid Idl File Generated", line.length() > 0);
-        stream.close();
     }
 
     // tests generating corba and idl in default wsdl and idl files
@@ -210,14 +203,14 @@ public class WSDLToIDLTest extends ToolTestBase {
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed", noError, exc);
 
-        File f1 = new File(output, "simple-binding-corba.wsdl");
-        assertTrue("simple-binding-corba.wsdl should be generated", f1.exists());
-        File f2 = new File(output, "simple-binding.idl");
-        assertTrue("simple-binding.idl should be generated", f2.exists());
+        Path path1 = FileSystems.getDefault().getPath(output.getPath(), "simple-binding-corba.wsdl");
+        assertTrue("simple-binding-corba.wsdl should be generated", Files.isReadable(path1));
+        Path path2 = FileSystems.getDefault().getPath(output.getPath(), "simple-binding.idl");
+        assertTrue("simple-binding.idl should be generated", Files.isReadable(path2));
 
         WSDLToProcessor proc = new WSDLToProcessor();
         try {
-            proc.parseWSDL(f1.getAbsolutePath());
+            proc.parseWSDL(path1.toAbsolutePath().toString());
             Definition model = proc.getWSDLDefinition();
             assertNotNull("WSDL Definition Should not be Null", model);
             QName bindingName = new QName("http://schemas.apache.org/tests", "BaseOneCORBABinding");
@@ -226,12 +219,8 @@ public class WSDLToIDLTest extends ToolTestBase {
             fail("WSDLToIDL generated an invalid simple-binding-corba.wsdl");
         }
 
-        FileInputStream stream = new FileInputStream(f2);            
-        BufferedInputStream bis = new BufferedInputStream(stream); 
-        DataInputStream dis = new DataInputStream(bis);
-        String line = dis.toString();
+        String line = new String(Files.readAllBytes(path2), "UTF-8");
         assertTrue("Invalid Idl File Generated", line.length() > 0);
-        stream.close();
     }
     
     public void testNoArgs() throws Exception {

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
----------------------------------------------------------------------
diff --git a/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
b/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
index 872661c..10cb2cf 100644
--- a/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
+++ b/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
@@ -19,10 +19,10 @@
 
 package org.apache.cxf.tools.wsdlto.javascript;
 
-import java.io.File;
-import java.io.FileInputStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
-import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
@@ -56,11 +56,12 @@ public class WSDLToJavaScriptTest extends ProcessorTestBase {
         context.put(ToolConstants.CFG_JSPACKAGEPREFIX, prefixes);
         container.setContext(context); 
         container.execute();
+        
         // now we really want to check some results.
-        File resultFile = new File(output, "SOAPService_Test1.js");
-        assertTrue(resultFile.canRead());
-        FileInputStream fis = new FileInputStream(resultFile);
-        String javascript = IOUtils.readStringFromStream(fis);
+        Path path = FileSystems.getDefault().getPath(output.getPath(), "SOAPService_Test1.js");
+        assertTrue(Files.isReadable(path));
+        String javascript = new String(Files.readAllBytes(path), "UTF-8");
+        
         assertTrue(javascript.contains("xmlns:murble='http://apache.org/hello_world_soap_http'"));
         assertEquals("Number of '{' does not match number of '}' in generated JavaScript.",
                 countChar(javascript, '{'),
@@ -79,11 +80,12 @@ public class WSDLToJavaScriptTest extends ProcessorTestBase {
         context.put(ToolConstants.CFG_JSPACKAGEPREFIX, prefixes);
         container.setContext(context); 
         container.execute();
+        
         // now we really want to check some results.
-        File resultFile = new File(output, "SOAPService.js");
-        assertTrue(resultFile.canRead());
-        FileInputStream fis = new FileInputStream(resultFile);
-        String javascript = IOUtils.readStringFromStream(fis);
+        Path path = FileSystems.getDefault().getPath(output.getPath(), "SOAPService.js");
+        assertTrue(Files.isReadable(path));
+        String javascript = new String(Files.readAllBytes(path), "UTF-8");
+        
         assertTrue(javascript.contains("xmlns:murble='http://apache.org/hello_world_soap_http'"));
         assertEquals("Number of '{' does not match number of '}' in generated JavaScript.",
                 countChar(javascript, '{'),

http://git-wip-us.apache.org/repos/asf/cxf/blob/07297f3c/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
----------------------------------------------------------------------
diff --git a/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
b/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
index 411d1a2..c6eea47 100644
--- a/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
+++ b/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
@@ -18,12 +18,14 @@
  */
 package org.apache.cxf.tools.wsdlto.jaxws;
 
-import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.List;
 
@@ -222,13 +224,11 @@ public class CodeGenBugTest extends AbstractCodeGenTest {
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/bug305772/hello_world.wsdl"));
         processor.setContext(env);
         processor.execute();
-        File file = new File(output.getCanonicalPath(), "build.xml");
-        FileInputStream fileinput = new FileInputStream(file);
-        BufferedInputStream filebuffer = new BufferedInputStream(fileinput);
-        byte[] buffer = new byte[(int)file.length()];
-        filebuffer.read(buffer);
-        String content = IOUtils.newStringFromBytes(buffer);
-        filebuffer.close();
+        
+        Path path = FileSystems.getDefault().getPath(output.getCanonicalPath(), "build.xml");
+        assertTrue(Files.isReadable(path));
+        String content = new String(Files.readAllBytes(path), "UTF-8");
+        
         assertTrue("wsdl location should be url style in build.xml", content.indexOf("param1=\"file:")
> -1);
 
     }


Mime
View raw message