cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r474307 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/wsdl4jutils/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/validator/ tools/validator/src/main/java/org/apache/cxf/tools/validator/ tools/validato...
Date Mon, 13 Nov 2006 13:38:26 GMT
Author: ema
Date: Mon Nov 13 05:38:25 2006
New Revision: 474307

URL: http://svn.apache.org/viewvc?view=rev&rev=474307
Log:
Added resource resolver for wsdl parser and schema factory in validation tool .

Removed unpack schemas in wsdl2java and validation module

Added:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/wsdl4jutils/WSDLResolver.java
  (with props)
Modified:
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    incubator/cxf/trunk/tools/validator/pom.xml
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml
    incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
    incubator/cxf/trunk/tools/wsdl2java/pom.xml
    incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
    incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToProcessor.java
    incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/common/ProcessorTestBase.java
    incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessorTest.java
    incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaXMLFormatTest.java
    incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/bughanging/schemas/wsdl/bf-2.xsd

Added: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/wsdl4jutils/WSDLResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/wsdl4jutils/WSDLResolver.java?view=auto&rev=474307
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/wsdl4jutils/WSDLResolver.java
(added)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/wsdl4jutils/WSDLResolver.java
Mon Nov 13 05:38:25 2006
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.wsdl4jutils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.wsdl.xml.WSDLLocator;
+
+import org.xml.sax.InputSource;
+
+import org.apache.cxf.resource.URIResolver;
+
+public class WSDLResolver implements WSDLLocator {
+    private String baseUri;
+    private String importedUri;
+    private InputSource inputSource;
+
+    public WSDLResolver(String baseURI, InputSource is) {
+        this.baseUri = baseURI;
+        inputSource = is;
+    }
+
+    public InputSource getBaseInputSource() {
+        return inputSource;
+    }
+
+    public String getBaseURI() {
+        return baseUri;
+    }
+
+    public String getLatestImportURI() {
+        return importedUri;
+    }
+
+    public InputSource getImportInputSource(String parent, String importLocation) {
+        this.baseUri = parent;
+        URL parentUrl;
+        try {
+            parentUrl = new URL(parent);
+            URL importUrl = new URL(parentUrl, importLocation);
+            if (importUrl.toURI() != null) {
+                File file = new File(importUrl.toURI());
+                if (file.exists()) {
+                    URIResolver resolver = new URIResolver(parent.toString(), importLocation);
+                    inputSource = new InputSource(resolver.getInputStream());
+                } else {
+                    URIResolver resolver = new URIResolver(importLocation);
+                    if (resolver.isResolved()) {
+                        inputSource = new InputSource(resolver.getInputStream());
+                    }
+                }
+                importedUri = importUrl.toURI().toString();
+            }
+        } catch (MalformedURLException e) {
+            // TODO
+        } catch (URISyntaxException e) {
+            // TODO
+        } catch (IOException e) {
+            // TODO
+        }
+        return inputSource;
+
+    }
+
+    public void close() {
+
+    }
+}

Propchange: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/wsdl4jutils/WSDLResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/wsdl4jutils/WSDLResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
Mon Nov 13 05:38:25 2006
@@ -108,6 +108,7 @@
     public static final String CFG_SCHEMA_DIR = "schemaDir";
     public static final String CFG_SCHEMA_URL = "schemaURL";
     public static final String CXF_SCHEMA_DIR = "cxf_schema_dir";
+    public static final String CXF_SCHEMAS_DIR_INJAR = "schemas/wsdl/";
 
 
 

Modified: incubator/cxf/trunk/tools/validator/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/pom.xml?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/validator/pom.xml (original)
+++ incubator/cxf/trunk/tools/validator/pom.xml Mon Nov 13 05:38:25 2006
@@ -35,35 +35,6 @@
         <topDirectoryLocation>../../</topDirectoryLocation>
     </properties>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>dependency-maven-plugin</artifactId>
-                <version>${dependency.plugin.version}</version>
-                <executions>
-                    <execution>
-                        <id>unpack-schemas</id>
-                        <phase>process-test-sources</phase>
-                        <goals>
-                            <goal>unpack</goal>
-                        </goals>
-                        <configuration>
-                            <outputDirectory>${project.build.directory}/generated/src/test/resources</outputDirectory>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>org.apache.cxf</groupId>
-                                    <artifactId>cxf-common-schemas</artifactId>
-                                    <version>${project.version}</version>
-                                </artifactItem>
-                            </artifactItems>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
     <dependencies>
         <dependency>
             <groupId>org.apache.cxf</groupId>
