cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r657272 - in /cxf/trunk: api/src/main/java/org/apache/cxf/io/ common/common/src/main/java/org/apache/cxf/helpers/ common/common/src/test/java/org/apache/cxf/common/util/ common/common/src/test/java/org/apache/cxf/resource/ integration/jca/s...
Date Sat, 17 May 2008 01:30:34 GMT
Author: bimargulies
Date: Fri May 16 18:30:34 2008
New Revision: 657272

URL: http://svn.apache.org/viewvc?rev=657272&view=rev
Log:
Remove uses of unsafe String constructors.

Also scratch the initial surface of controlling the element form in 
Aegis.

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java
    cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/Base64UtilityTest.java
    cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
    cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/core/classloader/PlugInClassLoaderTest.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisElementDataWriter.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
    cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TypesService.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConduitTest.java
    cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PushBack401.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_test/AbstractTypeTestClient.java
    cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Fri May 16 18:30:34
2008
@@ -256,7 +256,7 @@
         if (inmem) {
             if (currentStream instanceof ByteArrayOutputStream) {
                 byte bytes[] = ((ByteArrayOutputStream)currentStream).toByteArray();
-                out.append(new String(bytes, 0, limit));
+                out.append(IOUtils.newStringFromBytes(bytes, 0, limit));
             } else {
                 throw new IOException("Unknown format of currentStream");
             }
@@ -269,7 +269,7 @@
                 if ((count + x) > limit) {
                     x = limit - count;
                 }
-                out.append(new String(bytes, 0, x));
+                out.append(IOUtils.newStringFromBytes(bytes, 0, x));
                 count += x;
                 
                 if (count >= limit) {
@@ -295,7 +295,7 @@
             byte bytes[] = new byte[1024];
             int x = fin.read(bytes);
             while (x != -1) {
-                out.append(new String(bytes, 0, x));
+                out.append(IOUtils.newStringFromBytes(bytes, 0, x));
                 x = fin.read(bytes);
             }
             fin.close();

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java Fri May 16 18:30:34
2008
@@ -25,15 +25,50 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.nio.charset.Charset;
 
 public final class IOUtils {
-
+    public static final Charset UTF8_CHARSET = Charset.forName("utf-8");
     private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
 
     private IOUtils() {
 
     }
+    
+    /**
+     * Use this function instead of new String(byte[]) to avoid surprises from non-standard
default encodings.
+     * @param bytes
+     * @return
+     */
+    public static String newStringFromBytes(byte[] bytes) {
+        try {
+            return new String(bytes, UTF8_CHARSET.name());
+        } catch (UnsupportedEncodingException e) {
+            throw 
+                new RuntimeException("Impossible failure: Charset.forName(\"utf-8\") returns
invalid name.");
+
+        }
+    }
+
+    /**
+     * Use this function instead of new String(byte[], int, int) 
+     * to avoid surprises from non-standard default encodings.
+     * @param bytes
+     * @param start
+     * @param length
+     * @return
+     */
+    public static String newStringFromBytes(byte[] bytes, int start, int length) {
+        try {
+            return new String(bytes, start, length, UTF8_CHARSET.name());
+        } catch (UnsupportedEncodingException e) {
+            throw 
+                new RuntimeException("Impossible failure: Charset.forName(\"utf-8\") returns
invalid name.");
+
+        }
+    }
 
     public static int copy(final InputStream input, final OutputStream output)
         throws IOException {
@@ -107,7 +142,7 @@
         int n = 0;
         n = input.read(buffer);
         while (-1 != n) {
-            buf.append(new String(buffer, 0, n));
+            buf.append(newStringFromBytes(buffer, 0, n));
             n = input.read(buffer);
         }
         input.close();

Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/Base64UtilityTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/Base64UtilityTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/Base64UtilityTest.java
(original)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/Base64UtilityTest.java
Fri May 16 18:30:34 2008
@@ -22,6 +22,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.StringWriter;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -91,7 +92,7 @@
     public void testEncodeDecodeString() throws Exception {
         String in = "QWxhZGRpbjpvcGVuIHNlc2FtZQ==";
         byte bytes[] = Base64Utility.decode(in);
-        assertEquals("Aladdin:open sesame", new String(bytes));
+        assertEquals("Aladdin:open sesame", IOUtils.newStringFromBytes(bytes));
         String encoded = Base64Utility.encode(bytes);
         assertEquals(in, encoded);
     }
@@ -105,7 +106,7 @@
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
         ByteArrayOutputStream bout2 = new ByteArrayOutputStream();
         Base64Utility.encodeChunk(bytes, 0, bytes.length, bout);
-        String encodedString = new String(bout.toByteArray());
+        String encodedString = IOUtils.newStringFromBytes(bout.toByteArray());
         Base64Utility.decode(encodedString.toCharArray(),
                              0,
                              encodedString.length(),
@@ -118,7 +119,7 @@
         bout2.reset();
         Base64Utility.decode(in, bout);
         bytes = bout.toByteArray();
-        assertEquals("Aladdin:open sesame", new String(bytes));
+        assertEquals("Aladdin:open sesame", IOUtils.newStringFromBytes(bytes));
         StringWriter writer = new StringWriter();
         Base64Utility.encode(bytes, 0, bytes.length, writer);
         assertEquals(in, writer.toString());

Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java (original)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java Fri
May 16 18:30:34 2008
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.net.URL;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -60,7 +61,7 @@
             is2.close();
             
         }       
-        assertEquals(new String(barray), new String(barray2));
+        assertEquals(IOUtils.newStringFromBytes(barray), IOUtils.newStringFromBytes(barray2));
     }
 
     @Test

Modified: cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/core/classloader/PlugInClassLoaderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/core/classloader/PlugInClassLoaderTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/core/classloader/PlugInClassLoaderTest.java
(original)
+++ cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/core/classloader/PlugInClassLoaderTest.java
Fri May 16 18:30:34 2008
@@ -26,6 +26,7 @@
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.IOUtils;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -128,7 +129,7 @@
         byte[] bytes = new byte[10];
         configStream.read(bytes, 0, bytes.length);
 
-        String result = new String(bytes);
+        String result = IOUtils.newStringFromBytes(bytes);
         LOG.fine("dummy.txt contents: " + result);
         assertEquals("unexpected dummy.txt contents.", "blah,blah.", result);
     }
@@ -150,7 +151,7 @@
         byte[] bytes = new byte[21];
         configStream.read(bytes, 0, bytes.length);
     
-        String result = new String(bytes);
+        String result = IOUtils.newStringFromBytes(bytes);
         LOG.fine("dummy.txt contents: " + result);
         assertTrue("unexpected dummy.txt contents:"  + result, result.indexOf("Manifest-Version:
1.0") != -1);
     }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
Fri May 16 18:30:34 2008
@@ -108,7 +108,7 @@
             stream = new PushbackInputStream(message.getContent(InputStream.class),
                     boundary.length * 2);
             if (!readTillFirstBoundary(stream, boundary)) {
-                throw new IOException("Couldn't find MIME boundary: " + new String(boundary));
+                throw new IOException("Couldn't find MIME boundary: " + boundaryString);
             }
 
             try {
@@ -135,7 +135,7 @@
         PushbackInputStream in = new PushbackInputStream(is, 4096);
         byte buf[] = new byte[2048];
         int i = in.read(buf);
-        String msg = new String(buf, 0, i);
+        String msg = IOUtils.newStringFromBytes(buf, 0, i);
         in.unread(buf, 0, i);
         
         // Reset the input stream since we'll need it again later

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Fri
May 16 18:30:34 2008
@@ -23,6 +23,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
@@ -54,15 +55,11 @@
  * The application can control some parameters of the type creators by creating a TypeCreationOptions
  * object and setting properties. The application can add custom mappings to the type mapping,
or 
  * even use its own classes for the TypeMapping or TypeCreator objects.
- * 
- * At the level of the data binding, the 'root elements' are defined by the WSDL message
parts.
- * Additional classes that participate are termed 'override' classes.
- * 
+ *
  * Aegis, unlike JAXB, has no concept of a 'root element'. So, an application that 
  * uses Aegis without a web service has to either depend on xsi:type (at least for 
  * root elements) or have its own mapping from elements to classes, and pass the 
  * resulting Class objects to the readers.
- * 
  * At this level, the application must specify the initial set of classes to make 
  * make use of untyped collections or .aegis.xml files.
  * 
@@ -71,7 +68,10 @@
  * particular item read. Specifically, if the application just leaves it to Aegis to
  * map an element tagged with an xsi:type to a class, Aegis can't know that some arbitrary
class in
  * some arbitrary package is mapped to a particular schema type by QName in a
- * mapping XML file. 
+ * mapping XML file.
+ * 
+ * At the level of the CXF data binding, the 'root elements' are defined by the WSDL message
parts.
+ * Additional classes that participate are termed 'override' classes.
  * 
  */
 public class AegisContext {
@@ -89,7 +89,9 @@
     private boolean mtomEnabled;
     private boolean mtomUseXmime;
     // this URI goes into the type map.
-    private String mappingNamespaceURI; 
+    private String mappingNamespaceURI;
+    private XmlNsForm elementForm = XmlNsForm.QUALIFIED;
+    private XmlNsForm attributeForm = XmlNsForm.QUALIFIED;
     
     /**
      * Construct a context.
@@ -412,4 +414,36 @@
         this.mappingNamespaceURI = mappingNamespaceURI;
     }
 
+    /**
+     * The form of elements. 
+     * @return Returns the elementForm.
+     */
+    public XmlNsForm getElementForm() {
+        return elementForm;
+    }
+
+    /**
+     * The form of elements.
+     * @param elementForm The elementForm to set.
+     */
+    public void setElementForm(XmlNsForm elementForm) {
+        this.elementForm = elementForm;
+    }
+
+    /**
+     * The form of attributes. 
+     * @return Returns the attributeForm.
+     */
+    public XmlNsForm getAttributeForm() {
+        return attributeForm;
+    }
+
+    /**
+     * The form for attributes.
+     * @param attributeForm The attributeForm to set.
+     */
+    public void setAttributeForm(XmlNsForm attributeForm) {
+        this.attributeForm = attributeForm;
+    }
+
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisElementDataWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisElementDataWriter.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisElementDataWriter.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisElementDataWriter.java
Fri May 16 18:30:34 2008
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.aegis;
 
+import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.namespace.QName;
 import org.w3c.dom.Element;
 
@@ -41,6 +42,10 @@
     public void write(Object obj, QName elementName, boolean optional, Element output, Type
aegisType)
         throws Exception {
         W3CDOMStreamWriter swriter = new W3CDOMStreamWriter(output);
-        writer.write(obj, elementName, optional, swriter, aegisType);
+        QName elementNameToWrite = elementName;
+        if (aegisContext.getElementForm() == XmlNsForm.UNQUALIFIED) {
+            elementNameToWrite = new QName(elementName.getLocalPart());
+        }
+        writer.write(obj, elementNameToWrite, optional, swriter, aegisType);
     }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
Fri May 16 18:30:34 2008
@@ -40,13 +40,11 @@
     private XMLStreamWriter writer;
 
     private String namespace;
-
     private String name;
-
     private String prefix;
 
     /**
-     * Create a LiteralWriter but without writing an element name.
+     * Create an ElementWriter but without writing an element name.
      * 
      * @param writer
      */
@@ -96,7 +94,7 @@
     private void writeStartElement() throws XMLStreamException {
         if (!StringUtils.isEmpty(namespace)) {
             boolean declare = false;
-
+            // Did the user declare a prefix?
             String decPrefix = writer.getNamespaceContext().getPrefix(namespace);
 
             // If the user didn't specify a prefix, create one

Modified: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TypesService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TypesService.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TypesService.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/TypesService.java
Fri May 16 18:30:34 2008
@@ -23,6 +23,8 @@
 import javax.jws.WebService;
 import javax.xml.ws.Holder;
 
+import org.apache.cxf.helpers.IOUtils;
+
 @WebService(targetNamespace = "urn:TypesService")
 public class TypesService {
 
@@ -70,6 +72,6 @@
     @WebMethod 
     public String testBase64Binary(byte i[],  @WebParam(mode = WebParam.Mode.OUT) Holder<byte[]>
i2) {
         i2.value = i;
-        return "In:" + new String(i);
+        return "In:" + IOUtils.newStringFromBytes(i);
     }
 }

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java (original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java Fri May
16 18:30:34 2008
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
 import org.apache.cxf.javascript.fortest.MtoMImpl;
@@ -75,7 +76,7 @@
         InputStream dis = implementor.getLastDHBean().getNotXml10().getInputStream();
         byte[] bytes = new byte[2048];
         int byteCount = dis.read(bytes, 0, 2048);
-        String stuff = new String(bytes, 0, byteCount);
+        String stuff = IOUtils.newStringFromBytes(bytes, 0, byteCount);
         assertEquals("<html>\u0027</html>", stuff);
         return null;
     }

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
Fri May 16 18:30:34 2008
@@ -48,6 +48,7 @@
 import org.apache.cxf.configuration.Configurable;
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
@@ -440,7 +441,8 @@
                     if (getLogger().isLoggable(Level.FINE)) {
                         getLogger().log(Level.FINE, "The response message is ["
                                         + (replyObj instanceof String 
-                                           ? (String)replyObj : new String((byte[])replyObj))
+                                           ? (String)replyObj 
+                                               : IOUtils.newStringFromBytes((byte[])replyObj))
                                     + "]");
                     }
 

Modified: cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConduitTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConduitTest.java
(original)
+++ cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConduitTest.java
Fri May 16 18:30:34 2008
@@ -29,6 +29,7 @@
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.junit.BeforeClass;
@@ -117,7 +118,7 @@
         } catch (IOException ex) {
             ex.printStackTrace();
         }
-        String reponse = new String(bytes);
+        String reponse = IOUtils.newStringFromBytes(bytes);
         assertEquals("The reponse date should be equals", reponse, "HelloWorld");
                 
         JMSMessageHeadersType inHeader =

Modified: cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
(original)
+++ cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
Fri May 16 18:30:34 2008
@@ -25,6 +25,7 @@
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -230,7 +231,7 @@
             assertFalse("Read the Destination recieved Message error ", false);
             ex.printStackTrace();
         }
-        String reponse = new String(bytes);
+        String reponse = IOUtils.newStringFromBytes(bytes);
         assertEquals("The reponse date should be equals", reponse, "HelloWorld");
     }
     

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
Fri May 16 18:30:34 2008
@@ -336,7 +336,7 @@
                 }
             } else {
                 if (LOG.isLoggable(Level.FINE)) {
-                    LOG.fine("Using saved output stream: " + new String(content));
+                    LOG.fine("Using saved output stream: " + IOUtils.newStringFromBytes(content));
                 }
             }
             ByteArrayInputStream bis = new ByteArrayInputStream(content);

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
(original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
Fri May 16 18:30:34 2008
@@ -26,6 +26,7 @@
 import java.util.Collection;
 import java.util.Date;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.ws.addressing.v200408.EndpointReferenceType;
 import org.apache.cxf.ws.rm.DestinationSequence;
 import org.apache.cxf.ws.rm.Identifier;
@@ -589,7 +590,7 @@
                 assertNull(msg.getTo());
             }
             byte[] actual = msg.getContent();
-            assertEquals(new String("Message " + mn.longValue()), new String(actual));
+            assertEquals(new String("Message " + mn.longValue()), IOUtils.newStringFromBytes(actual));
         }
     }
     

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PushBack401.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PushBack401.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PushBack401.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PushBack401.java Fri May
16 18:30:34 2008
@@ -28,6 +28,7 @@
 
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -60,7 +61,7 @@
     private String[] extractUserPass(String token) {
         try {
             byte[] userpass = Base64Utility.decode(token);
-            String up = new String(userpass);
+            String up = IOUtils.newStringFromBytes(userpass);
             String user = up.substring(0, up.indexOf(':'));
             String pass = up.substring(up.indexOf(':') + 1);
             return new String[] {user, pass};

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java Fri
May 16 18:30:34 2008
@@ -76,7 +76,7 @@
         bis = data.value.getDataSource().getInputStream();
         byte b[] = new byte[10];
         bis.read(b, 0, 10);
-        String string = new String(b);
+        String string = IOUtils.newStringFromBytes(b);
         assertEquals("testfoobar", string);
         assertEquals("Hi", textHolder.value);
     }
@@ -106,7 +106,7 @@
         bis = data.value.getDataSource().getInputStream();
         byte b[] = new byte[10];
         bis.read(b, 0, 10);
-        String string = new String(b);
+        String string = IOUtils.newStringFromBytes(b);
         assertEquals("testfoobar", string);
         assertEquals("Hi", textHolder.value);
         assertEquals("Header", headerHolder.value);
@@ -136,7 +136,7 @@
         bis = handler.getDataSource().getInputStream();
         byte b[] = new byte[10];
         bis.read(b, 0, 10);
-        String string = new String(b);
+        String string = IOUtils.newStringFromBytes(b);
         assertEquals("testfoobar", string);
     }
     

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java Fri May
16 18:30:34 2008
@@ -29,6 +29,7 @@
 import javax.xml.ws.Holder;
 import javax.xml.ws.WebServiceException;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.swa.SwAServiceInterface;
 import org.apache.cxf.swa.types.DataStruct;
 import org.apache.cxf.swa.types.OutputResponseAll;
@@ -47,7 +48,7 @@
             bis = data.value.getDataRef().getDataSource().getInputStream();
             byte b[] = new byte[6];
             bis.read(b, 0, 6);
-            String string = new String(b);
+            String string = IOUtils.newStringFromBytes(b);
             
             ByteArrayDataSource source = 
                 new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
@@ -64,7 +65,7 @@
             bis = data.value.getDataSource().getInputStream();
             byte b[] = new byte[6];
             bis.read(b, 0, 6);
-            String string = new String(b);
+            String string = IOUtils.newStringFromBytes(b);
             
             ByteArrayDataSource source = 
                 new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
@@ -82,7 +83,7 @@
             bis = data.value.getDataSource().getInputStream();
             byte b[] = new byte[6];
             bis.read(b, 0, 6);
-            String string = new String(b);
+            String string = IOUtils.newStringFromBytes(b);
             
             ByteArrayDataSource source = 
                 new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_test/AbstractTypeTestClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_test/AbstractTypeTestClient.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_test/AbstractTypeTestClient.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_test/AbstractTypeTestClient.java
Fri May 16 18:30:34 2008
@@ -31,6 +31,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.type_test.doc.TypeTestPortType;
 import org.apache.type_test.rpc.SOAPService;
@@ -1961,8 +1962,8 @@
     }
 
     protected boolean equals(byte[] x, byte[] y) {
-        String xx = new String(x);
-        String yy = new String(y);
+        String xx = IOUtils.newStringFromBytes(x);
+        String yy = IOUtils.newStringFromBytes(y);
         return xx.equals(yy);
     }
 

Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=657272&r1=657271&r2=657272&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Fri May 16 18:30:34 2008
@@ -33,6 +33,7 @@
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.helpers.FileUtils;
+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.util.AnnotationUtil;
@@ -200,7 +201,7 @@
         BufferedInputStream filebuffer = new BufferedInputStream(fileinput);
         byte[] buffer = new byte[(int)file.length()];
         filebuffer.read(buffer);
-        String content = new String(buffer);
+        String content = IOUtils.newStringFromBytes(buffer);
         assertTrue("wsdl location should be url style in build.xml", content.indexOf("param1=\"file:")
> -1);
 
     }



Mime
View raw message