cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r908238 - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/helpers/ common/common/src/main/java/org/apache/cxf/staxutils/ rt/core/src/main/java/org/apache/cxf/attachment/ rt/frontend/jaxws/src/main/java/org/apache...
Date Tue, 09 Feb 2010 21:35:44 GMT
Author: dkulp
Date: Tue Feb  9 21:35:43 2010
New Revision: 908238

URL: http://svn.apache.org/viewvc?rev=908238&view=rev
Log:
Merge some fixes over that were discovered while testing with the parser built into java6.

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/ByteDataSource.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
    cxf/branches/2.2.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java

Propchange: cxf/branches/2.2.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java?rev=908238&r1=908237&r2=908238&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java
Tue Feb  9 21:35:43 2010
@@ -37,6 +37,7 @@
 import javax.wsdl.PortType;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
 
 public class WSDLHelper {
 
@@ -57,6 +58,10 @@
         }
         return null;
     }
+    
+    public static String writeQName(Definition def, QName qname) {
+        return def.getPrefix(qname.getNamespaceURI()) + ":" + qname.getLocalPart();
+    }
 
     public BindingOperation getBindingOperation(Binding binding, String operationName) {
         if (operationName == null) {

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java?rev=908238&r1=908237&r2=908238&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
Tue Feb  9 21:35:43 2010
@@ -35,7 +35,6 @@
 import java.util.WeakHashMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -387,10 +386,6 @@
         }
     }
 
-    public static String writeQName(Definition def, QName qname) {
-        return def.getPrefix(qname.getNamespaceURI()) + ":" + qname.getLocalPart();
-    }
-
     public static InputStream getInputStream(Document doc) throws Exception {
         DOMImplementationLS impl = null;
         DOMImplementation docImpl = doc.getImplementation();

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=908238&r1=908237&r2=908238&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Tue Feb  9 21:35:43 2010
@@ -354,7 +354,6 @@
             InputSource src = ((SAXSource)source).getInputSource();
             if (src.getSystemId() == null && src.getPublicId() == null
                 && ((SAXSource)source).getXMLReader() != null) {
-                
                 //OK - reader is OK.  We'll use that out
                 StreamWriterContentHandler ch = new StreamWriterContentHandler(writer);
                 XMLReader reader = ((SAXSource)source).getXMLReader();
@@ -1083,6 +1082,8 @@
                 } catch (Exception ex) {
                     //ignore
                 }
+            } else if (source instanceof SAXSource) {
+                return createXMLStreamReader(((SAXSource)source).getInputSource());
             }
             
             XMLInputFactory factory = getXMLInputFactory();

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/ByteDataSource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/ByteDataSource.java?rev=908238&r1=908237&r2=908238&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/ByteDataSource.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/ByteDataSource.java
Tue Feb  9 21:35:43 2010
@@ -36,6 +36,10 @@
     public ByteDataSource(byte[] dataParam) {
         this(dataParam, 0, dataParam.length);
     }
+    public ByteDataSource(byte[] dataParam, String ct) {
+        this(dataParam, 0, dataParam.length);
+        contentType = ct;
+    }
 
     public ByteDataSource(byte[] dataParam, int offsetParam, int lengthParam) {
         this.data = dataParam;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java?rev=908238&r1=908237&r2=908238&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
Tue Feb  9 21:35:43 2010
@@ -24,7 +24,6 @@
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -40,7 +39,6 @@
 import javax.imageio.ImageIO;
 import javax.imageio.ImageWriter;
 import javax.imageio.stream.ImageOutputStream;
-import javax.mail.util.ByteArrayDataSource;
 import javax.xml.bind.JAXBContext;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -48,6 +46,7 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.cxf.attachment.AttachmentImpl;
+import org.apache.cxf.attachment.ByteDataSource;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.binding.soap.model.SoapBodyInfo;
@@ -181,7 +180,7 @@
                                      LOG, ct));                    
                 }
                 
-                dh = new DataHandler(new ByteArrayDataSource(bos.toByteArray(), ct));
+                dh = new DataHandler(new ByteDataSource(bos.toByteArray(), ct));
             } else if (o instanceof DataHandler) {
                 dh = (DataHandler) o;
                 ct = dh.getContentType();
@@ -198,13 +197,13 @@
                 if (ct == null) {
                     ct = "application/octet-stream";
                 }
-                dh = new DataHandler(new ByteArrayDataSource((byte[])o, ct));           
    
+                dh = new DataHandler(new ByteDataSource((byte[])o, ct));                
             } else if (o instanceof String) {
                 if (ct == null) {
                     ct = "text/plain; charset=\'UTF-8\'";
                 }
                 try {
-                    dh = new DataHandler(new ByteArrayDataSource((String)o, ct));
+                    dh = new DataHandler(new ByteDataSource(((String)o).getBytes("UTF-8"),
ct));
                 } catch (IOException e) {
                     throw new Fault(e);
                 }                
@@ -233,25 +232,23 @@
                 if (src.getInputStream() != null) {
                     ByteArrayOutputStream bos = new ByteArrayOutputStream(2048);
                     IOUtils.copy(src.getInputStream(), bos, 1024);
-                    ds = new ByteArrayDataSource(bos.toByteArray(), ct);
+                    ds = new ByteDataSource(bos.toByteArray(), ct);
                 } else {
-                    ds = new ByteArrayDataSource(IOUtils.toString(src.getReader()),
+                    ds = new ByteDataSource(IOUtils.toString(src.getReader()).getBytes("UTF-8"),
                                                  ct);                            
                 }
             } catch (IOException e) {
                 throw new Fault(e);
             }
         } else {
-            StringWriter stringWriter = new StringWriter();
-            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(stringWriter);
+            ByteArrayOutputStream bwriter = new ByteArrayOutputStream();
+            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bwriter);
             try {
                 StaxUtils.copy((Source)o, writer);
                 writer.flush();
-                ds = new ByteArrayDataSource(stringWriter.toString(), ct);
+                ds = new ByteDataSource(bwriter.toByteArray(), ct);
             } catch (XMLStreamException e1) {
                 throw new Fault(e1);
-            } catch (IOException e) {
-                throw new Fault(e);
             }
         }
         return ds;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java?rev=908238&r1=908237&r2=908238&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