@@ -120,6 +91,12 @@
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-common-utilities</artifactId>
             <version>${project.version}</version>
+        </dependency>
+        
+        <dependency>
+		     <groupId>org.apache.cxf</groupId>
+		     <artifactId>cxf-common-schemas</artifactId>
+		     <version>${project.version}</version>
         </dependency>
     </dependencies>
 </project>

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
Mon Nov 13 05:38:25 2006
@@ -61,12 +61,7 @@
 
                 env.put(ToolConstants.CFG_CMD_ARG, args);
 
-                String schemaDir = (String)env.get(ToolConstants.CFG_SCHEMA_DIR);
-                if (schemaDir == null) {
-                    throw new ToolException("Schema search directory should "
-                                            + "be defined before validating wsdl.");
-                }
-
+              
                 WSDL11Validator wsdlValidator = new WSDL11Validator(null, env);
                 if (wsdlValidator.isValid()) {
                     System.out.println("Passed Validation : Valid WSDL ");

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
Mon Nov 13 05:38:25 2006
@@ -32,7 +32,11 @@
     protected List<String> errorMessages = new Vector<String>();
     protected Definition def;
     protected ToolContext env;
-
+    
+    public AbstractValidator() {
+        
+    }
+    
     public AbstractValidator(Definition definition) {
         this.def = definition;
     }

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
Mon Nov 13 05:38:25 2006
@@ -41,6 +41,7 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
@@ -59,6 +60,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.resource.URIResolver;
+import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.WSDLExtensionRegister;
 
@@ -66,12 +68,14 @@
     protected static final Logger LOG = LogUtils.getL7dLogger(SchemaValidator.class);
 
     protected String[] defaultSchemas;
-
+   
     protected String schemaLocation = "./";
 
     private String wsdlsrc;
 
     private String[] xsds;
+    
+    private List<InputSource> schemaFromJar;
 
     private DocumentBuilder docBuilder;
 
@@ -90,6 +94,13 @@
         wsdlsrc = wsdl;
         xsds = schemas;
     }
+    
+    public SchemaValidator(List<InputSource> defaultSchemas, String wsdl, String[]
schemas) {
+        schemaLocation = null;
+        schemaFromJar = defaultSchemas;
+        wsdlsrc = wsdl;
+        xsds = schemas;
+    }
 
     public boolean isValid() {
         return validate(wsdlsrc, xsds);
@@ -116,7 +127,37 @@
         return validate(is, schemas);
 
     }
