cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r749505 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/staxutils/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/apache/cxf/tools/util/ tools/common/src/test/java/org/apache/cxf/tools/uti...
Date Tue, 03 Mar 2009 01:56:04 GMT
Author: bimargulies
Date: Tue Mar  3 01:56:03 2009
New Revision: 749505

URL: http://svn.apache.org/viewvc?rev=749505&view=rev
Log:
Knock off small problems with sjsxp. Also rename a really confusingly named class.

Added:
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
      - copied, changed from r749431, cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/StAXUtil.java
Removed:
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/StAXUtil.java
Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
    cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java
    cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
    cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=749505&r1=749504&r2=749505&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Tue Mar
 3 01:56:03 2009
@@ -64,6 +64,7 @@
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
@@ -94,6 +95,15 @@
     
     private StaxUtils() {
     }
+    
+    public static boolean isWoodstox() {
+        try {
+            ClassLoaderUtils.loadClass("org.codehaus.stax2.XMLStreamReader2", StaxUtils.class);
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
+        return true;
+    }
 
     /**
      * Return a cached, namespace-aware, factory.

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java?rev=749505&r1=749504&r2=749505&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
(original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
Tue Mar  3 01:56:03 2009
@@ -42,7 +42,7 @@
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.FileUtils;
-import org.apache.cxf.tools.util.StAXUtil;
+import org.apache.cxf.tools.util.ToolsStaxUtils;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -195,8 +195,8 @@
 
     public boolean assertXmlEquals(final File expected, final File source, 
                                    final List<String> ignoreAttr) throws Exception
{
-        List<Tag> expectedTags = StAXUtil.getTags(expected);
-        List<Tag> sourceTags = StAXUtil.getTags(source);
+        List<Tag> expectedTags = ToolsStaxUtils.getTags(expected);
+        List<Tag> sourceTags = ToolsStaxUtils.getTags(source);
 
         Iterator<Tag> iterator = sourceTags.iterator();
 
@@ -304,8 +304,8 @@
 
     public void assertWsdlEquals(final File expected, final File source, List<String>
attr, List<String> tag) 
         throws Exception {
-        Tag expectedTag = StAXUtil.getTagTree(expected, attr);
-        Tag sourceTag = StAXUtil.getTagTree(source, attr);
+        Tag expectedTag = ToolsStaxUtils.getTagTree(expected, attr);
+        Tag sourceTag = ToolsStaxUtils.getTagTree(source, attr);
         assertTagEquals(expectedTag, sourceTag, attr, tag);
     }
 
@@ -316,8 +316,8 @@
     public void assertWsdlEquals(final InputStream expected, final InputStream source,
                                  List<String> attr, List<String> tag) 
         throws Exception {
-        Tag expectedTag = StAXUtil.getTagTree(expected, attr);
-        Tag sourceTag = StAXUtil.getTagTree(source, attr);
+        Tag expectedTag = ToolsStaxUtils.getTagTree(expected, attr);
+        Tag sourceTag = ToolsStaxUtils.getTagTree(source, attr);
         assertTagEquals(expectedTag, sourceTag, attr, tag);
     }
 

Copied: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
(from r749431, cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/StAXUtil.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java?p2=cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java&p1=cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/StAXUtil.java&r1=749431&r2=749505&rev=749505&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/StAXUtil.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java Tue
Mar  3 01:56:03 2009
@@ -23,58 +23,19 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Stack;
-import java.util.logging.Logger;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-import org.xml.sax.InputSource;
-
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.tools.common.Tag;
-import org.apache.cxf.tools.common.ToolException;
-
-public final class StAXUtil {
-    private static final Logger LOG = LogUtils.getL7dLogger(StAXUtil.class);
-    private static final XMLInputFactory XML_INPUT_FACTORY;
-    static {
-        XML_INPUT_FACTORY = XMLInputFactory.newInstance();
-        XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
-    }
-
-    private StAXUtil() {
-    }
 
-    public static void toStartTag(XMLStreamReader r) throws XMLStreamException {
-        while (!r.isStartElement() && r.hasNext()) {
-            r.next();
-        }
-    }
-
-    public static XMLStreamReader createFreshXMLStreamReader(InputSource source) {
-        try {
-            if (source.getCharacterStream() != null) {
-                return XML_INPUT_FACTORY.createXMLStreamReader(source.getSystemId(),
-                                                             source.getCharacterStream());
-            }
-            if (source.getByteStream() != null) {
-                return XML_INPUT_FACTORY.createXMLStreamReader(source.getSystemId(),
-                                                             source.getByteStream());
-            }
-            return XML_INPUT_FACTORY.createXMLStreamReader(source.getSystemId(),
-                                                         new URL(source.getSystemId()).openStream());
-        } catch (Exception e) {
-            Message msg = new Message("FAIL_TO_CREATE_STAX", LOG);
-            throw new ToolException(msg, e);
-        }
+public final class ToolsStaxUtils {
+   
+    private ToolsStaxUtils() {
     }
 
     public static List<Tag> getTags(final File source) throws Exception {

Modified: cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java?rev=749505&r1=749504&r2=749505&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java (original)
+++ cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java Tue Mar
 3 01:56:03 2009
@@ -32,7 +32,7 @@
         File file = new File(getClass().getResource("resources/test.wsdl").toURI());
 
         file = getResource("resources/test2.wsdl");
-        Tag tag1 = StAXUtil.getTagTree(file);
+        Tag tag1 = ToolsStaxUtils.getTagTree(file);
         assertEquals(1, tag1.getTags().size());
         Tag def1 = tag1.getTags().get(0);
         assertEquals(6, def1.getTags().size());
@@ -41,7 +41,7 @@
         assertEquals(4, schema1.getTags().size());
 
         file = getResource("resources/test3.wsdl");
-        Tag tag2 = StAXUtil.getTagTree(file);
+        Tag tag2 = ToolsStaxUtils.getTagTree(file);
         assertEquals(1, tag2.getTags().size());
         Tag def2 = tag2.getTags().get(0);
         assertEquals(6, def2.getTags().size());

Modified: cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java?rev=749505&r1=749504&r2=749505&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
(original)
+++ cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
Tue Mar  3 01:56:03 2009
@@ -22,6 +22,7 @@
 import java.net.URL;
 import java.util.Enumeration;
 
+import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.tools.common.ToolTestBase;
 import org.junit.Before;
 import org.junit.Test;
@@ -83,8 +84,12 @@
         String[] args = new String[] {"-verbose",
                                       getLocation("/validator_wsdl/hello_world_error_reference.wsdl")};
         WSDLValidator.main(args);
-        assertTrue(getStdErr().indexOf("[147,3]") != -1);
-        assertTrue(getStdErr().indexOf("Caused by {http://apache.org/hello_world_soap_http}"
+        String error = getStdErr();
+        if (StaxUtils.isWoodstox()) {
+            // sjsxp doesn't report locations.
+            assertTrue(error.indexOf("[147,3]") != -1);
+        }
+        assertTrue(error.indexOf("Caused by {http://apache.org/hello_world_soap_http}"
                                        + "[binding:Greeter_SOAPBinding1] not exist.") !=
-1);
     }
 

Modified: cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java?rev=749505&r1=749504&r2=749505&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
(original)
+++ cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
Tue Mar  3 01:56:03 2009
@@ -26,6 +26,7 @@
 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;
@@ -57,12 +58,23 @@
         assertEquals(2, results.getErrors().size());
         String t = results.getErrors().pop();
         String text = "{http://apache.org/hello_world/messages}[portType:GreeterA][operation:sayHi]";
-        Message msg = new Message("FAILED_AT_POINT",
-                                  WSDLRefValidator.LOG,
-                                  27,
-                                  2,
-                                  new java.net.URI(wsdl).toURL(),
-                                  text);
+        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);
     }
     
@@ -127,12 +139,22 @@
         
         assertEquals(1, results.getErrors().size());
         String text = "{http://schemas.apache.org/yoko/idl/OptionsPT}[message:getEmployee]";
-        Message msg = new Message("FAILED_AT_POINT",
-                                  WSDLRefValidator.LOG,
-                                  42,
-                                  6,
-                                  new java.net.URI(wsdl).toURL(),
-                                  text);
+        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());
     }
 

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=749505&r1=749504&r2=749505&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Tue Mar  3 01:56:03 2009
@@ -56,7 +56,6 @@
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
-import org.apache.cxf.tools.util.StAXUtil;
 import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ProcessorUtil;
 import org.apache.xml.resolver.Catalog;
@@ -459,7 +458,7 @@
             throw new ToolException(msg, e1);
         }
         XMLStreamReader reader = StaxUtils.createXMLStreamReader(root);
-        StAXUtil.toStartTag(reader);
+        StaxUtils.toNextTag(reader);
         if (isValidJaxwsBindingFile(bindingFile, reader)) {
 
             String wsdlLocation = root.getAttribute("wsdlLocation");



Mime
View raw message