Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java Sun Feb 21 21:34:00 2021 @@ -380,9 +380,14 @@ public class SchemaTypeSystemCompiler { String fjn = type.getFullJavaName(); + SchemaCodePrinter printer = (options == null) ? null : options.getSchemaCodePrinter(); + if (printer == null) { + printer = new SchemaTypeCodePrinter(); + } + try (Writer writer = filer.createSourceFile(fjn)) { // Generate interface class - SchemaTypeCodePrinter.printType(writer, type, options); + printer.printType(writer, type, options); } catch (IOException e) { System.err.println("IO Error " + e); success = false; @@ -392,7 +397,7 @@ public class SchemaTypeSystemCompiler { try (Writer writer = filer.createSourceFile(fjn)) { // Generate Implementation class - SchemaTypeCodePrinter.printTypeImpl(writer, type, options); + printer.printTypeImpl(writer, type, options); } catch (IOException e) { System.err.println("IO Error " + e); success = false;
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SimpleTypeFactory.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SimpleTypeFactory.java?rev=1886771&view=auto ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SimpleTypeFactory.java (added) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SimpleTypeFactory.java Sun Feb 21 21:34:00 2021 @@ -0,0 +1,29 @@ +/* Copyright 2017, 2018 The Apache Software Foundation + * + * Licensed 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.xmlbeans.impl.schema; + +import org.apache.xmlbeans.SchemaTypeSystem; + +@SuppressWarnings("unchecked") +public class SimpleTypeFactory<T> extends ElementFactory<T> { + public SimpleTypeFactory(SchemaTypeSystem typeSystem, String typeHandle) { + super(typeSystem, typeHandle); + } + + public T newValue(java.lang.Object obj) { + return (T) getType().newValue(obj); + } +} Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/XmlObjectFactory.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/XmlObjectFactory.java?rev=1886771&view=auto ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/XmlObjectFactory.java (added) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/XmlObjectFactory.java Sun Feb 21 21:34:00 2021 @@ -0,0 +1,332 @@ +/* Copyright 2004 The Apache Software Foundation + * + * Licensed 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.xmlbeans.impl.schema; + +import org.apache.xmlbeans.*; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Node; + +import javax.xml.stream.XMLStreamReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +/** + * Factory class for creating new instances. Note that if + * a type can be inferred from the XML being loaded (for example, + * by recognizing the document element QName), then the instance + * returned by a factory will have the inferred type. Otherwise + * the Factory will returned an untyped document. + */ +@SuppressWarnings("unchecked") +public class XmlObjectFactory<T> extends DocumentFactory<T> { + // anytype needs to be handled different while parsing - opposed to specific instances + private final boolean isAnyType; + + public XmlObjectFactory(String typeHandle) { + this(XmlBeans.getBuiltinTypeSystem(), typeHandle); + } + + /** + * This constructor is only used as a workaround for bootstrapping the XML schemas - don't use it! + */ + public XmlObjectFactory(SchemaTypeSystem typeSystem, String typeHandle) { + super(typeSystem, typeHandle); + isAnyType = "_BI_anyType".equals(typeHandle); + } + + /** + * Creates a new, completely empty instance. + */ + @Override + public T newInstance() { + return (T)XmlBeans.getContextTypeLoader().newInstance(getInnerType(), null); + } + + /** + * <p>Creates a new, completely empty instance, specifying options + * for the root element's document type and/or whether to validate + * value facets as they are set.</p> + * <p> + * Use the <em>options</em> parameter to specify the following:</p> + * + * <table> + * <tr><th>To specify this</th><th>Use this method</th></tr> + * <tr> + * <td>The document type for the root element.</td> + * <td>{@link XmlOptions#setDocumentType}</td> + * </tr> + * <tr> + * <td>Whether value facets should be checked as they are set.</td> + * <td>{@link XmlOptions#setValidateOnSet}</td> + * </tr> + * </table> + * + * @param options Options specifying root document type and/or value facet + * checking. + * @return A new, empty instance of XmlObject.</li> + */ + @Override + public T newInstance(XmlOptions options) { + return (T)XmlBeans.getContextTypeLoader().newInstance(getInnerType(), options); + } + + /** + * Creates an immutable {@link XmlObject} value + */ + public T newValue(Object obj) { + return (T)getType().newValue(obj); + } + + /** + * Parses the given {@link String} as XML. + */ + @Override + public T parse(String xmlAsString) throws XmlException { + return (T)XmlBeans.getContextTypeLoader().parse(xmlAsString, getInnerType(), null); + } + + /** + * Parses the given {@link String} as XML. + * <p> + * Use the <em>options</em> parameter to specify the following:</p> + * + * <table> + * <tr><th>To specify this</th><th>Use this method</th></tr> + * <tr> + * <td>The document type for the root element.</td> + * <td>{@link XmlOptions#setDocumentType}</td> + * </tr> + * <tr> + * <td>To place line number annotations in the store when parsing a document.</td> + * <td>{@link XmlOptions#setLoadLineNumbers}</td> + * </tr> + * <tr> + * <td>To replace the document element with the specified QName when parsing.</td> + * <td>{@link XmlOptions#setLoadReplaceDocumentElement}</td> + * </tr> + * <tr> + * <td>To strip all insignificant whitespace when parsing a document.</td> + * <td>{@link XmlOptions#setLoadStripWhitespace}</td> + * </tr> + * <tr> + * <td>To strip all comments when parsing a document.</td> + * <td>{@link XmlOptions#setLoadStripComments}</td> + * </tr> + * <tr> + * <td>To strip all processing instructions when parsing a document.</td> + * <td>{@link XmlOptions#setLoadStripProcinsts}</td> + * </tr> + * <tr> + * <td>A map of namespace URI substitutions to use when parsing a document.</td> + * <td>{@link XmlOptions#setLoadSubstituteNamespaces}</td> + * </tr> + * <tr> + * <td>Additional namespace mappings to be added when parsing a document.</td> + * <td>{@link XmlOptions#setLoadAdditionalNamespaces}</td> + * </tr> + * <tr> + * <td>To trim the underlying XML text buffer immediately after parsing + * a document, resulting in a smaller memory footprint.</td> + * <td>{@link XmlOptions#setLoadTrimTextBuffer}</td> + * </tr> + * </table> + * + * @param xmlAsString The string to parse. + * @param options Options as specified. + * @return A new instance containing the specified XML. + */ + @Override + public T parse(String xmlAsString, XmlOptions options) throws XmlException { + return (T)XmlBeans.getContextTypeLoader().parse(xmlAsString, getInnerType(), options); + } + + /** + * Parses the given {@link File} as XML. + */ + @Override + public T parse(File file) throws XmlException, IOException { + return (T)XmlBeans.getContextTypeLoader().parse(file, getInnerType(), null); + } + + /** + * Parses the given {@link File} as XML. + */ + @Override + public T parse(File file, XmlOptions options) throws XmlException, IOException { + return (T)XmlBeans.getContextTypeLoader().parse(file, getInnerType(), options); + } + + /** + * Downloads the given {@link java.net.URL} as XML. + */ + @Override + public T parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException { + return (T)XmlBeans.getContextTypeLoader().parse(u, getInnerType(), null); + } + + /** + * Downloads the given {@link java.net.URL} as XML. + */ + @Override + public T parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { + return (T)XmlBeans.getContextTypeLoader().parse(u, getInnerType(), options); + } + + /** + * Decodes and parses the given {@link InputStream} as XML. + */ + @Override + public T parse(InputStream is) throws XmlException, IOException { + return (T)XmlBeans.getContextTypeLoader().parse(is, getInnerType(), null); + } + + /** + * Decodes and parses the given {@link XMLStreamReader} as XML. + */ + @Override + public T parse(XMLStreamReader xsr) throws XmlException { + return (T)XmlBeans.getContextTypeLoader().parse(xsr, getInnerType(), null); + } + + /** + * Decodes and parses the given {@link InputStream} as XML. + * <p> + * Use the <em>options</em> parameter to specify the following:</p> + * + * <table> + * <tr><th>To specify this</th><th>Use this method</th></tr> + * <tr> + * <td>The character encoding to use when parsing or writing a document.</td> + * <td>{@link XmlOptions#setCharacterEncoding}</td> + * </tr> + * <tr> + * <td>The document type for the root element.</td> + * <td>{@link XmlOptions#setDocumentType}</td> + * </tr> + * <tr> + * <td>Place line number annotations in the store when parsing a document.</td> + * <td>{@link XmlOptions#setLoadLineNumbers}</td> + * </tr> + * <tr> + * <td>Replace the document element with the specified QName when parsing.</td> + * <td>{@link XmlOptions#setLoadReplaceDocumentElement}</td> + * </tr> + * <tr> + * <td>Strip all insignificant whitespace when parsing a document.</td> + * <td>{@link XmlOptions#setLoadStripWhitespace}</td> + * </tr> + * <tr> + * <td>Strip all comments when parsing a document.</td> + * <td>{@link XmlOptions#setLoadStripComments}</td> + * </tr> + * <tr> + * <td>Strip all processing instructions when parsing a document.</td> + * <td>{@link XmlOptions#setLoadStripProcinsts}</td> + * </tr> + * <tr> + * <td>Set a map of namespace URI substitutions to use when parsing a document.</td> + * <td>{@link XmlOptions#setLoadSubstituteNamespaces}</td> + * </tr> + * <tr> + * <td>Set additional namespace mappings to be added when parsing a document.</td> + * <td>{@link XmlOptions#setLoadAdditionalNamespaces}</td> + * </tr> + * <tr> + * <td>Trim the underlying XML text buffer immediately after parsing + * a document, resulting in a smaller memory footprint.</td> + * <td>{@link XmlOptions#setLoadTrimTextBuffer}</td> + * </tr> + * </table> + */ + @Override + public T parse(InputStream is, XmlOptions options) throws XmlException, IOException { + return (T)XmlBeans.getContextTypeLoader().parse(is, getInnerType(), options); + } + + /** + * Parses the given {@link XMLStreamReader} as XML. + */ + @Override + public T parse(XMLStreamReader xsr, XmlOptions options) throws XmlException { + return (T)XmlBeans.getContextTypeLoader().parse(xsr, getInnerType(), options); + } + + /** + * Parses the given {@link Reader} as XML. + */ + @Override + public T parse(Reader r) throws XmlException, IOException { + return (T)XmlBeans.getContextTypeLoader().parse(r, getInnerType(), null); + } + + /** + * Parses the given {@link Reader} as XML. + */ + @Override + public T parse(Reader r, XmlOptions options) throws XmlException, IOException { + return (T)XmlBeans.getContextTypeLoader().parse(r, getInnerType(), options); + } + + /** + * Converts the given DOM {@link Node} into an XmlObject. + */ + @Override + public T parse(Node node) throws XmlException { + return (T)XmlBeans.getContextTypeLoader().parse(node, getInnerType(), null); + } + + /** + * Converts the given DOM {@link Node} into an XmlObject. + */ + @Override + public T parse(Node node, XmlOptions options) throws XmlException { + return (T)XmlBeans.getContextTypeLoader().parse(node, getInnerType(), options); + } + + /** + * Returns an {@link XmlSaxHandler} that can load an XmlObject from SAX events. + */ + public XmlSaxHandler newXmlSaxHandler() { + return XmlBeans.getContextTypeLoader().newXmlSaxHandler(getInnerType(), null); + } + + /** + * Returns an {@link XmlSaxHandler} that can load an XmlObject from SAX events. + */ + public XmlSaxHandler newXmlSaxHandler(XmlOptions options) { + return XmlBeans.getContextTypeLoader().newXmlSaxHandler(getInnerType(), options); + } + + /** + * Creates a new DOMImplementation object + */ + public DOMImplementation newDomImplementation() { + return XmlBeans.getContextTypeLoader().newDomImplementation(null); + } + + /** + * Creates a new DOMImplementation object, taking options + */ + public DOMImplementation newDomImplementation(XmlOptions options) { + return XmlBeans.getContextTypeLoader().newDomImplementation(options); + } + + private SchemaType getInnerType() { + return isAnyType ? null : getType(); + } +} Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java?rev=1886771&view=auto ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java (added) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java Sun Feb 21 21:34:00 2021 @@ -0,0 +1,328 @@ +/* Copyright 2004 The Apache Software Foundation + * + * Licensed 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.xmlbeans.impl.tool; + +import org.apache.xmlbeans.SchemaCodePrinter; +import org.apache.xmlbeans.XmlError; +import org.apache.xmlbeans.XmlOptions; +import org.xml.sax.EntityResolver; + +import java.io.File; +import java.net.URL; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +public class Parameters { + private File baseDir; + private File[] xsdFiles; + private File[] wsdlFiles; + private File[] javaFiles; + private File[] configFiles; + private URL[] urlFiles; + private File[] classpath; + private File outputJar; + private String name; + private File srcDir; + private File classesDir; + private String memoryInitialSize; + private String memoryMaximumSize; + private String compiler; + private boolean nojavac; + private boolean quiet; + private boolean verbose; + private boolean download; + private Collection<XmlError> errorListener; + private boolean noUpa; + private boolean noPvr; + private boolean noAnn; + private boolean noVDoc; + private boolean noExt; + private boolean debug; + private boolean incrementalSrcGen; + private String repackage; + private List<Extension> extensions = Collections.emptyList(); + private Set<String> mdefNamespaces = Collections.emptySet(); + private String catalogFile; + private SchemaCodePrinter schemaCodePrinter; + private EntityResolver entityResolver; + private Set<XmlOptions.BeanMethod> partialMethods = Collections.emptySet(); + + public File getBaseDir() { + return baseDir; + } + + public void setBaseDir(File baseDir) { + this.baseDir = baseDir; + } + + public File[] getXsdFiles() { + return xsdFiles; + } + + public void setXsdFiles(File... xsdFiles) { + this.xsdFiles = xsdFiles; + } + + public File[] getWsdlFiles() { + return wsdlFiles; + } + + public void setWsdlFiles(File[] wsdlFiles) { + this.wsdlFiles = wsdlFiles; + } + + public File[] getJavaFiles() { + return javaFiles; + } + + public void setJavaFiles(File[] javaFiles) { + this.javaFiles = javaFiles; + } + + public File[] getConfigFiles() { + return configFiles; + } + + public void setConfigFiles(File[] configFiles) { + this.configFiles = configFiles; + } + + public URL[] getUrlFiles() { + return urlFiles; + } + + public void setUrlFiles(URL[] urlFiles) { + this.urlFiles = urlFiles; + } + + public File[] getClasspath() { + return classpath; + } + + public void setClasspath(File[] classpath) { + this.classpath = classpath; + } + + public File getOutputJar() { + return outputJar; + } + + public void setOutputJar(File outputJar) { + this.outputJar = outputJar; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public File getSrcDir() { + return srcDir; + } + + public void setSrcDir(File srcDir) { + this.srcDir = srcDir; + } + + public File getClassesDir() { + return classesDir; + } + + public void setClassesDir(File classesDir) { + this.classesDir = classesDir; + } + + public boolean isNojavac() { + return nojavac; + } + + public void setNojavac(boolean nojavac) { + this.nojavac = nojavac; + } + + public boolean isQuiet() { + return quiet; + } + + public void setQuiet(boolean quiet) { + this.quiet = quiet; + } + + public boolean isVerbose() { + return verbose; + } + + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + public boolean isDownload() { + return download; + } + + public void setDownload(boolean download) { + this.download = download; + } + + public boolean isNoUpa() { + return noUpa; + } + + public void setNoUpa(boolean noUpa) { + this.noUpa = noUpa; + } + + public boolean isNoPvr() { + return noPvr; + } + + public void setNoPvr(boolean noPvr) { + this.noPvr = noPvr; + } + + public boolean isNoAnn() { + return noAnn; + } + + public void setNoAnn(boolean noAnn) { + this.noAnn = noAnn; + } + + public boolean isNoVDoc() { + return noVDoc; + } + + public void setNoVDoc(boolean newNoVDoc) { + this.noVDoc = newNoVDoc; + } + + public boolean isNoExt() { + return noExt; + } + + public void setNoExt(boolean newNoExt) { + this.noExt = newNoExt; + } + + public boolean isIncrementalSrcGen() { + return incrementalSrcGen; + } + + public void setIncrementalSrcGen(boolean incrSrcGen) { + this.incrementalSrcGen = incrSrcGen; + } + + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public String getMemoryInitialSize() { + return memoryInitialSize; + } + + public void setMemoryInitialSize(String memoryInitialSize) { + this.memoryInitialSize = memoryInitialSize; + } + + public String getMemoryMaximumSize() { + return memoryMaximumSize; + } + + public void setMemoryMaximumSize(String memoryMaximumSize) { + this.memoryMaximumSize = memoryMaximumSize; + } + + public String getCompiler() { + return compiler; + } + + public void setCompiler(String compiler) { + this.compiler = compiler; + } + + public Collection<XmlError> getErrorListener() { + return errorListener; + } + + public void setErrorListener(Collection<XmlError> errorListener) { + this.errorListener = errorListener; + } + + public String getRepackage() { + return repackage; + } + + public void setRepackage(String newRepackage) { + repackage = newRepackage; + } + + public List<Extension> getExtensions() { + return extensions; + } + + public void setExtensions(List<Extension> extensions) { + this.extensions = extensions; + } + + public Set<String> getMdefNamespaces() { + return mdefNamespaces; + } + + public void setMdefNamespaces(Set<String> mdefNamespaces) { + this.mdefNamespaces = mdefNamespaces; + } + + public String getCatalogFile() { + return catalogFile; + } + + public void setCatalogFile(String catalogPropFile) { + this.catalogFile = catalogPropFile; + } + + public SchemaCodePrinter getSchemaCodePrinter() { + return schemaCodePrinter; + } + + public void setSchemaCodePrinter(SchemaCodePrinter schemaCodePrinter) { + this.schemaCodePrinter = schemaCodePrinter; + } + + public EntityResolver getEntityResolver() { + return entityResolver; + } + + public void setEntityResolver(EntityResolver entityResolver) { + this.entityResolver = entityResolver; + } + + public Set<XmlOptions.BeanMethod> getPartialMethods() { + return partialMethods; + } + + public void setPartialMethods(Set<XmlOptions.BeanMethod> partialMethods) { + this.partialMethods = partialMethods; + } +} Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java Sun Feb 21 21:34:00 2021 @@ -16,6 +16,7 @@ package org.apache.xmlbeans.impl.tool; import org.apache.xmlbeans.*; +import org.apache.xmlbeans.XmlOptions.BeanMethod; import org.apache.xmlbeans.impl.common.*; import org.apache.xmlbeans.impl.config.BindingConfigImpl; import org.apache.xmlbeans.impl.repackage.Repackager; @@ -62,6 +63,8 @@ public class SchemaCompiler { System.out.println(" -license - prints license information"); System.out.println(" -allowmdef \"[ns] [ns] [ns]\" - ignores multiple defs in given namespaces (use ##local for no-namespace)"); System.out.println(" -catalog [file] - catalog file for org.apache.xml.resolver.tools.CatalogResolver. (Note: needs resolver.jar from http://xml.apache.org/commons/components/resolver/index.html)"); + System.out.println(" -partialMethods [list] - comma separated list of bean methods to be generated. Use \"-\" to negate and \"ALL\" for all." ); + System.out.println(" processed left-to-right, e.g. \"ALL,-GET_LIST\" exclude java.util.List getters - see XmlOptions.BeanMethod" ); /* Undocumented feature - pass in one schema compiler extension and related parameters System.out.println(" -repackage - repackage specification"); System.out.println(" -extension - registers a schema compiler extension"); @@ -111,6 +114,8 @@ public class SchemaCompiler { opts.add("extensionParms"); opts.add("allowmdef"); opts.add("catalog"); + opts.add("partialMethods"); + CommandLine cl = new CommandLine(args, flags, opts); if (cl.getOpt("h") != null || cl.getOpt("help") != null || cl.getOpt("usage") != null) { @@ -298,6 +303,8 @@ public class SchemaCompiler { String catString = cl.getOpt("catalog"); + String partialMethods = cl.getOpt("partialMethods"); + Parameters params = new Parameters(); params.setBaseDir(baseDir); params.setXsdFiles(xsdFiles); @@ -329,7 +336,7 @@ public class SchemaCompiler { params.setMdefNamespaces(mdefNamespaces); params.setCatalogFile(catString); params.setSchemaCodePrinter(codePrinter); - + params.setPartialMethods(parsePartialMethods(partialMethods)); boolean result = compile(params); if (tempdir != null) { @@ -343,297 +350,6 @@ public class SchemaCompiler { System.exit(0); } - public static class Parameters { - private File baseDir; - private File[] xsdFiles; - private File[] wsdlFiles; - private File[] javaFiles; - private File[] configFiles; - private URL[] urlFiles; - private File[] classpath; - private File outputJar; - private String name; - private File srcDir; - private File classesDir; - private String memoryInitialSize; - private String memoryMaximumSize; - private String compiler; - private boolean nojavac; - private boolean quiet; - private boolean verbose; - private boolean download; - private Collection<XmlError> errorListener; - private boolean noUpa; - private boolean noPvr; - private boolean noAnn; - private boolean noVDoc; - private boolean noExt; - private boolean debug; - private boolean incrementalSrcGen; - private String repackage; - private List<Extension> extensions = Collections.emptyList(); - private Set<String> mdefNamespaces = Collections.emptySet(); - private String catalogFile; - private SchemaCodePrinter schemaCodePrinter; - private EntityResolver entityResolver; - - public File getBaseDir() { - return baseDir; - } - - public void setBaseDir(File baseDir) { - this.baseDir = baseDir; - } - - public File[] getXsdFiles() { - return xsdFiles; - } - - public void setXsdFiles(File[] xsdFiles) { - this.xsdFiles = xsdFiles; - } - - public File[] getWsdlFiles() { - return wsdlFiles; - } - - public void setWsdlFiles(File[] wsdlFiles) { - this.wsdlFiles = wsdlFiles; - } - - public File[] getJavaFiles() { - return javaFiles; - } - - public void setJavaFiles(File[] javaFiles) { - this.javaFiles = javaFiles; - } - - public File[] getConfigFiles() { - return configFiles; - } - - public void setConfigFiles(File[] configFiles) { - this.configFiles = configFiles; - } - - public URL[] getUrlFiles() { - return urlFiles; - } - - public void setUrlFiles(URL[] urlFiles) { - this.urlFiles = urlFiles; - } - - public File[] getClasspath() { - return classpath; - } - - public void setClasspath(File[] classpath) { - this.classpath = classpath; - } - - public File getOutputJar() { - return outputJar; - } - - public void setOutputJar(File outputJar) { - this.outputJar = outputJar; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public File getSrcDir() { - return srcDir; - } - - public void setSrcDir(File srcDir) { - this.srcDir = srcDir; - } - - public File getClassesDir() { - return classesDir; - } - - public void setClassesDir(File classesDir) { - this.classesDir = classesDir; - } - - public boolean isNojavac() { - return nojavac; - } - - public void setNojavac(boolean nojavac) { - this.nojavac = nojavac; - } - - public boolean isQuiet() { - return quiet; - } - - public void setQuiet(boolean quiet) { - this.quiet = quiet; - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public boolean isDownload() { - return download; - } - - public void setDownload(boolean download) { - this.download = download; - } - - public boolean isNoUpa() { - return noUpa; - } - - public void setNoUpa(boolean noUpa) { - this.noUpa = noUpa; - } - - public boolean isNoPvr() { - return noPvr; - } - - public void setNoPvr(boolean noPvr) { - this.noPvr = noPvr; - } - - public boolean isNoAnn() { - return noAnn; - } - - public void setNoAnn(boolean noAnn) { - this.noAnn = noAnn; - } - - public boolean isNoVDoc() { - return noVDoc; - } - - public void setNoVDoc(boolean newNoVDoc) { - this.noVDoc = newNoVDoc; - } - - public boolean isNoExt() { - return noExt; - } - - public void setNoExt(boolean newNoExt) { - this.noExt = newNoExt; - } - - public boolean isIncrementalSrcGen() { - return incrementalSrcGen; - } - - public void setIncrementalSrcGen(boolean incrSrcGen) { - this.incrementalSrcGen = incrSrcGen; - } - - public boolean isDebug() { - return debug; - } - - public void setDebug(boolean debug) { - this.debug = debug; - } - - public String getMemoryInitialSize() { - return memoryInitialSize; - } - - public void setMemoryInitialSize(String memoryInitialSize) { - this.memoryInitialSize = memoryInitialSize; - } - - public String getMemoryMaximumSize() { - return memoryMaximumSize; - } - - public void setMemoryMaximumSize(String memoryMaximumSize) { - this.memoryMaximumSize = memoryMaximumSize; - } - - public String getCompiler() { - return compiler; - } - - public void setCompiler(String compiler) { - this.compiler = compiler; - } - - public Collection<XmlError> getErrorListener() { - return errorListener; - } - - public void setErrorListener(Collection<XmlError> errorListener) { - this.errorListener = errorListener; - } - - public String getRepackage() { - return repackage; - } - - public void setRepackage(String newRepackage) { - repackage = newRepackage; - } - - public List<Extension> getExtensions() { - return extensions; - } - - public void setExtensions(List<Extension> extensions) { - this.extensions = extensions; - } - - public Set<String> getMdefNamespaces() { - return mdefNamespaces; - } - - public void setMdefNamespaces(Set<String> mdefNamespaces) { - this.mdefNamespaces = mdefNamespaces; - } - - public String getCatalogFile() { - return catalogFile; - } - - public void setCatalogFile(String catalogPropFile) { - this.catalogFile = catalogPropFile; - } - - public SchemaCodePrinter getSchemaCodePrinter() { - return schemaCodePrinter; - } - - public void setSchemaCodePrinter(SchemaCodePrinter schemaCodePrinter) { - this.schemaCodePrinter = schemaCodePrinter; - } - - public EntityResolver getEntityResolver() { - return entityResolver; - } - - public void setEntityResolver(EntityResolver entityResolver) { - this.entityResolver = entityResolver; - } - } - private static SchemaTypeSystem loadTypeSystem(String name, File[] xsdFiles, File[] wsdlFiles, URL[] urlFiles, File[] configFiles, File[] javaFiles, ResourceLoader cpResourceLoader, boolean download, boolean noUpa, boolean noPvr, boolean noAnn, boolean noVDoc, boolean noExt, @@ -894,6 +610,7 @@ public class SchemaCompiler { boolean noExt = params.isNoExt(); boolean incrSrcGen = params.isIncrementalSrcGen(); Collection<XmlError> outerErrorListener = params.getErrorListener(); + Set<BeanMethod> partialMethods = params.getPartialMethods(); String repackage = params.getRepackage(); @@ -968,6 +685,7 @@ public class SchemaCompiler { if (codePrinter != null) { options.setSchemaCodePrinter(codePrinter); } + options.setCompilePartialMethod(partialMethods); // save .xsb files system.save(filer); @@ -1035,6 +753,26 @@ public class SchemaCompiler { return result; } + static Set<BeanMethod> parsePartialMethods(String partialMethods) { + final Set<BeanMethod> beanMethods = new HashSet<>(); + if (partialMethods != null) { + for (String pm : partialMethods.split(",")) { + if ("ALL".equals(pm)) { + beanMethods.addAll(Arrays.asList(BeanMethod.values())); + continue; + } + boolean neg = pm.startsWith("-"); + BeanMethod bm = BeanMethod.valueOf(pm.substring(neg ? 1 : 0)); + if (neg) { + beanMethods.remove(bm); + } else { + beanMethods.add(bm); + } + } + } + return beanMethods.isEmpty() ? null : beanMethods; + } + private static void runExtensions(List<Extension> extensions, SchemaTypeSystem system, File classesDir) { if (extensions != null && extensions.size() > 0) { SchemaCompilerExtension sce; Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java Sun Feb 21 21:34:00 2021 @@ -25,6 +25,7 @@ import org.apache.tools.ant.types.FileSe import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.xmlbeans.XmlError; +import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.impl.common.IOUtil; import java.io.File; @@ -82,7 +83,8 @@ public class XMLBean extends MatchingTas memoryInitialSize, memoryMaximumSize, catalog, - repackage; + repackage, + partialMethods; private final List<Extension> extensions = new ArrayList<>(); @@ -203,7 +205,7 @@ public class XMLBean extends MatchingTas } // generate the source - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setBaseDir(theBasedir); params.setXsdFiles(xsdArray); params.setWsdlFiles(wsdlArray); @@ -229,6 +231,7 @@ public class XMLBean extends MatchingTas params.setNoVDoc(novdoc); params.setNoExt(noext); params.setRepackage(repackage); + params.setPartialMethods(SchemaCompiler.parsePartialMethods(partialMethods)); success = SchemaCompiler.compile(params); if (success && !srconly) { @@ -764,6 +767,20 @@ public class XMLBean extends MatchingTas this.repackage = repackage; } + public String getPartialMethods() { + return partialMethods; + } + + /** + * Comma separated list of bean methods to be generated. Use "-" to negate and "ALL" for all. + * processed left-to-right, e.g. "ALL,-GET_LIST" exclude java.util.List getters + * + * @see XmlOptions.BeanMethod + */ + public void setPartialMethods(String partialMethods) { + this.partialMethods = partialMethods; + } + private static URI uriFromFile(File f) { if (f == null) { return null; Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListObject.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListObject.java?rev=1886771&view=auto ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListObject.java (added) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListObject.java Sun Feb 21 21:34:00 2021 @@ -0,0 +1,89 @@ +/* Copyright 2004 The Apache Software Foundation + * + * Licensed 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.xmlbeans.impl.values; + +import java.util.AbstractList; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +public class JavaListObject<T> extends AbstractList<T> { + private final Function<Integer,T> getter; + private final BiConsumer<Integer,T> setter; + private final BiConsumer<Integer,T> adder; + private final Consumer<Integer> remover; + private final Supplier<Integer> sizer; + + public JavaListObject( + Function<Integer,T> getter, + BiConsumer<Integer,T> setter, + BiConsumer<Integer,T> adder, + Consumer<Integer> remover, + Supplier<Integer> sizer + ) { + this.getter = getter; + this.setter = setter; + this.adder = adder; + this.remover = remover; + this.sizer = sizer; + } + + + @Override + public T get(int index) { + if (getter == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no getter method available"); + } + return getter.apply(index); + } + + @Override + public T set(int index, T element) { + if (setter == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no setter method available"); + } + T old = get(index); + setter.accept(index, element); + return old; + } + + @Override + public void add(int index, T t) { + if (adder == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no add method available"); + } + adder.accept(index, t); + } + + @Override + public T remove(int index) { + if (remover == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no remove method available"); + } + T old = get(index); + remover.accept(index); + return old; + } + + @Override + public int size() { + if (sizer == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no size-of method available"); + } + return sizer.get(); + } +} Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListXmlObject.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListXmlObject.java?rev=1886771&view=auto ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListXmlObject.java (added) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaListXmlObject.java Sun Feb 21 21:34:00 2021 @@ -0,0 +1,91 @@ +/* Copyright 2004 The Apache Software Foundation + * + * Licensed 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.xmlbeans.impl.values; + +import org.apache.xmlbeans.XmlObject; + +import java.util.AbstractList; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +public class JavaListXmlObject<T extends XmlObject> extends AbstractList<T> { + private final Function<Integer,T> getter; + private final BiConsumer<Integer,T> setter; + private final Function<Integer,T> adder; + private final Consumer<Integer> remover; + private final Supplier<Integer> sizer; + + public JavaListXmlObject( + Function<Integer,T> getter, + BiConsumer<Integer,T> setter, + Function<Integer,T> adder, + Consumer<Integer> remover, + Supplier<Integer> sizer + ) { + this.getter = getter; + this.setter = setter; + this.adder = adder; + this.remover = remover; + this.sizer = sizer; + } + + + @Override + public T get(int index) { + if (getter == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no getter available"); + } + return getter.apply(index); + } + + @Override + public T set(int index, T element) { + if (setter == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no setter available"); + } + T old = get(index); + setter.accept(index, element); + return old; + } + + @Override + public void add(int index, T t) { + if (adder == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no add method available"); + } + adder.apply(index).set(t); + } + + @Override + public T remove(int index) { + if (remover == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no remove method available"); + } + T old = get(index); + remover.accept(index); + return old; + } + + @Override + public int size() { + if (sizer == null) { + throw new IllegalStateException("XmlBean generated using partial methods - no size-of method available"); + } + return sizer.get(); + } +} Modified: xmlbeans/trunk/src/main/multimodule/java9/module-info.class URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/multimodule/java9/module-info.class?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== Binary files - no diff available. Modified: xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java Sun Feb 21 21:34:00 2021 @@ -15,14 +15,12 @@ package compile.scomp.checkin; -import common.Common; import compile.scomp.common.CompileCommon; import org.apache.xmlbeans.*; +import org.apache.xmlbeans.XmlOptions.BeanMethod; import org.apache.xmlbeans.impl.common.QNameHelper; -import org.apache.xmlbeans.impl.tool.CodeGenUtil; -import org.apache.xmlbeans.impl.tool.Diff; -import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator; -import org.apache.xmlbeans.impl.tool.SchemaCompiler; +import org.apache.xmlbeans.impl.tool.*; +import org.apache.xmlbeans.impl.util.FilerImpl; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelComplexType; import org.junit.Assert; @@ -35,27 +33,115 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; +import java.util.stream.Stream; import static common.Common.getRootFile; +import static java.util.Collections.singletonList; import static org.junit.Assert.*; +@SuppressWarnings({"SpellCheckingInspection", "ResultOfMethodCallIgnored"}) public class CompilationTests { + private static final File fwroot = new File(getRootFile()); + + //location of files under "cases folder" + private static final String fileLocation = CompileCommon.fileLocation; + private static final File outputroot = new File(fwroot, "build/test/output"); + + + private static final String[] invalidSchemas = { + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + + " <xs:complexType name='base' final='extension'/>\n" + + " <xs:complexType name='ext'>\n" + + " <xs:complexContent>\n" + + " <xs:extension base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + + " <xs:complexType name='base' final='#all'/>\n" + + " <xs:complexType name='ext'>\n" + + " <xs:complexContent>\n" + + " <xs:extension base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='#all'>\n" + + " <xs:complexType name='base'/>\n" + + " <xs:complexType name='rest'>\n" + + " <xs:complexContent>\n" + + " <xs:restriction base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='restriction'>\n" + + " <xs:complexType name='base'/>\n" + + " <xs:complexType name='rest'>\n" + + " <xs:complexContent>\n" + + " <xs:restriction base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + }; + + static String[] validSchemas = { + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + + " <xs:complexType name='base' final='extension'/>\n" + + " <xs:complexType name='rest'>\n" + + " <xs:complexContent>\n" + + " <xs:restriction base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + + " <xs:complexType name='base' final='restriction'/>\n" + + " <xs:complexType name='ext'>\n" + + " <xs:complexContent>\n" + + " <xs:extension base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='restriction'>\n" + + " <xs:complexType name='base'/>\n" + + " <xs:complexType name='ext'>\n" + + " <xs:complexContent>\n" + + " <xs:extension base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + + "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='extension'>\n" + + " <xs:complexType name='base'/>\n" + + " <xs:complexType name='rest'>\n" + + " <xs:complexContent>\n" + + " <xs:restriction base='base'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n", + }; + + @Test - public void testJ2EE() throws Throwable { + public void testJ2EE() { deltree(xbeanOutput("compile/scomp/j2ee")); // First, compile schema File srcdir = xbeanOutput("compile/scomp/j2ee/j2eeconfigxml/src"); File classesdir = xbeanOutput("compile/scomp/j2ee/j2eeconfigxml/classes"); File outputjar = xbeanOutput("compile/scomp/j2ee/j2eeconfigxml.jar"); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[]{ + Parameters params = new Parameters(); + params.setXsdFiles( xbeanCase("j2ee/application-client_1_4.xsd"), xbeanCase("j2ee/application_1_4.xsd"), xbeanCase("j2ee/connector_1_5.xsd"), @@ -63,13 +149,12 @@ public class CompilationTests { xbeanCase("j2ee/j2ee_1_4.xsd"), xbeanCase("j2ee/jsp_2_0.xsd"), xbeanCase("j2ee/web-app_2_4.xsd"), - xbeanCase("j2ee/XML.xsd") - }); + xbeanCase("j2ee/XML.xsd")); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); params.setMdefNamespaces(Collections.singleton("http://java.sun.com/xml/ns/j2ee")); - List errors = new ArrayList(); + List<XmlError> errors = new ArrayList<>(); params.setErrorListener(errors); boolean result = SchemaCompiler.compile(params); StringWriter message = new StringWriter(); @@ -80,7 +165,7 @@ public class CompilationTests { } @Test - public void testIncrementalCompilation() throws Throwable { + public void testIncrementalCompilation() throws IOException, XmlException { File[] files = new File[]{ xbeanCase("incr/incr1.xsd"), xbeanCase("incr/incr3.xsd"), @@ -100,7 +185,7 @@ public class CompilationTests { // Compile incrementally // Initial compile schemas[n - 2] = SchemaDocument.Factory.parse(files[n - 2]).getSchema(); - List errors = new ArrayList(); + List<XmlError> errors = new ArrayList<>(); XmlOptions options = (new XmlOptions()).setErrorListener(errors); SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem(); system = XmlBeans.compileXsd(schemas, builtin, options); @@ -141,7 +226,8 @@ public class CompilationTests { schemas[n - 2] = schemas1[0]; system = XmlBeans.compileXsd(schemas, builtin, options); Assert.assertNotNull("Compilation failed during reference compile.", system); - SchemaCodeGenerator.saveTypeSystem(system, out, null, null, null); + Filer filer = new FilerImpl(out, null, null, false, false); + system.save(filer); System.out.println("-= Sanity Compile =-"); for (int i = 0; i < system.globalTypes().length; i++) { @@ -158,19 +244,14 @@ public class CompilationTests { String oldPropValue = System.getProperty("xmlbeans.diff.diffIndex"); System.setProperty("xmlbeans.diff.diffIndex", "false"); errors.clear(); - Diff.dirsAsTypeSystems(out, outincr, errors); + List<String> diffs = new ArrayList<>(); + Diff.dirsAsTypeSystems(out, outincr, diffs); System.setProperty("xmlbeans.diff.diffIndex", oldPropValue == null ? "true" : oldPropValue); - if (errors.size() > 0) { - StringWriter message = new StringWriter(); - for (int i = 0; i < errors.size(); i++) - message.write(((String) errors.get(i)) + "\n"); - fail("Differences encountered:" + message); - } - + assertEquals("Differences encountered:" + String.join("\n", diffs), 0, diffs.size()); } @Test - public void testSchemaBookmarks() throws Throwable { + public void testSchemaBookmarks() throws XmlException, IOException { File srcSchema = xbeanCase("../../simple/person/person.xsd"); // Parse SchemaDocument.Schema parsed = SchemaDocument.Factory.parse(srcSchema).getSchema(); @@ -200,7 +281,7 @@ public class CompilationTests { } @Test - public void testSimple() throws Throwable { + public void testSimple() throws MalformedURLException, ClassNotFoundException { deltree(xbeanOutput("compile/scomp/simple")); // First, compile schema @@ -213,8 +294,8 @@ public class CompilationTests { File classesdir = xbeanOutput("compile/scomp/simple/simpletypes/classes"); File outputjar = xbeanOutput("compile/scomp/simple/simpletypes.jar"); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[]{inputfile1, inputfile2}); + Parameters params = new Parameters(); + params.setXsdFiles(inputfile1, inputfile2); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); @@ -224,9 +305,8 @@ public class CompilationTests { File javasrc = new File(CompileCommon.fileLocation+"/simple"); File javaclasses = xbeanOutput("compile/scomp/simple/javaclasses"); javaclasses.mkdirs(); - List<File> testcp = new ArrayList<File>(Arrays.asList(CodeGenUtil.systemClasspath())); - testcp.add(outputjar); - CodeGenUtil.externalCompile(Arrays.asList(javasrc), javaclasses, testcp.toArray(new File[0]), true); + File[] testcp = Stream.concat(Stream.of(CodeGenUtil.systemClasspath()), Stream.of(outputjar)).toArray(File[]::new); + CodeGenUtil.externalCompile(singletonList(javasrc), javaclasses, testcp, true); // Then run the test URLClassLoader childcl = new URLClassLoader(new URL[]{outputjar.toURI().toURL()}, CompilationTests.class.getClassLoader()); @@ -237,7 +317,7 @@ public class CompilationTests { @Test @Ignore - public void testDownload() throws Throwable { + public void testDownload() { deltree(xbeanOutput("compile/scomp/include")); { @@ -245,15 +325,13 @@ public class CompilationTests { File srcdir = xbeanOutput("compile/scomp/include/shouldfail/src"); File classesdir = xbeanOutput("compile/scomp/include/shouldfail/classes"); File outputjar = xbeanOutput("compile/scomp/include/shouldfail.jar"); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[]{ - xbeanCase("compile/scomp/j2ee/j2ee_1_4.xsd") - }); + Parameters params = new Parameters(); + params.setXsdFiles(xbeanCase("compile/scomp/j2ee/j2ee_1_4.xsd")); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - assertTrue("Build should have failed", !SchemaCompiler.compile(params)); - assertTrue("Should not have created " + outputjar, !outputjar.exists()); + assertFalse("Build should have failed", SchemaCompiler.compile(params)); + assertFalse("Should not have created " + outputjar, outputjar.exists()); } { @@ -261,11 +339,9 @@ public class CompilationTests { File srcdir = xbeanOutput("compile/scomp/include/shouldsucceed/src"); File classesdir = xbeanOutput("compile/scomp/include/shouldsucceed/classes"); File outputjar = xbeanOutput("compile/scomp/include/shouldsucceed.jar"); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setDownload(true); - params.setXsdFiles(new File[]{ - xbeanCase("compile/scomp/j2ee/j2ee_1_4.xsd") - }); + params.setXsdFiles(xbeanCase("compile/scomp/j2ee/j2ee_1_4.xsd")); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); @@ -275,14 +351,14 @@ public class CompilationTests { } @Test - public void testPricequote() throws Throwable { + public void testPricequote() { deltree(xbeanOutput("compile/scomp/pricequote")); // First, compile schema File srcdir = xbeanOutput("compile/scomp/pricequote/src"); File classesdir = xbeanOutput("compile/scomp/pricequote/classes"); File outputjar = xbeanOutput("compile/scomp/pricequote/pricequote.jar"); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[]{xbeanCase("pricequote/PriceQuote.xsd")}); + Parameters params = new Parameters(); + params.setXsdFiles(xbeanCase("pricequote/PriceQuote.xsd")); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); @@ -290,127 +366,78 @@ public class CompilationTests { assertTrue("Cannout find " + outputjar, outputjar.exists()); } - private static String[] invalidSchemas = { - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + - " <xs:complexType name='base' final='extension'/>\n" + - " <xs:complexType name='ext'>\n" + - " <xs:complexContent>\n" + - " <xs:extension base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + - " <xs:complexType name='base' final='#all'/>\n" + - " <xs:complexType name='ext'>\n" + - " <xs:complexContent>\n" + - " <xs:extension base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='#all'>\n" + - " <xs:complexType name='base'/>\n" + - " <xs:complexType name='rest'>\n" + - " <xs:complexContent>\n" + - " <xs:restriction base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='restriction'>\n" + - " <xs:complexType name='base'/>\n" + - " <xs:complexType name='rest'>\n" + - " <xs:complexContent>\n" + - " <xs:restriction base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - }; - - static String[] validSchemas = { - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + - " <xs:complexType name='base' final='extension'/>\n" + - " <xs:complexType name='rest'>\n" + - " <xs:complexContent>\n" + - " <xs:restriction base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + - " <xs:complexType name='base' final='restriction'/>\n" + - " <xs:complexType name='ext'>\n" + - " <xs:complexContent>\n" + - " <xs:extension base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='restriction'>\n" + - " <xs:complexType name='base'/>\n" + - " <xs:complexType name='ext'>\n" + - " <xs:complexContent>\n" + - " <xs:extension base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - - "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='extension'>\n" + - " <xs:complexType name='base'/>\n" + - " <xs:complexType name='rest'>\n" + - " <xs:complexContent>\n" + - " <xs:restriction base='base'/>\n" + - " </xs:complexContent>\n" + - " </xs:complexType>\n" + - "</xs:schema>\n", - }; - @Test - public void testFinal() throws Throwable { - SchemaDocument[] schemas = new SchemaDocument[invalidSchemas.length]; + public void testInvalid() throws XmlException { + for (String schemaFile : invalidSchemas) { + // Parse the invalid schema files + SchemaDocument schema = SchemaDocument.Factory.parse(schemaFile); + // Now compile the invalid schemas, test that they fail + assertThrows("Schema should have failed to compile:\n" + schemaFile, XmlException.class, + () -> XmlBeans.loadXsd(schema)); + } + } - // Parse the invalid schema files - for (int i = 0; i < invalidSchemas.length; i++) - schemas[i] = SchemaDocument.Factory.parse(invalidSchemas[i]); + @Test + public void testValid() throws XmlException { + for (String schemaFile : validSchemas) { + // Parse the valid schema files + SchemaDocument schema = SchemaDocument.Factory.parse(schemaFile); + // Compile the valid schemas. They should not fail + SchemaTypeLoader xs = XmlBeans.loadXsd(schema); + assertNotNull(xs); + } + } - // Now compile the invalid schemas, test that they fail - for (int i = 0; i < schemas.length; i++) { - try { - XmlBeans.loadXsd(new XmlObject[]{schemas[i]}); - fail("Schema should have failed to compile:\n" + invalidSchemas[i]); - } catch (XmlException success) { - } + @Test + public void partials() throws InterruptedException, IOException { + String[] files = {"partials/RootDocument.java", "partials/impl/RootDocumentImpl.java"}; + String[] templ = new String[files.length]; + for (int i=0; i<files.length; i++) { + Path p = xbeanCase(files[i]).toPath(); + templ[i] = new String(Files.readAllBytes(p), StandardCharsets.UTF_8); } - // Parse the valid schema files - schemas = new SchemaDocument[validSchemas.length]; - for (int i = 0; i < validSchemas.length; i++) - schemas[i] = SchemaDocument.Factory.parse(validSchemas[i]); + deltree(xbeanOutput("compile/scomp/partials")); + File srcdir = xbeanOutput("compile/scomp/partials/src"); + File classesdir = xbeanOutput("compile/scomp/partials/classes"); + File outputjar = xbeanOutput("compile/scomp/partials/partialMethods.jar"); + Parameters params = new Parameters(); + params.setXsdFiles(xbeanCase("partials/partialMethods.xsd")); + params.setSrcDir(srcdir); + params.setClassesDir(classesdir); + params.setOutputJar(outputjar); + params.setName("Partials"); - // Compile the valid schemas. They should not fail - for (int i = 0; i < schemas.length; i++) { - try { - XmlBeans.loadXsd(new XmlObject[]{schemas[i]}); - } catch (XmlException fail) { - fail("Failed to compile schema:\n" + validSchemas[i]); + // exclude each bean method and compare with the template with that method excluded too + for (BeanMethod removeMethod : BeanMethod.values()) { + Set<BeanMethod> partialMethods = new HashSet<>(Arrays.asList(BeanMethod.values())); + partialMethods.remove(removeMethod); + params.setPartialMethods(partialMethods); + SchemaCompiler.compile(params); + + for (int i=0; i<files.length; i++) { + Path p = new File(srcdir, files[i]).toPath(); + String act = new String(Files.readAllBytes(p), StandardCharsets.UTF_8); + String exp = templ[i]; + // remove marker + content + exp = exp.replaceAll("(?m)^.*<" + removeMethod + ">(?s).+?</" + removeMethod + ">$\\n", ""); + // activate alternative content + exp = exp.replaceAll("(?m)^.*//.*</?" + removeMethod + "_ELSE>$\\n", ""); + // remove other alternative content + exp = exp.replaceAll("(?m)^.*<[^>]+_ELSE>(?s).+?</[^>]+_ELSE>$\\n", ""); + // remove unused markers + exp = exp.replaceAll("(?m)^.*//.*<.*>$\\n", ""); + assertEquals(files[i] + " - " + removeMethod + " failed", exp, act); } } } - //TESTENV: - - private static final File fwroot = new File(getRootFile()); - private static final File caseroot = new File(Common.getCaseLocation()); - //location of files under "cases folder" - private static final String fileLocation = CompileCommon.fileLocation; - private static final File outputroot = new File(fwroot, "build/test/output"); + //TESTENV: - private static void dumpErrors(List errors, PrintWriter out) { + private static void dumpErrors(List<XmlError> errors, PrintWriter out) { // Display the errors - for (int i = 0; i < errors.size(); i++) { - XmlError error = (XmlError) errors.get(i); + for (XmlError error : errors) { if (error.getSeverity() == XmlError.SEVERITY_ERROR) out.println(error.toString()); } @@ -427,29 +454,31 @@ public class CompilationTests { return result; } - private static void deltree(File dir) - throws InterruptedException { - if (dir.exists()) { - if (dir.isDirectory()) { - String[] list = dir.list(); - for (int i = 0; i < list.length; i++) - deltree(new File(dir, list[i])); - } - if (!dir.delete()) { - for (int i = 0; i < 5; i++) { - try { - System.out.println("Sleep 1s and try do delete it again: " + dir.getCanonicalPath()); - } catch (IOException e) { - e.printStackTrace(System.out); - } - Thread.currentThread().sleep(1000); - if (dir.delete()) - return; + private static void deltree(File dir) { + if (!dir.exists()) { + return; + } + + if (dir.isDirectory()) { + String[] list = dir.list(); + if (list != null) { + for (String s : list) { + deltree(new File(dir, s)); } + } + } - if (!dir.delete()) - throw new IllegalStateException("Could not delete " + dir); + for (int i = 0; i < 5; i++) { + if (dir.delete()) { + return; + } + try { + System.out.println("Sleep 1s and try do delete it again: " + dir.getCanonicalPath()); + Thread.sleep(1000); + } catch (InterruptedException|IOException ignored) { } } + + throw new IllegalStateException("Could not delete " + dir); } } Modified: xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java Sun Feb 21 21:34:00 2021 @@ -16,6 +16,7 @@ package compile.scomp.common; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.tool.Diff; +import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator; import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; @@ -109,23 +110,23 @@ public class CompileTestBase extends Com return fList; } - protected SchemaCompiler.Parameters getCompilerParams() { - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + protected Parameters getCompilerParams() { + Parameters params = new Parameters(); params.setDownload(true); params.setVerbose(true); return params; } - protected SchemaCompiler.Parameters getIncrCompilerParams() { - SchemaCompiler.Parameters params = getCompilerParams(); + protected Parameters getIncrCompilerParams() { + Parameters params = getCompilerParams(); params.setIncrementalSrcGen(true); return params; } protected boolean runCompiler(File[] schemas, String srcDir, String classesDir, String outputDir, - SchemaCompiler.Parameters params) { + Parameters params) { File srcdir = xbeanOutput(srcDir); File classesdir = xbeanOutput(classesDir); Modified: xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java Sun Feb 21 21:34:00 2021 @@ -15,6 +15,7 @@ package compile.scomp.detailed; import common.Common; +import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.junit.Test; @@ -41,7 +42,7 @@ public class SchemaCompilerTests extends String testName) { List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(xsdFiles); params.setErrorListener(errors); params.setSrcDir(new File(schemaCompOutputDirPath + outputDirName + P + "src")); @@ -57,7 +58,7 @@ public class SchemaCompilerTests extends public void testUnionRedefine() { File[] xsdFiles = - new File[] { new File(scompTestFilesRoot + "union_initial.xsd"), + new File[] { new File(scompTestFilesRoot + "union_initial.xsd"), new File(scompTestFilesRoot + "union_redefine.xsd") }; String outputDirName = "unionred"; String testname = "testUnionRedefine"; @@ -70,7 +71,7 @@ public class SchemaCompilerTests extends @Test public void testEnumerationRedefine1() { - File[] xsdFiles = + File[] xsdFiles = new File[] { new File(scompTestFilesRoot + "enum1.xsd_"), new File(scompTestFilesRoot + "enum1_redefine.xsd_") }; String outputDirName = "enumRedef1"; @@ -84,7 +85,7 @@ public class SchemaCompilerTests extends @Test public void testEnumerationRedefine2() { - File[] xsdFiles = + File[] xsdFiles = new File[] { new File(scompTestFilesRoot + "enum2.xsd_"), new File(scompTestFilesRoot + "enum2_redefine.xsd_") }; String outputDirName = "enumRedef2"; @@ -98,7 +99,7 @@ public class SchemaCompilerTests extends @Test public void testEnumerationRedefine3() { - File[] xsdFiles = + File[] xsdFiles = new File[] { new File(scompTestFilesRoot + "enum1.xsd_"), new File(scompTestFilesRoot + "enum3.xsd_"), new File(scompTestFilesRoot + "enum3_redefine.xsd_") }; @@ -126,7 +127,7 @@ public class SchemaCompilerTests extends String outputDirName = "methodsColide_jira205"; List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(xsdFiles); params.setConfigFiles(configFiles); params.setJavaFiles(javaFiles); @@ -155,7 +156,7 @@ public class SchemaCompilerTests extends String outputDirName = "noExt"; List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(xsdFiles); params.setConfigFiles(configFiles); // no java files, if noExt flag doesn't work should fail for not finding the java files params.setJavaFiles(javaFiles); Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression151_200Test.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression151_200Test.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression151_200Test.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression151_200Test.java Sun Feb 21 21:34:00 2021 @@ -19,6 +19,7 @@ import misc.common.JiraTestBase; import net.eads.space.scoexml.test.TestExponentDocument; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; +import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.junit.Test; @@ -91,7 +92,7 @@ public class JiraRegression151_200Test e List errors = new ArrayList(); // compile with nopvr, goes thro fine - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_184_vdx_data_V1.04.xsd_")}); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java Sun Feb 21 21:34:00 2021 @@ -16,6 +16,7 @@ package misc.detailed; import misc.common.JiraTestBase; import org.apache.xmlbeans.*; +import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; import org.junit.Ignore; @@ -74,7 +75,7 @@ public class JiraRegression1_50Test exte public void test_jira_xmlbeans04() { List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_04.xsd_")}); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); @@ -260,7 +261,7 @@ public class JiraRegression1_50Test exte public void test_jira_xmlbeans34() throws Exception { List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_34b.xsd_")}); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); @@ -437,7 +438,7 @@ public class JiraRegression1_50Test exte */ public void test_jira_xmlbeans49() { List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_49.xsd_")}); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java Sun Feb 21 21:34:00 2021 @@ -22,6 +22,7 @@ import net.orthogony.xml.sample.structur import net.orthogony.xml.sample.structure.ChildType; import org.apache.beehive.netui.tools.testrecorder.x2004.session.RecorderSessionDocument; import org.apache.xmlbeans.*; +import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument; import org.junit.Assert; @@ -90,7 +91,7 @@ public class JiraRegression50_100Test ex public void test_jira_xmlbeans54() throws Exception { List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_54.xsd_")}); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); @@ -165,7 +166,7 @@ public class JiraRegression50_100Test ex File classDir = new File(outputDir + P + "classes"); classDir.mkdirs(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(new File[]{new File(JIRA_CASES + "xmlbeans_57.xml")}); params.setErrorListener(errorList); params.setSrcDir(srcDir); @@ -204,7 +205,7 @@ public class JiraRegression50_100Test ex @Ignore("the url doesn't exist anymore ...") public void test_jira_xmlbeans58() throws Exception { List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); // old url has been retired //params.setUrlFiles(new URL[]{new URL("http://devresource.hp.com/drc/specifications/wsrf/interfaces/WS-BrokeredNotification-1-0.wsdl")}); @@ -237,7 +238,7 @@ public class JiraRegression50_100Test ex File classDir = new File(outputDir + P + "classes"); classDir.mkdirs(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setWsdlFiles(new File[]{new File(JIRA_CASES + "xmlbeans_62.xml")}); params.setErrorListener(errorList); params.setSrcDir(srcDir); @@ -582,7 +583,7 @@ public class JiraRegression50_100Test ex @Test public void test_jira_xmlbeans88() throws Exception { List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setUrlFiles(new URL[]{new URL("http://developer.ebay.com/webservices/latest/eBaySvc.wsdl")}); params.setErrorListener(errors); Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java Sun Feb 21 21:34:00 2021 @@ -16,6 +16,7 @@ package misc.detailed; import misc.common.JiraTestBase; import org.apache.xmlbeans.XmlError; +import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.junit.Test; @@ -34,7 +35,7 @@ public class JiraRegressionSchemaCompile { System.out.println(xsdFiles[0].getAbsolutePath()); List errors = new ArrayList(); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(xsdFiles); params.setErrorListener(errors); params.setSrcDir(new File(schemaCompOutputDirPath + outputDirName + P + "src")); @@ -80,7 +81,7 @@ public class JiraRegressionSchemaCompile @Test public void test_jira_xmlbeans239() { - /* complexType with complexContent extending base type with + /* complexType with complexContent extending base type with simpleContent is valid */ File[] xsdFiles = new File[] { new File(scompTestFilesRoot + "xmlbeans_239a.xsd_") }; Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java?rev=1886771&r1=1886770&r2=1886771&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java Sun Feb 21 21:34:00 2021 @@ -18,6 +18,7 @@ package misc.detailed; import misc.common.JiraTestBase; import org.apache.xmlbeans.XmlError; import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.junit.Test; @@ -39,7 +40,7 @@ public class JiraRegressionTest101_150 e @Test public void test_jira_xmlbeans102a() throws Exception{ // set the parameters similar to those in the bug - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setXsdFiles(new File[]{new File(JIRA_CASES + "xmlbeans_102.xsd")}); params.setOutputJar(new File(outputroot+P+"xmlbeans_102.jar")); File outputDir = new File(outputroot + P + "xmlbeans_102"); @@ -62,7 +63,7 @@ public class JiraRegressionTest101_150 e public void test_jira_xmlbeans102b() { //Assert.fail("test_jira_xmlbeans102: Infinite loop after completion of parsing" ); - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + Parameters params = new Parameters(); params.setOutputJar(new File(schemaCompOutputDirPath + "jira102.jar")); params.setClassesDir(schemaCompClassesDir); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org