Tue Feb  9 21:35:43 2010
@@ -25,13 +25,13 @@
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
-import javax.mail.util.ByteArrayDataSource;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.MessageContext.Scope;
 
 
 import org.apache.cxf.attachment.AttachmentImpl;
+import org.apache.cxf.attachment.ByteDataSource;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Exchange;
@@ -100,7 +100,7 @@
         
         Collection<Attachment> attachments = new LinkedList<Attachment>();
 
-        DataSource source = new ByteArrayDataSource(new byte[0], "text/xml");
+        DataSource source = new ByteDataSource(new byte[0], "text/xml");
         
         DataHandler handler1 = new DataHandler(source);
         attachments.add(new AttachmentImpl("part1", handler1));

Modified: cxf/branches/2.2.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java?rev=908238&r1=908237&r2=908238&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
Tue Feb  9 21:35:43 2010
@@ -26,7 +26,6 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.tools.validator.internal.model.XNode;
 import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
 import org.junit.Assert;
@@ -58,24 +57,29 @@
         assertEquals(2, results.getErrors().size());
         String t = results.getErrors().pop();
         String text = "{http://apache.org/hello_world/messages}[portType:GreeterA][operation:sayHi]";
-        Message msg;
-        if (StaxUtils.isWoodstox()) {
-            msg = new Message("FAILED_AT_POINT",
-                              WSDLRefValidator.LOG,
-                              27,
-                              2,
-                              new java.net.URI(wsdl).toURL(),
-                              text);
-        } else {
-            // sjsxp
-            msg = new Message("FAILED_AT_POINT",
-                              WSDLRefValidator.LOG,
-                              -1,
-                              -1,
-                              new java.net.URI(wsdl).toURL(),
-                              text);
-        }
-        assertEquals(msg.toString(), t);
+        Set<String> possibles = new HashSet<String>();
+        //woodstox
+        possibles.add(new Message("FAILED_AT_POINT",
+                    WSDLRefValidator.LOG,
+                    27,
+                    2,
+                    new java.net.URI(wsdl).toURL(),
+                    text).toString());
+        //Sun java6 stax parser
+        possibles.add(new Message("FAILED_AT_POINT",
+                                  WSDLRefValidator.LOG,
+                                  27,
+                                  31,
+                                  new java.net.URI(wsdl).toURL(),
+                                  text).toString());
+        //sjsxp
+        possibles.add(new Message("FAILED_AT_POINT",
+                                  WSDLRefValidator.LOG,
+                                  -1,
+                                  -1,
+                                  new java.net.URI(wsdl).toURL(),
+                                  text).toString());
+        assertTrue(possibles.contains(t));
     }
     
 
@@ -139,23 +143,29 @@
         
         assertEquals(1, results.getErrors().size());
         String text = "{http://schemas.apache.org/yoko/idl/OptionsPT}[message:getEmployee]";
-        Message msg;
-        if (StaxUtils.isWoodstox()) {
-            msg = new Message("FAILED_AT_POINT",
-                              WSDLRefValidator.LOG,
-                              42,
-                              6,
-                              new java.net.URI(wsdl).toURL(),
-                              text);
-        } else {
-            msg = new Message("FAILED_AT_POINT",
-                              WSDLRefValidator.LOG,
-                              -1,
-                              -1,
-                              new java.net.URI(wsdl).toURL(),
-                              text);
-        }
-        assertEquals(msg.toString(), results.getErrors().pop());
+        Set<String> possibles = new HashSet<String>();
+        //woodstox
+        possibles.add(new Message("FAILED_AT_POINT",
+                    WSDLRefValidator.LOG,
+                    42,
+                    6,
+                    new java.net.URI(wsdl).toURL(),
+                    text).toString());
+        //Sun java6 stax parser
+        possibles.add(new Message("FAILED_AT_POINT",
+                                  WSDLRefValidator.LOG,
+                                  42,
+                                  70,
+                                  new java.net.URI(wsdl).toURL(),
+                                  text).toString());
+        //sjsxp
+        possibles.add(new Message("FAILED_AT_POINT",
+                                  WSDLRefValidator.LOG,
+                                  -1,
+                                  -1,
+                                  new java.net.URI(wsdl).toURL(),
+                                  text).toString());
+        assertTrue(possibles.contains(results.getErrors().pop()));
     }
 
     @Test



Mime
View raw message