+    
+    private Schema createSchema(List<InputSource> xsdsInJar, String[] schemas) 
+        throws SAXException, IOException {
+        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+        SchemaResourceResolver resourceResolver = new SchemaResourceResolver();
+
+        sf.setResourceResolver(resourceResolver);
+        
+        List<Source> sources = new ArrayList<Source>();
 
+        for (InputSource is : xsdsInJar) {
+            StreamSource stream = new StreamSource(is.getByteStream());
+            stream.setSystemId(is.getSystemId());
+            sources.add(stream);
+        }
+        
+        if (schemas != null) {
+            for (int i = 0; i < schemas.length; i++) {
+                Document doc = docBuilder.parse(schemas[i]);
+                DOMSource stream = new DOMSource(doc, schemas[i]);
+                sources.add(stream);
+            } 
+        }
+        
+        Source[] args = new Source[sources.size()];
+        sources.toArray(args);
+        return sf.newSchema(args);
+    
+    }
+    
     private Schema createSchema(String[] schemas) throws SAXException, IOException {
 
         SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -141,6 +182,7 @@
 
     public boolean validate(InputSource wsdlsource, String[] schemas) throws ToolException
{
         boolean isValid = false;
+        Schema schema;
         try {
 
             Document document = docBuilder.parse(wsdlsource.getSystemId());
@@ -155,16 +197,19 @@
             saxFactory.setFeature("http://xml.org/sax/features/namespaces", true);
             saxParser = saxFactory.newSAXParser();
 
-            schemas = addSchemas(defaultSchemas, schemas);
-
-            SAXSource saxSource = new SAXSource(saxParser.getXMLReader(), wsdlsource);
+            if (defaultSchemas != null) {
+                schemas = addSchemas(defaultSchemas, schemas);
+                schema = createSchema(schemas);
+            } else {
+                schema = createSchema(schemaFromJar, schemas); 
+            }
 
-            Schema schema = createSchema(schemas);
 
             Validator validator = schema.newValidator();
-
+            
             NewStackTraceErrorHandler errHandler = new NewStackTraceErrorHandler();
             validator.setErrorHandler(errHandler);
+            SAXSource saxSource = new SAXSource(saxParser.getXMLReader(), wsdlsource);
             validator.validate(saxSource);
 
             if (!errHandler.isValid()) {
@@ -339,13 +384,20 @@
 class SchemaResourceResolver implements LSResourceResolver {
     public LSInput resolveResource(String type, String namespaceURI, String publicId, String
systemId,
             String baseURI) {
-        String schemaLocation = baseURI.substring(0, baseURI.lastIndexOf("/") + 1);
+        String schemaLocation = null;
+        if (baseURI != null) {
+            schemaLocation = baseURI.substring(0, baseURI.lastIndexOf("/") + 1);
 
-        if (systemId.indexOf("http://") < 0) {
-            systemId = schemaLocation + systemId;
+            if (systemId.indexOf("http://") < 0) {
+                systemId = schemaLocation + systemId;
+            }
+        } else {
+            // try to get it from jar
+            systemId = ToolConstants.CXF_SCHEMAS_DIR_INJAR + systemId;
         }
-
+        
         URIResolver resolver = null;
+        
         try {
             resolver = new URIResolver(systemId);
         } catch (IOException e1) {

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
Mon Nov 13 05:38:25 2006
@@ -19,12 +19,21 @@
 
 package org.apache.cxf.tools.validator.internal;
 
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
 
 import javax.wsdl.Definition;
 
+import org.xml.sax.InputSource;
+
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
@@ -32,7 +41,7 @@
 
 
 public class WSDL11Validator extends AbstractValidator {
-
+    
     private final List<AbstractValidator> validators = new ArrayList<AbstractValidator>();
 
     public WSDL11Validator(Definition definition) {
@@ -46,24 +55,35 @@
     public boolean isValid() throws ToolException {
         boolean isValid = true;
         String schemaDir = getSchemaDir();
+        SchemaValidator schemaValidator = null;
+        String[] schemas = (String[])env.get(ToolConstants.CFG_SCHEMA_URL);
+        //Tool will use the following sequence to find the schema files  
+        //1.ToolConstants.CFG_SCHEMA_DIR from ToolContext
+        //2.ToolConstants.CXF_SCHEMA_DIR from System property
+        //3.If 1 and 2 is null , then load these schema files from jar file
+        
         if (!StringUtils.isEmpty(schemaDir)) {
 
-            String[] schemas = (String[])env.get(ToolConstants.CFG_SCHEMA_URL);
-            
-            SchemaValidator schemaValidator = new SchemaValidator(schemaDir, (String)env
-                .get(ToolConstants.CFG_WSDLURL), schemas);
-
-            if (!schemaValidator.isValid()) {              
-                this.addErrorMessage(schemaValidator.getErrorMessage());
-                isValid = false;
-                throw new ToolException(this.getErrorMessage());
-               
-            } else {
-                this.def = schemaValidator.def;
+            schemaValidator = new SchemaValidator(schemaDir, (String)env.get(ToolConstants.CFG_WSDLURL),
+                                                  schemas);
+        } else {
+            try {
+                schemaValidator = new SchemaValidator(this.getSchemasFromJarFile(), (String)env
+                    .get(ToolConstants.CFG_WSDLURL), schemas);
+            } catch (IOException e) {
+                throw new ToolException("Schemas can not be loaded before validating wsdl",
e);
             }
+
+        }
+        if (!schemaValidator.isValid()) {
+            this.addErrorMessage(schemaValidator.getErrorMessage());
+            isValid = false;
+            throw new ToolException(this.getErrorMessage());
+
         } else {
-            throw new ToolException("Schema dir should be defined before validating wsdl");
+            this.def = schemaValidator.def;
         }
+        
 
         validators.add(new UniqueBodyPartsValidator(this.def));
         validators.add(new WSIBPValidator(this.def));
@@ -87,7 +107,34 @@
             dir = System.getProperty(ToolConstants.CXF_SCHEMA_DIR);
         } else {
             dir = (String)env.get(ToolConstants.CFG_SCHEMA_DIR);
-        }
+        } 
         return dir;
     }
+    
+    protected List<InputSource> getSchemasFromJarFile() throws IOException {
+        List<InputSource> xsdList = new ArrayList<InputSource>();
+        ClassLoader clzLoader = Thread.currentThread().getContextClassLoader();
+        URL url = clzLoader.getResource(ToolConstants.CXF_SCHEMAS_DIR_INJAR);
+                
+        JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
+        
+        JarFile jarFile = jarConnection.getJarFile();
+        
+        Enumeration<JarEntry> entry = jarFile.entries();
+        
+        while (entry.hasMoreElements()) {
+            JarEntry ele =  (JarEntry)entry.nextElement();
+            if (ele.getName().endsWith(".xsd") 
+                && ele.getName().indexOf(ToolConstants.CXF_SCHEMAS_DIR_INJAR) >
-1) {
+                URIResolver resolver =  new URIResolver(ele.getName()); 
+                if (resolver.isResolved()) {
+                    InputSource is = new InputSource(resolver.getInputStream());
+                    is.setSystemId(ele.getName());
+                    xsdList.add(new InputSource(resolver.getInputStream()));
+                }   
+            }            
+        }
+        
+        return xsdList; 
+    }   
 }

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml
Mon Nov 13 05:38:25 2006
@@ -33,7 +33,7 @@
 
 	<usage>
 		<optionGroup id="options">				
-			<option id="schemaDir" minOccurs="1" maxOccurs="1">
+			<!--option id="schemaDir" minOccurs="1" maxOccurs="1">
 		         <annotation>
 		            The Directory used to search for schemas
 		         </annotation>
@@ -41,7 +41,7 @@
 				<associatedArgument placement="afterSpace">
 					<annotation>schema-directory</annotation>
 				</associatedArgument>
-			</option>
+			</option-->
 			
 			<option id="schemaURL" maxOccurs="unbounded">
 			<annotation>

Modified: incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
Mon Nov 13 05:38:25 2006
@@ -26,23 +26,14 @@
 import org.apache.cxf.tools.common.ToolTestBase;
 
 public class WSDLValidationTest extends ToolTestBase {
-    private String schemaDir;
-
     public void setUp() {
         super.setUp();
-        try {
-            schemaDir = getLocation("/schemas/wsdl");
-        } catch (IOException ex) {
-            ex.printStackTrace();
-        }
-
     }
 
     public void testValidateUniqueBody() {
         try {
 
-            String[] args = new String[] {"-d", schemaDir,
-                                          "-verbose", getLocation("/validator_wsdl/doc_lit_bare.wsdl")};
+            String[] args = new String[] {"-verbose", getLocation("/validator_wsdl/doc_lit_bare.wsdl")};
             WSDLValidator.main(args);
             assertTrue("Non Unique Body Parts Error should be discovered: " + getStdErr(),
                        getStdErr().indexOf("Non unique body part") > -1);
@@ -54,7 +45,7 @@
     public void testValidateMixedStyle() {
         try {
 
-            String[] args = new String[] {"-d", schemaDir, "-verbose",
+            String[] args = new String[] {"-verbose",
                                           getLocation("/validator_wsdl/hello_world_mixed_style.wsdl")};
             WSDLValidator.main(args);
             assertTrue("Mixed style. Error should have been discovered: " + getStdErr(),
@@ -68,7 +59,7 @@
     public void testValidateTypeElement() {
         try {
 
-            String[] args = new String[] {"-d", schemaDir, "-verbose",
+            String[] args = new String[] {"-verbose",
                                           getLocation("/validator_wsdl/hello_world_doc_lit_type.wsdl")};
             WSDLValidator.main(args);
             assertTrue("Must refer to type element error should have been discovered: " +
getStdErr(),
@@ -81,7 +72,7 @@
     public void testValidateAttribute() {
         try {
 
-            String[] args = new String[] {"-d", schemaDir, "-verbose",
+            String[] args = new String[] {"-verbose",
                                           getLocation("/validator_wsdl/hello_world_error_attribute.wsdl")};
             WSDLValidator.main(args);
             assertTrue("Attribute error should be discovered: " + getStdErr(),
@@ -96,7 +87,7 @@
 
         try {
 
-            String[] args = new String[] {"-d", schemaDir, "-verbose",
+            String[] args = new String[] {"-verbose",
                                           getLocation("/validator_wsdl/hello_world_error_reference.wsdl")};
             WSDLValidator.main(args);
             assertTrue("Reference error should be discovered: " + getStdErr(),
@@ -110,7 +101,7 @@
     
     public void testBug305872() throws Exception {
         try {
-            String[] args = new String[] {"-d", schemaDir, "-verbose",
+            String[] args = new String[] {"-verbose",
                                           getLocation("/validator_wsdl/bug305872/http.xsd")};
             WSDLValidator.main(args);
             
@@ -124,7 +115,7 @@
 
     public void testImportWsdlValidation() throws Exception {
         try {
-            String[] args = new String[] {"-d", schemaDir, "-verbose",
+            String[] args = new String[] {"-verbose",
                                           getLocation("/validator_wsdl/hello_world_import.wsdl")};
             WSDLValidator.main(args);
             
@@ -138,7 +129,7 @@
 
     public void testImportSchemaValidation() throws Exception {
         try {
-            String[] args = new String[] {"-d", schemaDir, "-verbose",
+            String[] args = new String[] {"-verbose",
                                           getLocation("/validator_wsdl/hello_world_schema_import.wsdl")};
             WSDLValidator.main(args);
             

Modified: incubator/cxf/trunk/tools/wsdl2java/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/pom.xml?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/pom.xml (original)
+++ incubator/cxf/trunk/tools/wsdl2java/pom.xml Mon Nov 13 05:38:25 2006
@@ -103,36 +103,11 @@
             <artifactId>cxf-common-utilities</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+	     <groupId>org.apache.cxf</groupId>
+	     <artifactId>cxf-common-schemas</artifactId>
+	     <version>${project.version}</version>
+        </dependency>
     </dependencies>
 
-    <build>
-        <plugins>
-<!--
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>dependency-maven-plugin</artifactId>
-                <version>${dependency.plugin.version}</version>
-                <executions>
-                    <execution>
-                        <id>unpack-schemas</id>
-                        <phase>process-test-sources</phase>
-                        <goals>
-                            <goal>unpack</goal>
-                        </goals>
-                        <configuration>
-                            <outputDirectory>${project.build.directory}/generated/src/test/resources</outputDirectory>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>org.apache.cxf</groupId>
-                                    <artifactId>cxf-common-schemas</artifactId>
-                                    <version>${project.version}</version>
-                                </artifactItem>
-                            </artifactItems>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
--->
-        </plugins>
-    </build>
 </project>

Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
Mon Nov 13 05:38:25 2006
@@ -295,9 +295,6 @@
         //Jaxb's bug . Jaxb ClassNameCollecotr may not be invoked when generated class is
an enum.
         //So we need recheck whether we add all generated source files to  fileList
         
-       
-        
-
         String[] arguments = new String[argList.size() + fileList.size() + 1];
         arguments[0] = "javac";
         

Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToProcessor.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToProcessor.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToProcessor.java
Mon Nov 13 05:38:25 2006
@@ -40,17 +40,20 @@
 import javax.wsdl.PortType;
 import javax.wsdl.Service;
 import javax.wsdl.Types;
-import javax.wsdl.WSDLException;
+
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.extensions.schema.SchemaImport;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
 
+import org.xml.sax.InputSource;
+
 import com.sun.tools.xjc.api.S2JJAXBModel;
 import com.sun.tools.xjc.model.Model;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.tools.common.DataBindingGenerator;
 import org.apache.cxf.tools.common.FrontEndGenerator;
 import org.apache.cxf.tools.common.Processor;
@@ -64,7 +67,9 @@
 import org.apache.cxf.tools.util.WSDLExtensionRegister;
 import org.apache.cxf.tools.validator.internal.WSDL11Validator;
 import org.apache.cxf.tools.wsdl2java.databindings.jaxb.JAXBBindingGenerator;
-import org.apache.cxf.wsdl4jutils.WSDLLocatorImpl;
+
+//import org.apache.cxf.wsdl4jutils.WSDLLocatorImpl;
+import org.apache.cxf.wsdl4jutils.WSDLResolver;
 import org.apache.velocity.app.Velocity;
 
 public class WSDLToProcessor implements Processor {
@@ -147,10 +152,15 @@
             wsdlReader.setFeature("javax.wsdl.verbose", false);
             WSDLExtensionRegister register = new WSDLExtensionRegister(wsdlFactory, wsdlReader);
             register.registerExtensions();
-            wsdlDefinition = wsdlReader.readWSDL(new WSDLLocatorImpl(wsdlURL));
+            URIResolver resolver = new URIResolver(wsdlURL);
+            InputSource insource = new InputSource(resolver.getInputStream());
+            wsdlURL = resolver.getURI().toString();
+            wsdlDefinition = wsdlReader.readWSDL(new WSDLResolver(wsdlURL, insource));
+            /*wsdlDefinition = wsdlReader.readWSDL(new WSDLLocatorImpl(wsdlURL));*/
+            
             parseImports(wsdlDefinition);
             buildImportedMaps();
-        } catch (WSDLException we) {
+        } catch (Exception we) {
             org.apache.cxf.common.i18n.Message msg =
                 new org.apache.cxf.common.i18n.Message("FAIL_TO_CREATE_WSDL_DEFINITION",
                                                              LOG, wsdlURL);

Modified: incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/common/ProcessorTestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/common/ProcessorTestBase.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/common/ProcessorTestBase.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/common/ProcessorTestBase.java
Mon Nov 13 05:38:25 2006
@@ -139,5 +139,8 @@
         }
         return classPath.toString();
     }
+    
+    
+    
 
 }

Modified: incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessorTest.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessorTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessorTest.java
Mon Nov 13 05:38:25 2006
@@ -63,7 +63,6 @@
     public void tearDown() {
         super.tearDown();
         processor = null;
-
     }
 
     public void testRPCLit() throws Exception {

Modified: incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaXMLFormatTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaXMLFormatTest.java?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaXMLFormatTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaXMLFormatTest.java
Mon Nov 13 05:38:25 2006
@@ -19,15 +19,9 @@
 
 package org.apache.cxf.tools.wsdl2java.processor;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
-// import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.ToolException;
 
 public class WSDLToJavaXMLFormatTest
     extends ProcessorTestBase {
@@ -37,22 +31,21 @@
         env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
     }
     // temporarily comment, waiting for tool's validator fix
-//    public void testXMLFormatRootNodeValidationFail() throws Exception {
-//        WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
-//        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
-//        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/xml_format_fail.wsdl"));
-//        env.put(ToolConstants.CFG_VALIDATE_WSDL, ToolConstants.CFG_VALIDATE_WSDL);
-//        System.setProperty(ToolConstants.CXF_SCHEMA_DIR, getSchemaLocation("/schemas/wsdl"));
-//        processor.setEnvironment(env);
-//        try {
-//            processor.process();
-//            fail("Do not catch expected tool exception for xml format binding!");
-//        } catch (ToolException e) {
-//            if (e.toString().indexOf("missing xml format body element") == -1) {
-//                throw e;
-//            }
-//        }
-//    }
+    public void testXMLFormatRootNodeValidationFail() throws Exception {
+        WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
+        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/xml_format_fail.wsdl"));
+        env.put(ToolConstants.CFG_VALIDATE_WSDL, ToolConstants.CFG_VALIDATE_WSDL);
+        processor.setEnvironment(env);
+        try {
+            processor.process();
+            fail("Do not catch expected tool exception for xml format binding!");
+        } catch (ToolException e) {
+            if (e.toString().indexOf("missing xml format body element") == -1) {
+                throw e;
+            }
+        }
+    }
 
     public void testXMLFormatRootNodeValidationPass() throws Exception {
         WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
@@ -66,18 +59,6 @@
         return WSDLToJavaXMLFormatTest.class.getResource(wsdlFile).getFile();
     }
     
-    private String getSchemaLocation(String schemaDir) throws IOException {
-        Enumeration<URL> e = LogUtils.class.getClassLoader().getResources(schemaDir);
-        
-        while (e.hasMoreElements()) {
-            URL u = e.nextElement();
-            File f = new File(u.getFile());
-            if (f.exists() && f.isDirectory()) {
-                return f.toString();
-            }
-        }
-
-        return LogUtils.class.getResource(schemaDir).getFile();
-    }
+    
     
 }

Modified: incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/bughanging/schemas/wsdl/bf-2.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/bughanging/schemas/wsdl/bf-2.xsd?view=diff&rev=474307&r1=474306&r2=474307
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/bughanging/schemas/wsdl/bf-2.xsd
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/bughanging/schemas/wsdl/bf-2.xsd
Mon Nov 13 05:38:25 2006
@@ -22,8 +22,7 @@
   elementFormDefault="qualified" attributeFormDefault="unqualified" 
   targetNamespace="http://docs.oasis-open.org/wsrf/bf-2">
 
-  <xsd:import namespace="http://www.w3.org/2005/08/addressing" 
-              schemaLocation="/schemas/wsdl/ws-addr.xsd" />
+  <xsd:import schemaLocation="/schemas/wsdl/ws-addr.xsd" />
               
   <xsd:import namespace="http://www.w3.org/XML/1998/namespace" 
               schemaLocation="/schemas/wsdl/xml.xsd">



Mime
View raw message