Modified: xmlbeans/branches/gradle-build/samples/build.xml URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/samples/build.xml?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/samples/build.xml (original) +++ xmlbeans/branches/gradle-build/samples/build.xml Mon Dec 27 20:28:38 2021 @@ -26,7 +26,7 @@ limitations under the License. clean-AbstractTypes, clean-SubstitutionGroup, clean-DateTime, - clean-XsdConfig + clean-XsdConfig "> <delete dir="build"/> </target> @@ -73,49 +73,49 @@ limitations under the License. build-SampleTemplate, build-MixedContent, build-OrderMatters, - build-vxsdb, build-SchemaEnum, build-AbstractTypes, build-SubstitutionGroup, build-DateTime, - build-XsdConfig + build-XsdConfig "> + <!-- build-vxsdb,--> </target> <target name="build-SampleTemplate"> - <ant dir="SampleTemplate" target="build"/> + <ant dir="SampleTemplate" target="build" inheritAll="true"/> </target> <target name="build-MixedContent"> - <ant dir="MixedContent" target="build"/> + <ant dir="MixedContent" target="build" inheritAll="true"/> </target> <target name="build-OrderMatters"> - <ant dir="OrderMatters" target="build"/> + <ant dir="OrderMatters" target="build" inheritAll="true"/> </target> <target name="build-vxsdb"> - <ant dir="vxsdb" target="build"/> + <ant dir="vxsdb" target="build" inheritAll="true"/> </target> <target name="build-SchemaEnum"> - <ant dir="SchemaEnum" target="build"/> + <ant dir="SchemaEnum" target="build" inheritAll="true"/> </target> <target name="build-AbstractTypes"> - <ant dir="AbstractTypes" target="build"/> + <ant dir="AbstractTypes" target="build" inheritAll="true"/> </target> <target name="build-SubstitutionGroup"> - <ant dir="SubstitutionGroup" target="build"/> + <ant dir="SubstitutionGroup" target="build" inheritAll="true"/> </target> <target name="build-DateTime"> - <ant dir="DateTime" target="build"/> + <ant dir="DateTime" target="build" inheritAll="true"/> </target> - + <target name="build-XsdConfig"> - <ant dir="XsdConfig" target="build"/> + <ant dir="XsdConfig" target="build" inheritAll="true"/> </target> <!-- ========================== test ==== --> @@ -125,13 +125,13 @@ limitations under the License. test-SampleTemplate, test-MixedContent, test-OrderMatters, - test-vxsdb, test-SchemaEnum, test-AbstractTypes, test-SubstitutionGroup, test-DateTime, - test-XsdConfig + test-XsdConfig "> + <!-- test-vxsdb,--> </target> <target name="test-SampleTemplate"> @@ -176,13 +176,14 @@ limitations under the License. dist-SampleTemplate, dist-MixedContent, dist-OrderMatters, - dist-vxsdb, dist-SchemaEnum, dist-AbstractTypes, dist-SubstitutionGroup, dist-DateTime, dist-XsdConfig "> + <!-- dist-vxsdb,--> + <zip destfile="build/samples.zip" basedir=".." includes="samples/**"
Propchange: xmlbeans/branches/gradle-build/samples/vxsdb/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Dec 27 20:28:38 2021 @@ -0,0 +1,2 @@ +build +lib Modified: xmlbeans/branches/gradle-build/samples/vxsdb/build.xml URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/samples/vxsdb/build.xml?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/samples/vxsdb/build.xml (original) +++ xmlbeans/branches/gradle-build/samples/vxsdb/build.xml Mon Dec 27 20:28:38 2021 @@ -60,17 +60,16 @@ <property name="xmlbeans.home" value="${env.XMLBEANS_HOME}" /> <echo message="xmlbeans.home: ${xmlbeans.home}" /> - <!-- check for xbean.jar from binary distribution --> - <available property="xmlbeans.lib" value="${xmlbeans.home}/lib" file="${xmlbeans.home}/lib/xbean.jar" /> + <!-- check for xmlbeans-*.jar from binary distribution --> + <pathconvert property="xmlbeans.lib" setonempty="false" pathsep=" "> + <path><fileset dir="${xmlbeans.home}/libs" includes="xmlbeans-*.jar" /></path> + </pathconvert> - <!-- check for xbean.jar compiled from source --> - <available property="xmlbeans.lib" value="${xmlbeans.home}/build/lib" file="${xmlbeans.home}/build/lib/xbean.jar" /> - - <fail message="Set XMLBEANS_HOME in your enviornment." unless="xmlbeans.lib" /> + <fail message="Set XMLBEANS_HOME in your enviornment." unless="xmlbeans.lib"/> <echo message="xmlbeans.lib: ${xmlbeans.lib}" /> <path id="xmlbeans.path"> - <fileset dir="${xmlbeans.lib}" includes="*.jar" /> + <fileset dir="${xmlbeans.home}/libs" includes="*.jar"/> </path> <mkdir dir="lib" /> Copied: xmlbeans/branches/gradle-build/settings.gradle (from r1896166, poi/trunk/settings.gradle) URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/settings.gradle?p2=xmlbeans/branches/gradle-build/settings.gradle&p1=poi/trunk/settings.gradle&r1=1896166&r2=1896456&rev=1896456&view=diff ============================================================================== --- poi/trunk/settings.gradle (original) +++ xmlbeans/branches/gradle-build/settings.gradle Mon Dec 27 20:28:38 2021 @@ -1,4 +1,4 @@ -rootProject.name = 'poi' +rootProject.name = 'xmlbeans' -include 'poi', 'poi-ooxml-full', 'poi-ooxml-lite-agent', 'poi-scratchpad', - 'poi-ooxml', 'poi-excelant', 'poi-examples', 'poi-integration' , 'poi-ooxml-lite' \ No newline at end of file +//include 'poi', 'poi-ooxml-full', 'poi-ooxml-lite-agent', 'poi-scratchpad', +// 'poi-ooxml', 'poi-excelant', 'poi-examples', 'poi-integration' , 'poi-ooxml-lite' \ No newline at end of file Modified: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/InterfaceExtension.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/InterfaceExtension.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/InterfaceExtension.java (original) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/InterfaceExtension.java Mon Dec 27 20:28:38 2021 @@ -44,6 +44,9 @@ public interface InterfaceExtension /** Returns the fully qualified type name of the parameter types in order. */ String[] getParameterTypes(); + /** Returns the name of the parameter */ + String[] getParameterNames(); + /** Returns the fully qualified type name of the exception types. */ String[] getExceptionTypes(); } Added: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/ChildSolverCollectionStrategy.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/ChildSolverCollectionStrategy.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/ChildSolverCollectionStrategy.java (added) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/ChildSolverCollectionStrategy.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,125 @@ +/* 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.config; + +import com.github.javaparser.ParserConfiguration; +import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver; +import com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver; +import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver; +import com.github.javaparser.utils.CollectionStrategy; +import com.github.javaparser.utils.ProjectRoot; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; + +import static java.nio.file.FileVisitResult.CONTINUE; +import static java.nio.file.FileVisitResult.SKIP_SUBTREE; + +/** + * Collection strategy which works on a subdirectory and determines the root source directory + * for further lookups + */ +class ChildSolverCollectionStrategy implements CollectionStrategy { + private static final Logger LOG = LogManager.getLogger(ChildSolverCollectionStrategy.class); + + private final ParserConfiguration config; + private final PathMatcher javaMatcher = getPathMatcher("glob:**.java"); + private final PathMatcher jarMatcher = getPathMatcher("glob:**.jar"); + private final List<Path> roots = new ArrayList<>(); + private final CombinedTypeSolver combinedTypeSolver; + + ChildSolverCollectionStrategy(ParserConfiguration config, CombinedTypeSolver combinedTypeSolver) { + this.config = config; + this.combinedTypeSolver = combinedTypeSolver; + } + + @Override + public ParserConfiguration getParserConfiguration() { + return config; + } + + @Override + public ProjectRoot collect(Path path) { + try { + Files.walkFileTree(path, new FileVisitor()); + } catch (IOException e) { + LOG.atWarn().withThrowable(e).log("Unable to walk {}",path); + } + return roots.isEmpty() ? null : new ProjectRoot(roots.get(roots.size()-1), config); + } + + public ProjectRoot collectAll() { + Path root = null; + for (Path p : roots) { + if (root == null) { + root = p; + } else { + root = commonRoot(root, p); + if (root == null) { + break; + } + } + } + + if (root == null) { + throw new IllegalStateException("Unable to construct a common project root - giving up."); + } + + ProjectRoot pr = new ProjectRoot(root, config); + roots.forEach(pr::addSourceRoot); + return pr; + } + + private static Path commonRoot(Path path1, Path path2) { + List<Path> l1 = new ArrayList<>(); + path1.toAbsolutePath().iterator().forEachRemaining(l1::add); + List<Path> l2 = new ArrayList<>(); + path2.toAbsolutePath().iterator().forEachRemaining(l2::add); + l1.retainAll(l2); + return l1.isEmpty() ? null : l1.get(l1.size()-1); + } + + private CombinedTypeSolver getSolver() { + return combinedTypeSolver; + } + + private class FileVisitor extends SimpleFileVisitor<Path> { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + if (javaMatcher.matches(file)) { + if (roots.stream().noneMatch(file::startsWith)) { + getRoot(file).ifPresent(r -> { + getSolver().add(new JavaParserTypeSolver(r, getParserConfiguration())); + roots.add(r); + }); + } + } else if (jarMatcher.matches(file)) { + getSolver().add(new JarTypeSolver(file)); + } + return CONTINUE; + } + + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + return Files.isHidden(dir) ? SKIP_SUBTREE : CONTINUE; + } + } +} Modified: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/InterfaceExtensionImpl.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/InterfaceExtensionImpl.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/InterfaceExtensionImpl.java (original) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/InterfaceExtensionImpl.java Mon Dec 27 20:28:38 2021 @@ -20,11 +20,17 @@ import com.github.javaparser.ast.body.Cl import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.Parameter; import com.github.javaparser.ast.type.ReferenceType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.type.TypeParameter; +import com.github.javaparser.resolution.MethodUsage; +import com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration; +import com.github.javaparser.resolution.types.ResolvedType; import org.apache.xmlbeans.InterfaceExtension; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.impl.xb.xmlconfig.Extensionconfig; import java.util.Arrays; +import java.util.List; import java.util.Objects; import java.util.stream.Stream; @@ -59,7 +65,7 @@ public class InterfaceExtensionImpl impl return result; } - if (!result.validateMethods(interfaceJClass, delegateJClass, intfXO)) + if (!result.validateMethods(loader, interfaceJClass, delegateJClass, intfXO)) return null; return result; @@ -81,7 +87,7 @@ public class InterfaceExtensionImpl impl final String ent = isInterface ? "Interface" : "Class"; ClassOrInterfaceDeclaration cls = loader.loadSource(clsStr); - if (cls==null) { + if (cls == null) { BindingConfigImpl.error(ent + " '" + clsStr + "' not found.", loc); return null; } @@ -97,8 +103,9 @@ public class InterfaceExtensionImpl impl return cls; } - private boolean validateMethods(ClassOrInterfaceDeclaration interfaceJClass, ClassOrInterfaceDeclaration delegateJClass, XmlObject loc) { - _methods = interfaceJClass.getMethods().stream() + private boolean validateMethods(Parser loader, ClassOrInterfaceDeclaration interfaceJClass, ClassOrInterfaceDeclaration delegateJClass, XmlObject loc) { + _methods = interfaceJClass.resolve().getAllMethods().stream() + .filter(m -> !Object.class.getName().equals(m.declaringType().getQualifiedName())) .map(m -> validateMethod(interfaceJClass, delegateJClass, m, loc)) .map(m -> m == null ? null : new MethodSignatureImpl(getStaticHandler(), m)) .toArray(MethodSignatureImpl[]::new); @@ -107,49 +114,91 @@ public class InterfaceExtensionImpl impl } private MethodDeclaration validateMethod(ClassOrInterfaceDeclaration interfaceJClass, - ClassOrInterfaceDeclaration delegateJClass, MethodDeclaration method, XmlObject loc) { + ClassOrInterfaceDeclaration delegateJClass, MethodUsage ifMethod, XmlObject loc) { + String methodName = ifMethod.getName(); - String methodName = method.getName().asString(); - - String[] delegateParams = Stream.concat( - Stream.of("org.apache.xmlbeans.XmlObject"), - Stream.of(paramStrings(method.getParameters())) - ).toArray(String[]::new); - - MethodDeclaration handlerMethod = getMethod(delegateJClass, methodName, delegateParams); + MethodDeclaration delMethod = delegateJClass.getMethodsByName(methodName).stream() + .filter(mDel -> matchParams(ifMethod, mDel)).findFirst().orElse(null); String delegateFQN = delegateJClass.getFullyQualifiedName().orElse(""); - String methodFQN = methodName + "(" + method.getParameters().toString() + ")"; + String methodFQN = methodName + "(" + ifMethod.getParamTypes().toString() + ")"; String interfaceFQN = interfaceJClass.getFullyQualifiedName().orElse(""); - if (handlerMethod == null) { + if (delMethod == null) { BindingConfigImpl.error("Handler class '" + delegateFQN + "' does not contain method " + methodFQN, loc); return null; } // check for throws exceptions - if (!Arrays.equals(exceptionStrings(method), exceptionStrings(handlerMethod))) { + String[] ifEx = ifMethod.getDeclaration().getSpecifiedExceptions().stream().map(ResolvedType::describe).sorted().toArray(String[]::new); + String[] delEx = delMethod.getThrownExceptions().stream().map(Type::resolve).map(ResolvedType::describe).sorted().toArray(String[]::new); + + if (!Arrays.equals(ifEx, delEx)) { BindingConfigImpl.error("Handler method '" + delegateFQN + "." + methodName + "' must declare the same " + - "exceptions as the interface method '" + interfaceFQN + "." + methodFQN, loc); + "exceptions as the interface method '" + interfaceFQN + "." + methodFQN, loc); return null; } - if (!handlerMethod.isPublic() || !handlerMethod.isStatic()) { - BindingConfigImpl.error("Method '" + delegateJClass.getFullyQualifiedName() + "." + - methodFQN + "' must be declared public and static.", loc); + if (!delMethod.isPublic() || !delMethod.isStatic()) { + BindingConfigImpl.error("Method '" + delegateFQN + "." + methodFQN + "' must be declared public and static.", loc); return null; } - String returnType = method.getTypeAsString(); - if (!returnType.equals(handlerMethod.getTypeAsString())) { + + if (!ifMethod.getDeclaration().getReturnType().equals(delMethod.resolve().getReturnType())) { + String returnType = ifMethod.getDeclaration().getReturnType().describe(); BindingConfigImpl.error("Return type for method '" + returnType + " " + delegateFQN + "." + methodName + - "(...)' does not match the return type of the interface method :'" + returnType + "'.", loc); + "(...)' does not match the return type of the interface method :'" + returnType + "'.", loc); return null; } - return method; + return delMethod; } +// private MethodDeclaration validateMethod(ClassOrInterfaceDeclaration interfaceJClass, +// ClassOrInterfaceDeclaration delegateJClass, MethodDeclaration method, XmlObject loc) { +// +// String methodName = method.getName().asString(); +// +// String[] delegateParams = Stream.concat( +// Stream.of("org.apache.xmlbeans.XmlObject"), +// Stream.of(paramStrings(method.getParameters())) +// ).toArray(String[]::new); +// +// MethodDeclaration handlerMethod = getMethod(delegateJClass, methodName, delegateParams); +// +// String delegateFQN = delegateJClass.getFullyQualifiedName().orElse(""); +// String methodFQN = methodName + "(" + method.getParameters().toString() + ")"; +// String interfaceFQN = interfaceJClass.getFullyQualifiedName().orElse(""); +// +// if (handlerMethod == null) { +// BindingConfigImpl.error("Handler class '" + delegateFQN + "' does not contain method " + methodFQN, loc); +// return null; +// } +// +// // check for throws exceptions +// if (!Arrays.equals(exceptionStrings(method), exceptionStrings(handlerMethod))) { +// BindingConfigImpl.error("Handler method '" + delegateFQN + "." + methodName + "' must declare the same " + +// "exceptions as the interface method '" + interfaceFQN + "." + methodFQN, loc); +// return null; +// } +// +// if (!handlerMethod.isPublic() || !handlerMethod.isStatic()) { +// BindingConfigImpl.error("Method '" + delegateJClass.getFullyQualifiedName() + "." + +// methodFQN + "' must be declared public and static.", loc); +// return null; +// } +// +// String returnType = method.getTypeAsString(); +// if (!returnType.equals(handlerMethod.getTypeAsString())) { +// BindingConfigImpl.error("Return type for method '" + returnType + " " + delegateFQN + "." + methodName + +// "(...)' does not match the return type of the interface method :'" + returnType + "'.", loc); +// return null; +// } +// +// return method; +// } + static MethodDeclaration getMethod(ClassOrInterfaceDeclaration cls, String name, String[] paramTypes) { // cls.getMethodsBySignature only checks the type name as-is ... i.e. if the type name is imported // only the simple name is checked, otherwise the full qualified name @@ -158,14 +207,49 @@ public class InterfaceExtensionImpl impl .findFirst().orElse(null); } - private static String[] paramStrings(NodeList<Parameter> params) { - return params.stream().map(Parameter::getTypeAsString).toArray(String[]::new); + + private static String[] paramStrings(List<ResolvedTypeParameterDeclaration> params) { + return params.stream().map(ResolvedTypeParameterDeclaration::getClassName).toArray(String[]::new); + } + + private static String[] paramStrings(NodeList<?> params) { + return params.stream().map(p -> { + if (p instanceof Parameter) { + return ((Parameter)p).getTypeAsString(); + } else if (p instanceof TypeParameter) { + return ((TypeParameter)p).getNameAsString(); + } else { + return "unknown"; + } + }).toArray(String[]::new); } private static String[] exceptionStrings(MethodDeclaration method) { return method.getThrownExceptions().stream().map(ReferenceType::asString).toArray(String[]::new); } + private static boolean matchParams(MethodUsage mIf, MethodDeclaration mDel) { + // the delegate needs to have the XmlObject as first parameter + List<ResolvedType> pIf = mIf.getParamTypes(); + NodeList<Parameter> pDel = mDel.getParameters(); + if (pDel.size() != pIf.size()+1) { + return false; + } + + if (!XmlObject.class.getName().equals(pDel.get(0).resolve().describeType())) { + return false; + } + + // the other parameters need to match + int idx = 1; + for (ResolvedType rt : pIf) { + if (!rt.describe().equals(pDel.get(idx++).resolve().describeType())) { + return false; + } + } + return true; + } + private static boolean parameterMatches(String[] params1, String[] params2) { // compare all parameters type strings // a type string can be a simple name (e.g. "XmlObject") or @@ -228,6 +312,7 @@ public class InterfaceExtensionImpl impl private final String _name; private final String _return; private final String[] _params; + private final String[] _paramNames; private final String[] _exceptions; MethodSignatureImpl(String intfName, MethodDeclaration method) { @@ -241,11 +326,13 @@ public class InterfaceExtensionImpl impl _name = method.getName().asString(); _return = replaceInner(method.getTypeAsString()); - _params = method.getParameters().stream().map(Parameter::getTypeAsString). + _params = method.getParameters().stream().map(p -> p.getType().resolve().describe()). map(MethodSignatureImpl::replaceInner).toArray(String[]::new); _exceptions = method.getThrownExceptions().stream().map(ReferenceType::asString). map(MethodSignatureImpl::replaceInner).toArray(String[]::new); + + _paramNames = method.getParameters().stream().map(p -> p.getNameAsString()).toArray(String[]::new); } private static String replaceInner(String classname) { @@ -268,6 +355,10 @@ public class InterfaceExtensionImpl impl return _params; } + public String[] getParameterNames() { + return _paramNames; + } + public String[] getExceptionTypes() { return _exceptions; } Modified: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/Parser.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/Parser.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/Parser.java (original) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/config/Parser.java Mon Dec 27 20:28:38 2021 @@ -16,51 +16,97 @@ package org.apache.xmlbeans.impl.config; import com.github.javaparser.ParseResult; +import com.github.javaparser.ParserConfiguration; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; -import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.symbolsolver.JavaSymbolSolver; +import com.github.javaparser.symbolsolver.resolution.typesolvers.ClassLoaderTypeSolver; +import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver; +import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; +import com.github.javaparser.utils.ProjectRoot; import com.github.javaparser.utils.SourceRoot; import java.io.File; import java.io.IOException; -import java.util.function.Predicate; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Stream; -class Parser { - final File[] javaFiles; - final File[] classpath; +import static com.github.javaparser.ParserConfiguration.LanguageLevel.BLEEDING_EDGE; +class Parser { + private final File[] javaFiles; + private final File[] classpath; + private final ParserConfiguration pc; + private final ProjectRoot projectRoot; + private final CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver(); public Parser(File[] javaFiles, File[] classpath) { this.javaFiles = (javaFiles != null) ? javaFiles.clone() : new File[0]; this.classpath = (classpath != null) ? classpath.clone() : new File[0]; + + pc = new ParserConfiguration(); + pc.setLanguageLevel(BLEEDING_EDGE); + + URL[] urls = Stream.of(this.classpath).map(Parser::fileToURL).filter(Objects::nonNull).toArray(URL[]::new); + combinedTypeSolver.add(new ClassLoaderTypeSolver(new URLClassLoader(urls, getClass().getClassLoader()))); + combinedTypeSolver.add(new ReflectionTypeSolver()); + + JavaSymbolSolver symbolSolver = new JavaSymbolSolver(combinedTypeSolver); + pc.setSymbolResolver(symbolSolver); + + if (this.javaFiles.length > 0) { + ChildSolverCollectionStrategy solver = new ChildSolverCollectionStrategy(pc, combinedTypeSolver); + + Stream.of(this.javaFiles) + .map(f -> f.isDirectory() ? f : f.getParentFile()) + .map(File::toPath) + .distinct() + .forEach(solver::collect); + + projectRoot = solver.collectAll(); + } else { + projectRoot = null; + } } public ClassOrInterfaceDeclaration loadSource(String className) { final String fileName = className.replace('.','/') +".java"; - for (File f : javaFiles) { - final String filePath = f.getPath(); - if (filePath.replace('\\','/').endsWith(fileName)) { - // remove filename from path - don't use replace because of different path separator - final String rootPath = filePath.substring(0, filePath.length()-fileName.length()); - final String startPackage = className.indexOf('.') == -1 ? "" : className.substring(0, className.lastIndexOf('.')); - final String simpleName = startPackage.isEmpty() ? className : className.substring(startPackage.length()+1); - SourceRoot sourceRoot = new SourceRoot(new File(rootPath).toPath()); - try { - ParseResult<CompilationUnit> pcu = sourceRoot.tryToParse(startPackage, simpleName+".java"); - ClassOrInterfaceDeclaration cls = pcu.getResult().flatMap(cu -> cu.getTypes().stream() - .filter(matchType(className)) - .map(t -> (ClassOrInterfaceDeclaration) t).findFirst()).orElse(null); - return cls; - } catch (IOException e) { - return null; - } - } + if (projectRoot == null) { + // TODO: check if this is called, when no sources are specified +// ParseResult<CompilationUnit> blub = new JavaParser(pc).parse(fileName); +// boolean suc = blub.isSuccessful(); + return null; + } else { + return projectRoot.getSourceRoots().stream().map(sr -> parseOrNull(sr, fileName)) + .filter(Objects::nonNull) + .filter(ParseResult::isSuccessful) + .map(ParseResult::getResult) + .map(Optional::get) + .flatMap(cu -> cu.getTypes().stream()) + .filter(ClassOrInterfaceDeclaration.class::isInstance) + .filter(t -> className.equals(t.getFullyQualifiedName().orElse(null))) + .map(ClassOrInterfaceDeclaration.class::cast) + .findFirst().orElse(null); } - return null; } - private static Predicate<TypeDeclaration<?>> matchType(String className) { - return (t) -> t instanceof ClassOrInterfaceDeclaration && - t.getFullyQualifiedName().map(fqn -> fqn.equals(className)).orElse(false); + private static URL fileToURL(File file) { + try { + return file.toURI().toURL(); + } catch (MalformedURLException ignored) { + return null; + } + } + + private ParseResult<CompilationUnit> parseOrNull(SourceRoot sr, String fileName) { + try { + return sr.tryToParse("", fileName, pc); + } catch (IOException ignroed) { + return null; + } } } Modified: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java (original) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java Mon Dec 27 20:28:38 2021 @@ -145,6 +145,7 @@ public final class SchemaTypeCodePrinter emit(""); emit("import javax.xml.namespace.QName;"); emit("import org.apache.xmlbeans.QNameSet;"); + emit("import org.apache.xmlbeans.XmlObject;"); emit(""); printInnerTypeImpl(sType, sType.getTypeSystem(), false); } @@ -2352,12 +2353,15 @@ public final class SchemaTypeCodePrinter decl.append("public ").append(method.getReturnType()); decl.append(" ").append(method.getName()).append("("); + // first parameter is always XmlObject, i.e. which is "this" and therefore doesn't need + // to be in the method declaration of the type implementation String[] paramTypes = method.getParameterTypes(); - for (int i = 0; i < paramTypes.length; i++) { - if (i != 0) { + String[] paramNames = method.getParameterNames(); + for (int i = 1; i < paramTypes.length; i++) { + if (i > 1) { decl.append(", "); } - decl.append(paramTypes[i]).append(" p").append(i); + decl.append(paramTypes[i]).append(" ").append(paramNames[i]); } decl.append(")"); @@ -2382,8 +2386,9 @@ public final class SchemaTypeCodePrinter impl.append(handler).append(".").append(method.getName()).append("(this"); String[] params = method.getParameterTypes(); - for (int i = 0; i < params.length; i++) { - impl.append(", p").append(i); + String[] paramsNames = method.getParameterNames(); + for (int i = 1; i < params.length; i++) { + impl.append(", ").append(paramsNames[i]); } impl.append(");"); Modified: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java (original) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java Mon Dec 27 20:28:38 2021 @@ -319,6 +319,11 @@ public final class DomImpl { private static String validatePrefix( String prefix, String uri, String local, boolean isAttr) { + + if (prefix != null && prefix.contains(":")) { + throw new NamespaceErr("Invalid prefix - contains ':' character"); + } + validateNcName(prefix); if (prefix == null) { Modified: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/Saver.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/Saver.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/Saver.java (original) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/store/Saver.java Mon Dec 27 20:28:38 2021 @@ -538,7 +538,7 @@ abstract class Saver { } private void addNewFrameMapping(String prefix, String uri, boolean ensureDefaultEmpty) { - // If the prefix maps to "", this don't include this mapping 'cause it's not well formed. + // If the prefix maps to "", then don't include this mapping 'cause it's not well formed. // Also, if we want to make sure that the default namespace is always "", then check that // here as well. @@ -942,9 +942,22 @@ abstract class Saver { } private void emitNamespacesHelper() { + LinkedHashMap<String, String> nsMap = new LinkedHashMap<>(); for (iterateMappings(); hasMapping(); nextMapping()) { + String prefix = mappingPrefix(); + String uri = mappingUri(); + if (nsMap.containsKey(prefix)) { + //only overwrite the nsMap entry for the prefix if the stored entry has prefix="" and uri="" + if (prefix.length() == 0 && nsMap.get(prefix).length() == 0) { + nsMap.put(prefix, uri); + } + } else { + nsMap.put(prefix, uri); + } + } + for (Map.Entry<String, String> nsEntry : nsMap.entrySet()) { emit(' '); - emitXmlns(mappingPrefix(), mappingUri()); + emitXmlns(nsEntry.getKey(), nsEntry.getValue()); } } Modified: xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java (original) +++ xmlbeans/branches/gradle-build/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java Mon Dec 27 20:28:38 2021 @@ -571,16 +571,16 @@ public class SchemaCompiler { XmlObject[] types = wsdldoc.getDefinitions().getTypesArray(); int count = 0; for (XmlObject type : types) { - Schema[] schemas = (Schema[]) type.selectPath("declare namespace xs=\"http://www.w3.org/2001/XMLSchema\" xs:schema"); + XmlObject[] schemas = type.selectPath("declare namespace xs=\"http://www.w3.org/2001/XMLSchema\" xs:schema"); if (schemas.length == 0) { StscState.addWarning(errorListener, "The WSDL " + name + " did not have any schema documents in namespace 'http://www.w3.org/2001/XMLSchema'", XmlErrorCodes.GENERIC_ERROR, wsdldoc); continue; } - for (Schema schema : schemas) { + for (XmlObject schema : schemas) { if (schema.validate(opts)) { count++; - scontentlist.add(schema); + scontentlist.add((Schema)schema); } } } Modified: xmlbeans/branches/gradle-build/src/main/java9/module-info.class URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/main/java9/module-info.class?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== Binary files - no diff available. Modified: xmlbeans/branches/gradle-build/src/test/java/common/Common.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/common/Common.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/common/Common.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/common/Common.java Mon Dec 27 20:28:38 2021 @@ -15,12 +15,13 @@ package common; import org.apache.xmlbeans.*; -import org.junit.Assert; import javax.xml.namespace.QName; import java.io.File; -import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; import static org.junit.Assert.assertNotNull; @@ -36,7 +37,7 @@ public class Common { public static String OUTPUTROOT = FWROOT + P + "build" + P + "test" + P + "output"; - public final LinkedList errorList = new LinkedList(); + public final List<XmlError> errorList = new LinkedList<>(); public final XmlOptions xmOpts = new XmlOptions(); public Common() { @@ -47,9 +48,6 @@ public class Common { * If System.property for 'xbean.rootdir' == null * use '.' as basePath * '.' should be where the build.xml file lives - * - * @return - * @throws IllegalStateException */ public static String getRootFile() throws IllegalStateException { String baseDir = System.getProperty("xbean.rootdir"); @@ -64,8 +62,6 @@ public class Common { * If System.property for 'cases.location' == null * use '.' as basePath and add src/test/resources. * should be where the build.xml file lives - * - * @throws IllegalStateException */ public static String getCaseLocation() throws IllegalStateException { String baseDir = System.getProperty("cases.location"); @@ -79,7 +75,6 @@ public class Common { /** * Gets a case file from under CASEROOT with location passed in as strPath * - * @param strPath * @return file Object for references location */ public static File xbeanCase(String strPath) { @@ -89,7 +84,6 @@ public class Common { /** * Creates directory under output directory as noted by strPath * - * @param strPath * @return File Object specified by strPath */ public static File xbeanOutput(String strPath) { @@ -101,15 +95,12 @@ public class Common { /** * Recursively deletes files under specified directory - * - * @param dir */ public static void deltree(File dir) { if (dir.exists()) { if (dir.isDirectory()) { - String[] list = dir.list(); - for (int i = 0; i < list.length; i++) { - deltree(new File(dir, list[i])); + for (String s : Objects.requireNonNull(dir.list())) { + deltree(new File(dir, s)); } } if (!dir.delete()) { @@ -120,30 +111,12 @@ public class Common { } /** - * Convenience method for displaying errorListener contents after validation - * - * @param errors - */ - public static void listErrors(List errors) { - for (int i = 0; i < errors.size(); i++) { - XmlError error = (XmlError) errors.get(i); - if (error.getSeverity() == XmlError.SEVERITY_ERROR) { - System.out.println(error.toString()); - } - } - } - - /** * check list of errors/warnings/msgs and print them. Return true if errors found - * - * @param errors - * @return */ - public static boolean printOptionErrMsgs(Collection errors) { + public static boolean printOptionErrMsgs(List<XmlError> errors) { boolean errFound = false; if (!errors.isEmpty()) { - for (Iterator i = errors.iterator(); i.hasNext(); ) { - XmlError eacherr = (XmlError) i.next(); + for (XmlError eacherr : errors) { int errSeverity = eacherr.getSeverity(); if (errSeverity == XmlError.SEVERITY_ERROR) { System.out.println("Err Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage()); @@ -161,11 +134,6 @@ public class Common { /** * Validate schemas to instance based on the docType - * - * @param schemas - * @param instances - * @param docType - * @throws Exception */ public static void validateInstance(String[] schemas, String[] instances, QName docType) throws Exception { SchemaTypeLoader stl = makeSchemaTypeLoader(schemas); @@ -173,13 +141,12 @@ public class Common { if (docType != null) { SchemaType docSchema = stl.findDocumentType(docType); - Assert.assertTrue(docSchema != null); + assertNotNull(docSchema); options.setDocumentType(docSchema); } for (int i = 0; i < instances.length; i++) { - XmlObject x = - stl.parse((String) instances[i], null, options); + XmlObject x = stl.parse(instances[i], null, options); //if (!startOnDocument) { // XmlCursor c = x.newCursor(); @@ -196,73 +163,20 @@ public class Common { if (!isValid) { StringBuilder errorTxt = new StringBuilder("Invalid doc, expected a valid doc: "); - errorTxt.append("Instance(" + i + "): "); + errorTxt.append("Instance(").append(i).append("): "); errorTxt.append(x.xmlText()); errorTxt.append("Errors: "); for (XmlError xmlError : xel) { - errorTxt.append(xmlError + "\n"); - } - System.err.println(errorTxt.toString()); - throw new Exception("Instance not valid\n" + errorTxt.toString()); - } - } - } - - - /** - * Convenience method for creating an XmlObject from a String - * - * @param XsdAsString - * @return - */ - public static XmlObject compileXsdString(String XsdAsString) { - XmlObject xobj = null; - try { - xobj = XmlObject.Factory.parse(XsdAsString); - } catch (XmlException xme) { - if (!xme.getErrors().isEmpty()) { - for (Iterator itr = xme.getErrors().iterator(); itr.hasNext(); ) { - System.out.println("Parse Errors :" + itr.next()); - } - } - } finally { - assertNotNull(xobj); - return xobj; - } - } - - - /** - * Convenience method for creating an XmlObject from a File referenced as a String of the path to the file - * - * @param XsdFilePath - * @return - */ - public static XmlObject compileXsdFile(String XsdFilePath) { - XmlObject xobj = null; - try { - xobj = XmlObject.Factory.parse(new File(XsdFilePath)); - } catch (XmlException xme) { - if (!xme.getErrors().isEmpty()) { - for (Iterator itr = xme.getErrors().iterator(); itr.hasNext(); ) { - System.out.println("Parse Errors :" + itr.next()); + errorTxt.append(xmlError).append("\n"); } + System.err.println(errorTxt); + throw new Exception("Instance not valid\n" + errorTxt); } - } catch (IOException ioe) { - ioe.printStackTrace(); - ioe.getMessage(); - } finally { - assertNotNull(xobj); - return xobj; } } /** * Convenience method to create a SchemaTypeLoader from a set of xsds - * - * @param schemas - * @return - * @throws Exception */ public static SchemaTypeLoader makeSchemaTypeLoader(String[] schemas) throws Exception { @@ -277,27 +191,16 @@ public class Common { } /** - * Is the JVM being used a 1.4 version? - * Used for tests involving the javasource=1.5 compilation setting - * - * @return true if java.version starts with 1.4 - */ - public static boolean isJDK14() { - return System.getProperty("java.version").startsWith("1.4"); - } - - /** * Convenience class for creating tests in a multithreaded env */ public static abstract class TestThread extends Thread { protected Throwable _throwable; protected boolean _result; protected XmlOptions xm; - protected ArrayList errors; + protected List<XmlError> errors = new ArrayList<>(); public TestThread() { xm = new XmlOptions(); - ArrayList errors = new ArrayList(); xm.setErrorListener(errors); xm.setValidateOnSet(); } Modified: xmlbeans/branches/gradle-build/src/test/java/compile/scomp/common/CompileTestBase.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/compile/scomp/common/CompileTestBase.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/compile/scomp/common/CompileTestBase.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/compile/scomp/common/CompileTestBase.java Mon Dec 27 20:28:38 2021 @@ -47,7 +47,7 @@ public class CompileTestBase extends Com public File out; public File outincr; public File sanity; - public List errors; + public List<XmlError> errors; public XmlOptions xm; //schemas to use Modified: xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java Mon Dec 27 20:28:38 2021 @@ -24,10 +24,7 @@ import org.junit.*; import javax.xml.namespace.QName; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; +import java.util.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; @@ -41,7 +38,7 @@ public class IncrCompilationTests extend sanity = CompileCommon.xbeanOutput(sanityPath); outincr = CompileCommon.xbeanOutput(incrPath); - errors = new ArrayList(); + errors = new ArrayList<>(); xm = new XmlOptions(); xm.setErrorListener(errors); xm.setSavePrettyPrint(); @@ -279,12 +276,12 @@ public class IncrCompilationTests extend base.saveToDirectory(out); // get timestamps for first compile - HashMap initialTimeStamps = new HashMap(); + Map<String,Long> initialTimeStamps = new HashMap<>(); recordTimeStamps(out, initialTimeStamps); // the incr compile - provide the same name for the STS as the initial compile // note: providing a null or different name results in regeneration of generated Interface java src files - HashMap recompileTimeStamps = new HashMap(); + Map<String,Long> recompileTimeStamps = new HashMap<>(); Filer filer2 = new FilerImpl(out, out, null, true, true); SchemaTypeSystem incr = XmlBeans.compileXmlBeans("teststs",base,schemas2,null,builtin,filer2,xm); Assert.assertNotNull("Compilation failed during Incremental Compile.", incr); @@ -293,10 +290,9 @@ public class IncrCompilationTests extend // compare generated source timestamps here assertEquals("Number of Files not equal for Incremental Schema Compilation using Filer",initialTimeStamps.size(), recompileTimeStamps.size()); - Set keyset = initialTimeStamps.keySet(); - for (Iterator iterator = keyset.iterator(); iterator.hasNext();) { - String eachFile = (String) iterator.next(); - assertEquals("Mismatch for File " + eachFile,initialTimeStamps.get(eachFile),recompileTimeStamps.get(eachFile)); + Set<String> keyset = initialTimeStamps.keySet(); + for (String eachFile : keyset) { + assertEquals("Mismatch for File " + eachFile, initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile)); } handleErrors(errors); @@ -322,11 +318,11 @@ public class IncrCompilationTests extend base.saveToDirectory(out); // get timestamps for first compile - HashMap initialTimeStamps = new HashMap(); + HashMap<String,Long> initialTimeStamps = new HashMap<>(); recordTimeStamps(out, initialTimeStamps); // the incr compile - HashMap recompileTimeStamps = new HashMap(); + Map<String,Long> recompileTimeStamps = new HashMap<>(); Filer filer2 = new FilerImpl(out, out, null, true, true); SchemaTypeSystem incr = XmlBeans.compileXmlBeans("test",base,schemas2,null,builtin,filer2,xm); Assert.assertNotNull("Compilation failed during Incremental Compile.", incr); @@ -335,31 +331,29 @@ public class IncrCompilationTests extend // compare generated source timestamps here assertEquals("Number of Files not equal for Incremental Schema Compilation using Filer",initialTimeStamps.size(), recompileTimeStamps.size()); - Set keyset = initialTimeStamps.keySet(); + Set<String> keyset = initialTimeStamps.keySet(); // Atype has been modified, BType has been removed String sep = System.getProperty("file.separator"); String modifiedFileName = out.getCanonicalFile() + sep + "org" + sep + "openuri" + sep + "impl" + sep + "ATypeImpl.java"; String modifiedFileName2 = out.getCanonicalFile() + sep + "org" + sep + "openuri" + sep + "AType.java"; - for (Iterator iterator = keyset.iterator(); iterator.hasNext();) { - String eachFile = (String) iterator.next(); - - if(eachFile.equalsIgnoreCase(modifiedFileName)){ - assertNotSame("File Should have been regenerated by Filer but has the same timestamp",initialTimeStamps.get(eachFile),recompileTimeStamps.get(eachFile)); + for (String eachFile : keyset) { + if (eachFile.equalsIgnoreCase(modifiedFileName)) { + assertNotSame("File Should have been regenerated by Filer but has the same timestamp", initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile)); continue; } - if(eachFile.equalsIgnoreCase(modifiedFileName2)){ - assertNotSame("File Should have been regenerated by Filer but has the same timestamp",initialTimeStamps.get(eachFile),recompileTimeStamps.get(eachFile)); + if (eachFile.equalsIgnoreCase(modifiedFileName2)) { + assertNotSame("File Should have been regenerated by Filer but has the same timestamp", initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile)); continue; } - assertEquals("Mismatch for File " + eachFile,initialTimeStamps.get(eachFile),recompileTimeStamps.get(eachFile)); + assertEquals("Mismatch for File " + eachFile, initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile)); } handleErrors(errors); } - public boolean recordTimeStamps(File inputDir, HashMap timeStampResults) throws Exception + public boolean recordTimeStamps(File inputDir, Map<String,Long> timeStampResults) throws Exception { if (timeStampResults == null){ return false; @@ -375,52 +369,51 @@ public class IncrCompilationTests extend return true; } - File[] child = inputDir.listFiles(); - for(int i=0;i<child.length;i++) - { + for (File file : Objects.requireNonNull(inputDir.listFiles())) { //System.out.println("Dir :"+ child[i].getCanonicalPath() + "\t:" + child[i].lastModified()); - if(child[i].getName().endsWith(".java")){ - timeStampResults.put(child[i].getCanonicalPath(),new Long(child[i].lastModified())); + if (file.getName().endsWith(".java")) { + timeStampResults.put(file.getCanonicalPath(), file.lastModified()); } - recordTimeStamps(child[i], timeStampResults); + recordTimeStamps(file, timeStampResults); } return true; } - private static String schemaFilesRegeneration_schema1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + - "<xs:schema " + - "attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " + - "targetNamespace=\"http://openuri.org\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + - "<xs:element name=\"TestElement\" type=\"bas:aType\" xmlns:bas=\"http://openuri.org\" />" + - "<xs:element name=\"NewTestElement\" type=\"bas:bType\" xmlns:bas=\"http://openuri.org\" />" + - "<xs:complexType name=\"aType\">" + - "<xs:simpleContent>" + - "<xs:extension base=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + - "<xs:attribute type=\"xs:string\" name=\"stringAttr\" />" + - "</xs:extension>" + - "</xs:simpleContent>" + - "</xs:complexType>" + - "<xs:complexType name=\"bType\">" + - "<xs:simpleContent>" + - "<xs:extension base=\"xs:integer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + - "</xs:extension>" + - "</xs:simpleContent>" + - "</xs:complexType>" + - "</xs:schema>"; - - private static String schemaFilesRegeneration_schema1_modified = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xs:schema " + - "attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " + - "targetNamespace=\"http://openuri.org\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + - "<xs:element name=\"TestElement\" type=\"bas:aType\" xmlns:bas=\"http://openuri.org\" />" + - "<xs:complexType name=\"aType\">" + - "<xs:simpleContent>" + - "<xs:extension base=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + - "<xs:attribute type=\"xs:token\" name=\"tokenAttr\" />" + - "</xs:extension>" + - "</xs:simpleContent>" + - "</xs:complexType>" + - "</xs:schema>"; - - + private static final String schemaFilesRegeneration_schema1 = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<xs:schema " + + "attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " + + "targetNamespace=\"http://openuri.org\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + + "<xs:element name=\"TestElement\" type=\"bas:aType\" xmlns:bas=\"http://openuri.org\" />" + + "<xs:element name=\"NewTestElement\" type=\"bas:bType\" xmlns:bas=\"http://openuri.org\" />" + + "<xs:complexType name=\"aType\">" + + "<xs:simpleContent>" + + "<xs:extension base=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + + "<xs:attribute type=\"xs:string\" name=\"stringAttr\" />" + + "</xs:extension>" + + "</xs:simpleContent>" + + "</xs:complexType>" + + "<xs:complexType name=\"bType\">" + + "<xs:simpleContent>" + + "<xs:extension base=\"xs:integer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + + "</xs:extension>" + + "</xs:simpleContent>" + + "</xs:complexType>" + + "</xs:schema>"; + + private static final String schemaFilesRegeneration_schema1_modified = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<xs:schema " + + "attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " + + "targetNamespace=\"http://openuri.org\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + + "<xs:element name=\"TestElement\" type=\"bas:aType\" xmlns:bas=\"http://openuri.org\" />" + + "<xs:complexType name=\"aType\">" + + "<xs:simpleContent>" + + "<xs:extension base=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" + + "<xs:attribute type=\"xs:token\" name=\"tokenAttr\" />" + + "</xs:extension>" + + "</xs:simpleContent>" + + "</xs:complexType>" + + "</xs:schema>"; } Modified: xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java Mon Dec 27 20:28:38 2021 @@ -31,7 +31,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import static org.junit.Assert.assertNotSame; @@ -49,7 +49,7 @@ public class ModelGroupTests extends Com sanity = CompileCommon.xbeanOutput(sanityPath); outincr = CompileCommon.xbeanOutput(incrPath); - errors = new ArrayList(); + errors = new ArrayList<>(); xm = new XmlOptions(); xm.setErrorListener(errors); xm.setSavePrettyPrint(); @@ -69,7 +69,7 @@ public class ModelGroupTests extends Com private XmlObject[] getSchema(File objFile, String schemaString) throws IOException, XmlException { FileOutputStream fos = new FileOutputStream(objFile); - OutputStreamWriter osw = new OutputStreamWriter(fos, Charset.forName("UTF-8")); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); if (!schemaString.startsWith("<?xml")) { osw.write(getSchemaTop("baz")); } Modified: xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java Mon Dec 27 20:28:38 2021 @@ -40,7 +40,7 @@ public class PerfTests extends CompileTe sanity = CompileCommon.xbeanOutput(sanityPath); outincr = CompileCommon.xbeanOutput(incrPath); - errors = new ArrayList(); + errors = new ArrayList<>(); xm = new XmlOptions(); xm.setErrorListener(errors); xm.setSavePrettyPrint(); Modified: xmlbeans/branches/gradle-build/src/test/java/misc/checkin/RichParserTests.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/misc/checkin/RichParserTests.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/misc/checkin/RichParserTests.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/misc/checkin/RichParserTests.java Mon Dec 27 20:28:38 2021 @@ -124,13 +124,13 @@ public class RichParserTests { else if ("double".equals(ln)) { double v = attIndex>-1 ? xs.getAttributeDoubleValue(attIndex) : xs.getDoubleValue(); - assertEquals("double expected: " + doubles[doublesIdx] + " actual: " + v, new Double(doubles[doublesIdx++]), new Double(v)); + assertEquals("double expected: " + doubles[doublesIdx] + " actual: " + v, doubles[doublesIdx++], v, 0.0); // makeing new Doubles because Double.NaN==Double.NaN is false; } else if ("float".equals(ln)) { float v = attIndex>-1 ? xs.getAttributeFloatValue(attIndex) : xs.getFloatValue(); - assertEquals("float expected: " + floats[floatsIdx] + " actual: " + v, new Float(floats[floatsIdx++]), new Float(v)); + assertEquals("float expected: " + floats[floatsIdx] + " actual: " + v, floats[floatsIdx++], v, 0.0f); // makeing new Floats because Float.NaN==Float.NaN is false; } else if ("decimal".equals(ln)) Modified: xmlbeans/branches/gradle-build/src/test/java/misc/detailed/JiraRegression50_100Test.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/misc/detailed/JiraRegression50_100Test.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/misc/detailed/JiraRegression50_100Test.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/misc/detailed/JiraRegression50_100Test.java Mon Dec 27 20:28:38 2021 @@ -25,7 +25,6 @@ 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; import org.junit.Ignore; import org.junit.Test; import org.w3c.dom.Document; @@ -68,7 +67,7 @@ public class JiraRegression50_100Test ex * [XMLBEANS-52] Validator loops when schema has certain conditions */ @Test - public void test_jira_XmlBeans52() throws Exception{ + public void test_jira_XmlBeans52() { //reusing code from method test_jira_XmlBeans48() String correctXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<!--Sample XML file generated by XMLSPY v5 rel. 4 U (http://www.xmlspy.com)--/> \n" + @@ -88,11 +87,11 @@ public class JiraRegression50_100Test ex * [XMLBEANS-54]: problem with default value */ @Test - public void test_jira_xmlbeans54() throws Exception { - List errors = new ArrayList(); + public void test_jira_xmlbeans54() { + List<XmlError> errors = new ArrayList<>(); Parameters params = new Parameters(); - params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_54.xsd_")}); + params.setXsdFiles(new File(scompTestFilesRoot + "xmlbeans_54.xsd_")); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); params.setClassesDir(schemaCompClassesDir); @@ -106,12 +105,7 @@ public class JiraRegression50_100Test ex try { SchemaCompiler.compile(params); } catch (OutOfMemoryError ome) { - System.out.println(ome.getStackTrace()); - System.out.println("test_jira_xmlbeans54() - out of Heap Memory"); - } - - if (printOptionErrMsgs(errors)) { - fail("test_jira_xmlbeans54() : Errors found when executing scomp"); + fail("test_jira_xmlbeans54() - out of Heap Memory"); } } @@ -137,20 +131,11 @@ public class JiraRegression50_100Test ex " </xb:extension>\n" + " <xb:qname name=\"ep:purchase-order\" javaname=\"purchaseOrderXXX\"/>\n" + "</xb:config> "; - ConfigDocument config = - ConfigDocument.Factory.parse(xsdConfig); + ConfigDocument config = ConfigDocument.Factory.parse(xsdConfig); xmOpts.setErrorListener(errorList); - if (config.validate(xmOpts)) { - System.out.println("Config Validated"); - return; - } else { - System.err.println("Config File did not validate"); - for (Iterator iterator = errorList.iterator(); iterator.hasNext();) { - System.out.println("Error: " + iterator.next()); - } - throw new Exception("Config File did not validate"); + if (!config.validate(xmOpts)) { + fail("Config File did not validate - Error: " + errorList); } - } /** @@ -167,22 +152,19 @@ public class JiraRegression50_100Test ex classDir.mkdirs(); Parameters params = new Parameters(); - params.setXsdFiles(new File[]{new File(JIRA_CASES + "xmlbeans_57.xml")}); + params.setXsdFiles(new File(JIRA_CASES + "xmlbeans_57.xml")); params.setErrorListener(errorList); params.setSrcDir(srcDir); params.setClassesDir(classDir); SchemaCompiler.compile(params); - Collection errs = params.getErrorListener(); + Collection<XmlError> errs = params.getErrorListener(); boolean outTextPresent = true; - if (errs.size() != 0) { - for (Iterator iterator = errs.iterator(); iterator.hasNext();) { - Object o = iterator.next(); - String out = o.toString(); - System.out.println("Dav: " + out); - if (out.startsWith("Compiled types to")) - outTextPresent = false; - } + for (XmlError o : errs) { + String out = o.toString(); + System.out.println("Dav: " + out); + if (out.startsWith("Compiled types to")) + outTextPresent = false; } //cleanup gen'd dirs @@ -204,13 +186,13 @@ public class JiraRegression50_100Test ex @Test @Ignore("the url doesn't exist anymore ...") public void test_jira_xmlbeans58() throws Exception { - List errors = new ArrayList(); + List<XmlError> errors = new ArrayList<>(); 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")}); // this seems to be a url for a WS-BrokeredNotification 1.0 wsdl - params.setUrlFiles(new URL[]{new URL("http://www.ibm.com/developerworks/library/specification/ws-notification/WS-BrokeredN.wsdl")}); + params.setUrlFiles(new URL("http://www.ibm.com/developerworks/library/specification/ws-notification/WS-BrokeredN.wsdl")); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); params.setClassesDir(schemaCompClassesDir); @@ -230,8 +212,7 @@ public class JiraRegression50_100Test ex @Test public void test_jira_XmlBeans62() throws Exception { String P = File.separator; - String outputDir = System.getProperty("xbean.rootdir") + P + "build" + - P + "test" + P + "output" + P + "x1999"; + String outputDir = "build" + P + "jiratest62"; File srcDir = new File(outputDir + P + "src"); srcDir.mkdirs(); @@ -239,18 +220,16 @@ public class JiraRegression50_100Test ex classDir.mkdirs(); Parameters params = new Parameters(); - params.setWsdlFiles(new File[]{new File(JIRA_CASES + "xmlbeans_62.xml")}); + params.setWsdlFiles(new File(JIRA_CASES + "xmlbeans_62.xml")); params.setErrorListener(errorList); params.setSrcDir(srcDir); params.setClassesDir(classDir); SchemaCompiler.compile(params); - Collection errs = params.getErrorListener(); + Collection<XmlError> errs = params.getErrorListener(); boolean warningPresent = false; - for (Iterator iterator = errs.iterator(); iterator.hasNext();) { - Object o = iterator.next(); + for (XmlError o : errs) { String out = o.toString(); - if (out.endsWith("did not have any schema documents in namespace 'http://www.w3.org/2001/XMLSchema'")) ; - warningPresent = true; + warningPresent |= out.endsWith("did not have any schema documents in namespace 'http://www.w3.org/2001/XMLSchema'"); } //cleanup gen'd dirs @@ -258,10 +237,7 @@ public class JiraRegression50_100Test ex classDir.deleteOnExit(); //validate error present - if (!warningPresent) - throw new Exception("Warning for 1999 schema was not found when compiling srcs"); - else - System.out.println("Warning Present, test Passed"); + assertTrue("Warning for 1999 schema was not found when compiling srcs", warningPresent); } /** @@ -275,7 +251,7 @@ public class JiraRegression50_100Test ex // validate XmlOptions validateOptions = new XmlOptions(); validateOptions.setLoadLineNumbers(); - ArrayList errorList = new ArrayList(); + List<XmlError> errorList = new ArrayList<>(); validateOptions.setErrorListener(errorList); boolean isValid = doc.validate(validateOptions); @@ -370,7 +346,7 @@ public class JiraRegression50_100Test ex else System.out.println("DOC-XML:\n" + doc.xmlText()); - errorList.removeAll(errorList); + errorList.clear(); xmOpts.setErrorListener(errorList); if (!baz.validate(xmOpts)) @@ -431,34 +407,26 @@ public class JiraRegression50_100Test ex if (doc2Props.getDoctypeName() == null || doc2Props.getDoctypeName().compareTo(docTypeName) != 0 || doc2Props.getDoctypeName().compareTo(docType.getName()) != 0) - compareText.append("docTypeName was not as " + - "expected in the document properties " + - doc2Props.getDoctypeName()+"\n"); + compareText.append("docTypeName was not as expected in the document properties ").append(doc2Props.getDoctypeName()).append("\n"); if (doc2Props.getDoctypePublicId() == null || doc2Props.getDoctypePublicId().compareTo(docTypePublicID) != 0 || doc2Props.getDoctypePublicId().compareTo(docType.getPublicId()) != 0) - compareText.append("docTypePublicID was not as " + - "expected in the document properties " + - doc2Props.getDoctypePublicId()+"\n"); + compareText.append("docTypePublicID was not as expected in the document properties ").append(doc2Props.getDoctypePublicId()).append("\n"); if (doc2Props.getDoctypeSystemId() == null || doc2Props.getDoctypeSystemId().compareTo(docTypeSystemID) != 0 || doc2Props.getDoctypeSystemId().compareTo(docType.getSystemId()) != 0) - compareText.append("docTypeSystemID was not as " + - "expected in the document properties "+ - doc2Props.getDoctypeSystemId()+"\n" ); + compareText.append("docTypeSystemID was not as expected in the document properties ").append(doc2Props.getDoctypeSystemId()).append("\n"); } else { compareText.append("Document Properties were null, should have been set"); } //cleanup - po2 = null; - po = null; new File(fileName).deleteOnExit(); if (compareText.toString().length() > 1) - throw new Exception("Doc properties were not saved or read correctly\n" + compareText.toString()); + throw new Exception("Doc properties were not saved or read correctly\n" + compareText); } /** @@ -468,18 +436,14 @@ public class JiraRegression50_100Test ex @Test public void test_jira_xmlbeans78() throws Exception { XMLInputFactory factory = XMLInputFactory.newInstance(); - FileInputStream fis = new FileInputStream(new File(JIRA_CASES+ "xmlbeans_78.xml")); + FileInputStream fis = new FileInputStream(JIRA_CASES + "xmlbeans_78.xml"); XMLStreamReader reader = factory.createXMLStreamReader(fis); skipToBody(reader); - XmlObject o = XmlObject.Factory.parse(reader); + XmlObject.Factory.parse(reader); } /** * Move reader to element of SOAP Body - * - * @param reader - * @throws javax.xml.stream.XMLStreamException - * */ private void skipToBody(XMLStreamReader reader) throws javax.xml.stream.XMLStreamException { while (true) { @@ -570,8 +534,8 @@ public class JiraRegression50_100Test ex Thread.sleep(6000); System.out.println("Done with XPaths?..."); - for (int i = 0; i < threads.length; i++) { - Assert.assertNull(threads[i].getException()); + for (XPathThread thread : threads) { + assertNull(thread.getException()); } } @@ -582,10 +546,10 @@ public class JiraRegression50_100Test ex @Ignore @Test public void test_jira_xmlbeans88() throws Exception { - List errors = new ArrayList(); + List<XmlError> errors = new ArrayList<>(); Parameters params = new Parameters(); - params.setUrlFiles(new URL[]{new URL("http://developer.ebay.com/webservices/latest/eBaySvc.wsdl")}); + params.setUrlFiles(new URL("http://developer.ebay.com/webservices/latest/eBaySvc.wsdl")); params.setErrorListener(errors); params.setSrcDir(schemaCompSrcDir); params.setClassesDir(schemaCompClassesDir); @@ -620,12 +584,13 @@ public class JiraRegression50_100Test ex @Test @Ignore public void test_jira_xmlbeans96() throws Exception { - StringBuilder xmlstringbuf = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); - xmlstringbuf.append("<test>"); - xmlstringbuf.append("<testchild attr=\"abcd\"> Jira02 </testchild>"); - xmlstringbuf.append("</test>"); + String xmlstringbuf = + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + + "<test>" + + "<testchild attr=\"abcd\"> Jira02 </testchild>" + + "</test>"; - XmlObject doc = XmlObject.Factory.parse(xmlstringbuf.toString()); + XmlObject doc = XmlObject.Factory.parse(xmlstringbuf); XmlDocumentProperties props = doc.documentProperties(); assertEquals("test_jira_xmlbeans96() : Xml Version is not picked up", "1.0", props.getVersion()); assertEquals("test_jira_xmlbeans96() : Xml Encoding is not picked up", "UTF-8", props.getEncoding()); @@ -649,7 +614,7 @@ public class JiraRegression50_100Test ex XmlOptions options = new XmlOptions(); // associate namespaces with prefixes - Map prefixes = new HashMap(); + Map<String,String> prefixes = new HashMap<>(); prefixes.put(structnamespace, "s"); prefixes.put(datanamespace, "d"); prefixes.put(xsinamespace, "v"); @@ -676,15 +641,16 @@ public class JiraRegression50_100Test ex doc.save(out, options); XmlObject xObj = XmlObject.Factory.parse(out); - String expXText = "<s:a-root v:schemaLocation=\"http://www.orthogony.net/xml/sample/structure xmlbeans_98.xsd\" xmlns:s=\"http://www.orthogony.net/xml/sample/structure\" xmlns:v=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + - " <s:a-child qualified-data=\"data:IAmQualified\" xmlns:data=\"http://www.orthogony.net/xml/sample/data\"/>\n" + - "</s:a-root>"; - XmlObject txtXObj = XmlObject.Factory.parse(doc.xmlText()); + String expXText = + "<s:a-root v:schemaLocation=\"http://www.orthogony.net/xml/sample/structure xmlbeans_98.xsd\" xmlns:s=\"http://www.orthogony.net/xml/sample/structure\" xmlns:v=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + + " <s:a-child qualified-data=\"data:IAmQualified\" xmlns:data=\"http://www.orthogony.net/xml/sample/data\"/>\n" + + "</s:a-root>"; + XmlObject.Factory.parse(doc.xmlText()); System.out.println("xObj: " + xObj.xmlText()); //NamedNodeMap n = xObj.getDomNode().getAttributes(); //Assert.assertTrue("Length was not as expected", n.getLength() == 3); Node no = xObj.getDomNode();//n.getNamedItem("a-root"); - Assert.assertTrue("Expected Prefix was not present: " + no.getPrefix(), no.getPrefix().compareTo("s") == 0); + assertEquals("Expected Prefix was not present: " + no.getPrefix(), 0, no.getPrefix().compareTo("s")); //Assert.assertTrue("s prefix was not found " + no.lookupPrefix(structnamespace), no.lookupPrefix(structnamespace).compareTo("s") == 0); //Assert.assertTrue("d prefix was not found " + no.lookupPrefix(datanamespace), no.lookupPrefix(datanamespace).compareTo("s") == 0); //Assert.assertTrue("v prefix was not found " + no.lookupPrefix(xsinamespace), no.lookupPrefix(xsinamespace).compareTo("s") == 0); @@ -715,7 +681,7 @@ public class JiraRegression50_100Test ex * refer to [XMLBEANS-14] */ @Test - public void test_jira_xmlbeans99_b() throws Exception { + public void test_jira_xmlbeans99_b() { StringBuilder xmlstringbuf = new StringBuilder("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?> \n"); xmlstringbuf.append(" <x:dummy xmlns:x=\"http://dufourrault\" xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:SchemaLocation=\"dummy.xsd\">\n"); xmlstringbuf.append(" <x:father>\n"); @@ -810,9 +776,9 @@ public class JiraRegression50_100Test ex "</statusreport>"; XmlObject path = XmlObject.Factory.parse(statusDoc, xm); XmlObject[] resSet = path.selectPath("//*:status"); - Assert.assertTrue(resSet.length + "", resSet.length == 4); + assertEquals(resSet.length + "", 4, resSet.length); resSet = path.selectPath("//*:status[@name='first']"); - Assert.assertTrue(resSet.length == 2); + assertEquals(2, resSet.length); } catch (Throwable t) { _throwable = t; @@ -835,9 +801,9 @@ public class JiraRegression50_100Test ex "</doc><!-- --> "; XmlObject path = XmlObject.Factory.parse(docDoc, xm); XmlObject[] resSet = path.selectPath("//a"); - Assert.assertTrue(resSet.length == 2); + assertEquals(2, resSet.length); resSet = path.selectPath("//b[@attr2]"); - Assert.assertTrue(resSet.length == 1); + assertEquals(1, resSet.length); } catch (Throwable t) { _throwable = t; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
