Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/TypeStore.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/TypeStore.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/TypeStore.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/TypeStore.java Fri Dec 31 00:01:16 2021 @@ -196,8 +196,8 @@ public interface TypeStore extends Names * it should be inserted adjacent to existing elements with * the same name. * - * Should throw an IndexOutOfBoundsException if i < 0 - * or if i > # of elts + * Should throw an IndexOutOfBoundsException if i < 0 + * or if i > # of elts */ TypeStoreUser insert_element_user(QName name, int i); @@ -219,8 +219,8 @@ public interface TypeStore extends Names /** * Removes the ith element with the given name. * - * Should throw an IndexOutOfBoundsException if i < 0 - * or if i > # of elts-1. + * Should throw an IndexOutOfBoundsException if i < 0 + * or if i > # of elts-1. */ void remove_element(QName name, int i); @@ -296,12 +296,12 @@ public interface TypeStore extends Names * If there are n current elements of the given name and m elements * in the source array, there are several cases for individual elements: * - * 1. If i < n and i < m, then the contents of the ith source are copied + * 1. If i < n and i < m, then the contents of the ith source are copied * underneath the ith element; the ith element is not moved, but its * TypeStoreUser is disconnected. - * 2. if i >= n and i < m, then first enough new elements are appended + * 2. if i >= n and i < m, then first enough new elements are appended * so that there is an element with the name i, then rule #1 is followed. - * 3. if i >= m and i < n, then the element #i and all its contents + * 3. if i >= m and i < n, then the element #i and all its contents * are removed. */
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java Fri Dec 31 00:01:16 2021 @@ -1323,6 +1323,7 @@ public abstract class XmlObjectBase impl if (wasNilled) { get_store().invalidate_nil(); } + _flags &= ~(FLAGS_DATED); } else { _textsource = null; } Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java Fri Dec 31 00:01:16 2021 @@ -67,24 +67,20 @@ public class SaxonXPath implements Path * Select all nodes that are selectable by this XPath * expression. If multiple nodes match, multiple nodes * will be returned. - * <p/> - * <p/> + * <p> * <b>NOTE:</b> In most cases, nodes will be returned * in document-order, as defined by the XML Canonicalization * specification. The exception occurs when using XPath - * expressions involving the <code>union</code> operator + * expressions involving the {@code union} operator * (denoted with the pipe '|' character). - * </p> - * <p/> - * <p/> + * <p> * <b>NOTE:</b> Param node must be a DOM node which will be used * during the xpath execution and iteration through the results. * A call of node.dispose() must be done after reading all results. - * </p> * * @param node The node, nodeset or Context object for evaluation. * This value can be null. - * @return The <code>List</code> of all items selected + * @return The {@code List} of all items selected * by this XPath expression. */ public List selectNodes(Object node) { @@ -135,15 +131,15 @@ public class SaxonXPath implements Path /** * According to the Saxon javadoc: - * <code>getUnderlyingNode</code> in <code>NodeWrapper</code> implements - * the method specified in the interface <code>VirtualNode</code>, and + * {@code getUnderlyingNode} in {@code NodeWrapper} implements + * the method specified in the interface {@code VirtualNode}, and * the specification of the latter says that it may return another - * <code>VirtualNode</code>, and you may have to drill down through + * {@code VirtualNode}, and you may have to drill down through * several layers of wrapping. * To be safe, this method is provided to drill down through multiple * layers of wrapping. * - * @param v The <code>VirtualNode</code> + * @param v The {@code VirtualNode} * @return The underlying node */ private static Node getUnderlyingNode(VirtualNode v) { Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpathgen/XPathGenerator.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpathgen/XPathGenerator.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpathgen/XPathGenerator.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpathgen/XPathGenerator.java Fri Dec 31 00:01:16 2021 @@ -18,8 +18,8 @@ package org.apache.xmlbeans.impl.xpathge import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor.TokenType; -import javax.xml.namespace.QName; import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; /** * Generates an XPath String that points to a given position in an XML document @@ -27,16 +27,16 @@ import javax.xml.namespace.NamespaceCont public class XPathGenerator { /** - * Generates an XPath pointing to the position in the document indicated by <code>node</code>. - * <p>If the <code>context</code> parameter is null, the XPath is absolute, otherwise the - * XPath will be relative to the position indicated by <code>context</code>.</p> - * <p>Note: the cursor position for the <code>node</code> parameter is not preserved</p> + * Generates an XPath pointing to the position in the document indicated by {@code node}. + * <p>If the {@code context} parameter is null, the XPath is absolute, otherwise the + * XPath will be relative to the position indicated by {@code context}.</p> + * <p>Note: the cursor position for the {@code node} parameter is not preserved</p> * @param node the position in the document that the generated path will point to * @param context the context node; the generated path will be relative to it if not null and if - * pointing to an element on the path from the document root to <code>node</code> + * pointing to an element on the path from the document root to {@code node} * @param nsctx a namespace context that will be used to obtain prefixes; a (non-default) * namespace mapping must be available for all required namespace URIs - * @return the generated path as a <code>String</code> + * @return the generated path as a {@code String} * @throws XPathGenerationException if the path could not be generated: the cursor is in a bad * position (like over a comment) or no prefix mapping was found for one of the namespace URIs */ @@ -138,9 +138,9 @@ public class XPathGenerator } /** - * Computes how many text nodes the + * Computes how many text nodes the * @param c the position in the document - * @return how many text nodes occur before the position determined by <code>c</code> + * @return how many text nodes occur before the position determined by {@code c} */ private static int countTextTokens(XmlCursor c) { Modified: xmlbeans/trunk/src/test/java/common/Common.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/common/Common.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/common/Common.java (original) +++ xmlbeans/trunk/src/test/java/common/Common.java Fri Dec 31 00:01:16 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/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=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java Fri Dec 31 00:01:16 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/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java Fri Dec 31 00:01:16 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/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java Fri Dec 31 00:01:16 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/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/incr/schemaCompile/detailed/PerfTests.java Fri Dec 31 00:01:16 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/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java Fri Dec 31 00:01:16 2021 @@ -34,15 +34,13 @@ import org.apache.xmlbeans.impl.tool.Dif import org.junit.Assert; import javax.xml.namespace.QName; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; +import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -72,7 +70,7 @@ public class SomTestBase extends Compile String logFileName = somOutputRootDir + P + "SOM_INSPECTION_RESULT_" + runid + ".txt"; File outfile = new File(logFileName); - try (PrintWriter out = new PrintWriter(new FileWriter(outfile, true))) { + try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outfile,true), UTF_8))) { out.println("\n Call to inspectPSOM .. .. .. .."); out.println("\n\n ======================================================="); Modified: xmlbeans/trunk/src/test/java/misc/checkin/RichParserTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/checkin/RichParserTests.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/checkin/RichParserTests.java (original) +++ xmlbeans/trunk/src/test/java/misc/checkin/RichParserTests.java Fri Dec 31 00:01:16 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/trunk/src/test/java/misc/detailed/ClassLoadingTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/ClassLoadingTest.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/ClassLoadingTest.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/ClassLoadingTest.java Fri Dec 31 00:01:16 2021 @@ -15,16 +15,17 @@ package misc.detailed; -import org.apache.xmlbeans.*; +import org.apache.xmlbeans.XmlError; +import org.apache.xmlbeans.XmlOptions; import org.junit.Ignore; import org.junit.Test; import java.io.File; -import java.util.ArrayList; -import java.util.Random; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Random; @Ignore("needs to be updated to current jars") public class ClassLoadingTest { @@ -35,13 +36,13 @@ public class ClassLoadingTest { private boolean _result; private Random rand; XmlOptions xm; - ArrayList errors; + ArrayList<XmlError> errors; public CompilationThread() { rand = new Random(); xm = new XmlOptions(); - ArrayList errors = new ArrayList(); + ArrayList<XmlError> errors = new ArrayList<>(); xm.setErrorListener(errors); xm.setValidateOnSet(); } @@ -72,19 +73,19 @@ public class ClassLoadingTest { File xbeanFile = new File(xbean_home + "/build/lib/xbean.jar"); if (!xbeanFile.exists()) throw new Exception("File does not exist"); - URL xbeanjar = xbeanFile.toURL(); + URL xbeanjar = xbeanFile.toURI().toURL(); File xmlpublicFile = new File(xbean_home + "/build/lib/xmlpublic.jar"); if (!xmlpublicFile.exists()) throw new Exception("File does not exist"); - URL xmlpublicjar = xmlpublicFile.toURL(); + URL xmlpublicjar = xmlpublicFile.toURI().toURL(); File jsr173File = new File(xbean_home + "/build/lib/jsr173.jar"); if (!jsr173File.exists()) throw new Exception("File does not exist"); - URL jsr173jar = new URL(jsr173File.toURL().toString()); + URL jsr173jar = new URL(jsr173File.toURI().toURL().toString()); File jsr173_apiFile = new File(xbean_home + "/build/lib/jsr173_1.0_api.jar"); if (!jsr173_apiFile.exists()) throw new Exception("File does not exist"); - URL jsr173_apijar = jsr173_apiFile.toURL(); + URL jsr173_apijar = jsr173_apiFile.toURI().toURL(); File jsr173_riFile = new File(xbean_home + "/build/lib/jsr173_1.0_ri.jar"); if (!jsr173_riFile.exists()) throw new Exception("File does not exist"); @@ -92,16 +93,16 @@ public class ClassLoadingTest { File junitFile = new File(xbean_home + "/external/lib/junit.jar"); if (!junitFile.exists()) throw new Exception("File does not exist"); - URL junitjar = junitFile.toURL(); + URL junitjar = junitFile.toURI().toURL(); File xmlcursorFile = new File(xbean_home + "/build/test/lib/schemajars/xmlcursor.jar"); if (!xmlcursorFile.exists()) throw new Exception("File does not exist"); - URL xmlcursorjar = xmlcursorFile.toURL(); + URL xmlcursorjar = xmlcursorFile.toURI().toURL(); File validatingFile = new File(xbean_home + "/build/test/lib/schemajars/ValidatingStream.jar"); if (!validatingFile.exists()) throw new Exception("File does not exist"); - URL validating = validatingFile.toURL(); + URL validating = validatingFile.toURI().toURL(); //URLClassLoader allLoader = new URLClassLoader(new URL[]{xbeanjar, xmlpublicjar, 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=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java Fri Dec 31 00:01:16 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; Modified: xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java Fri Dec 31 00:01:16 2021 @@ -22,6 +22,7 @@ import java.io.File; import java.io.FilenameFilter; import java.io.PrintStream; import java.util.ArrayList; +import java.util.List; /** * Date: Feb 8, 2005 @@ -29,86 +30,72 @@ import java.util.ArrayList; */ public class SampleRunner { - private ArrayList samples; - private Project proj; - private Target target; + private List<File> samples; private String XMLBEANS_HOME; private SamplesBuildFileTest runSampleTest; @Before - protected void setUp() throws Exception { - proj = new Project(); + public void setUp() throws Exception { + Project proj = new Project(); proj.setName("Samples Task Tests"); - XMLBEANS_HOME = proj.getBaseDir().getAbsolutePath(); - samples = new ArrayList(); + XMLBEANS_HOME = new File(proj.getBaseDir(), "build").getAbsolutePath(); + samples = new ArrayList<>(); runSampleTest = new SamplesBuildFileTest(); } @Test public void testSamples() throws Exception { loadSampleDirs(new File("./samples")); - ArrayList exceptions = new ArrayList(); - for (int i = 0; i < samples.size(); i++) - { - - runSampleTest.call_samples_task( - ((File) samples.get(i)).getAbsolutePath() - , "test"); + List<Object> exceptions = new ArrayList<>(); + for (File sample : samples) { + + runSampleTest.call_samples_task(sample.getAbsolutePath(), "test"); BuildException e; - if ((e = runSampleTest.getAnyExceptions()) != null) - { - exceptions.add(((File) samples.get(i)).getAbsolutePath()); - exceptions.add(e.getException()); + if ((e = runSampleTest.getAnyExceptions()) != null) { + exceptions.add(sample.getAbsolutePath()); + exceptions.add(e.getCause()); } } - if (exceptions.size() != 0) + if (exceptions.size() != 0) { throw new RuntimeException(getMessageFromExceptions(exceptions)); + } } - private String getMessageFromExceptions(ArrayList ex) - { + private String getMessageFromExceptions(List<Object> ex) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < ex.size(); i += 2) - { - sb.append("\n\nFILE:" + (String) ex.get(i)); - sb.append( - "\n **Error: " + ((BuildException) ex.get(i + 1)).getMessage()); + for (int i = 0; i < ex.size(); i += 2) { + sb.append("\n\nFILE:").append(ex.get(i)); + sb.append("\n **Error: ").append(((BuildException) ex.get(i + 1)).getMessage()); } return sb.toString(); } - private void loadSampleDirs(File dir) - { + private void loadSampleDirs(File dir) { assert dir != null && dir.exists(); File[] files = dir.listFiles(new BuildFilter()); - assert files.length == 1; + assert (files != null && files.length == 1); samples.add(files[0]); } - private class BuildFilter - implements FilenameFilter - { - public boolean accept(File file, String name) - { + private static class BuildFilter + implements FilenameFilter { + public boolean accept(File file, String name) { return name.equals("build.xml"); } } private class SamplesBuildFileTest extends BuildFileTest { - public void call_samples_task(String projectPath, String taskName) - { + public void call_samples_task(String projectPath, String taskName) { configureProject(projectPath); Project proj = getProject(); proj.setProperty("xmlbeans.home", XMLBEANS_HOME); executeTarget(proj.getDefaultTarget()); } - public BuildException getAnyExceptions() - throws Exception - { + public BuildException getAnyExceptions() { return this.getBuildException(); } } @@ -160,25 +147,26 @@ abstract class BuildFileTest { } /** - * set up to run the named project + * set up to run the named project * - * @param filename name of project file to run + * @param filename name of project file to run */ protected void configureProject(String filename) throws BuildException { logBuffer = new StringBuilder(); fullLogBuffer = new StringBuilder(); project = new Project(); project.init(); - project.setUserProperty( "ant.file" , new File(filename).getAbsolutePath() ); + project.setUserProperty("ant.file", new File(filename).getAbsolutePath()); project.addBuildListener(new BuildFileTest.AntTestListener()); //ProjectHelper.configureProject(project, new File(filename)); ProjectHelper.getProjectHelper().parse(project, new File(filename)); } /** - * execute a target we have set up - * @pre configureProject has been called - * @param targetName target to run + * execute a target we have set up. + * configureProject needs to be called before + * + * @param targetName target to run */ protected void executeTarget(String targetName) { PrintStream sysOut = System.out; @@ -220,7 +208,7 @@ abstract class BuildFileTest { */ private class AntOutputStream extends java.io.OutputStream { public void write(int b) { - outBuffer.append((char)b); + outBuffer.append((char) b); } } @@ -229,63 +217,63 @@ abstract class BuildFileTest { */ private class AntTestListener implements BuildListener { /** - * Fired before any targets are started. + * Fired before any targets are started. */ public void buildStarted(BuildEvent event) { } /** - * Fired after the last target has finished. This event - * will still be thrown if an error occured during the build. + * Fired after the last target has finished. This event + * will still be thrown if an error occured during the build. * - * @see BuildEvent#getException() + * @see BuildEvent#getException() */ public void buildFinished(BuildEvent event) { } /** - * Fired when a target is started. + * Fired when a target is started. * - * @see BuildEvent#getTarget() + * @see BuildEvent#getTarget() */ public void targetStarted(BuildEvent event) { //System.out.println("targetStarted " + event.getTarget().getName()); } /** - * Fired when a target has finished. This event will - * still be thrown if an error occured during the build. + * Fired when a target has finished. This event will + * still be thrown if an error occured during the build. * - * @see BuildEvent#getException() + * @see BuildEvent#getException() */ public void targetFinished(BuildEvent event) { //System.out.println("targetFinished " + event.getTarget().getName()); } /** - * Fired when a task is started. + * Fired when a task is started. * - * @see BuildEvent#getTask() + * @see BuildEvent#getTask() */ public void taskStarted(BuildEvent event) { //System.out.println("taskStarted " + event.getTask().getTaskName()); } /** - * Fired when a task has finished. This event will still - * be throw if an error occured during the build. + * Fired when a task has finished. This event will still + * be throw if an error occured during the build. * - * @see BuildEvent#getException() + * @see BuildEvent#getException() */ public void taskFinished(BuildEvent event) { //System.out.println("taskFinished " + event.getTask().getTaskName()); } /** - * Fired whenever a message is logged. + * Fired whenever a message is logged. * - * @see BuildEvent#getMessage() - * @see BuildEvent#getPriority() + * @see BuildEvent#getMessage() + * @see BuildEvent#getPriority() */ public void messageLogged(BuildEvent event) { if (event.getPriority() == Project.MSG_INFO || Modified: xmlbeans/trunk/src/test/java/misc/detailed/SystemCacheTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/SystemCacheTests.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/misc/detailed/SystemCacheTests.java (original) +++ xmlbeans/trunk/src/test/java/misc/detailed/SystemCacheTests.java Fri Dec 31 00:01:16 2021 @@ -17,6 +17,7 @@ package misc.detailed; import org.apache.xmlbeans.impl.common.SystemCache; +import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -24,7 +25,13 @@ import static org.junit.Assert.assertNul public class SystemCacheTests { @Test + @Ignore("invalid test") public void testSystemCacheImplFromAPITest() { + // Test ignored: + // this test is dangerous if we eventually execute tests in parallel and + // also the premise that the SystemCache instance is the default is wrong, + // as SchemaTypeLoaderImpl overrides the SystemCache + // store the default SystemCache implementation before switch SystemCache defaultImpl = SystemCache.get(); Modified: xmlbeans/trunk/src/test/java/random/common/Random.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/random/common/Random.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/random/common/Random.java (original) +++ xmlbeans/trunk/src/test/java/random/common/Random.java Fri Dec 31 00:01:16 2021 @@ -30,6 +30,8 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; public class Random implements Runnable { @@ -483,7 +485,7 @@ public class Random implements Runnable if (x instanceof PurchaseOrder) { PurchaseOrder o = (PurchaseOrder) x; - o.setDate(Calendar.getInstance()); + o.setDate(Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT)); } else if (x instanceof XmlCustomerBean) { XmlCustomerBean o = (XmlCustomerBean) x; o.setName("Bob"); Modified: xmlbeans/trunk/src/test/java/scomp/common/BaseCase.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/scomp/common/BaseCase.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/scomp/common/BaseCase.java (original) +++ xmlbeans/trunk/src/test/java/scomp/common/BaseCase.java Fri Dec 31 00:01:16 2021 @@ -21,33 +21,32 @@ import org.junit.Before; import java.util.ArrayList; public class BaseCase { - protected boolean bVerbose = true; + protected boolean bVerbose = false; protected XmlOptions validateOptions; - protected ArrayList errorList; + protected final ArrayList<XmlError> errorList = new ArrayList<>(); @Before public void setUp() { validateOptions = new XmlOptions(); - errorList = new ArrayList(); + errorList.clear(); validateOptions.setErrorListener(errorList); } protected void clearErrors() { //reset error list for next time - errorList = new ArrayList(); + errorList.clear(); validateOptions.setErrorListener(errorList); } public void showErrors() { if (bVerbose) - for (int i = 0; i < errorList.size(); i++) { - XmlError error = (XmlError) errorList.get(i); + for (XmlError error : errorList) { System.out.println("\n"); System.out.println("Message: " + error.getMessage() + "\n"); - if (error.getCursorLocation() != null) - System.out.println("Location of invalid XML: " + - error.getCursorLocation().xmlText() + "\n"); + if (error.getCursorLocation() != null) { + System.out.println("Location of invalid XML: " + error.getCursorLocation().xmlText() + "\n"); + } } } @@ -56,7 +55,7 @@ public class BaseCase { public boolean compareErrorCodes(String[] expected) { if ( errorList.size() != expected.length){ System.err.println(stringOfCodes(expected,errorList)); - + return false; } StringBuilder errMessage = new StringBuilder(); Modified: xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/ListType.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/ListType.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/ListType.java (original) +++ xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/ListType.java Fri Dec 31 00:01:16 2021 @@ -18,6 +18,8 @@ package scomp.contentType.simple.detaile import org.apache.xmlbeans.XmlErrorCodes; import org.apache.xmlbeans.XmlSimpleList; import org.apache.xmlbeans.impl.values.XmlValueNotSupportedException; +import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException; +import org.junit.Ignore; import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.contentType.list.*; @@ -33,8 +35,8 @@ public class ListType extends BaseCase { public void testListTypeAnonymous() throws Throwable { ListEltTokenDocument doc = ListEltTokenDocument.Factory.newInstance(); - assertEquals(null, doc.getListEltToken()); - List values = new LinkedList(); + assertNull(doc.getListEltToken()); + List<Object> values = new LinkedList<>(); values.add("lstsmall"); values.add("lstmedium"); doc.setListEltToken(values); @@ -45,7 +47,7 @@ public class ListType extends BaseCase { showErrors(); throw t; } - values.set(0, new Integer(4)); + values.set(0, 4); // since the list has enumerations, it contains a fixed number of Java constants in the xobj // which are checked for types and an exception is expected irrespective of validateOnSet XmlOption @@ -84,10 +86,10 @@ public class ListType extends BaseCase { //immutable list assertTrue(result instanceof XmlSimpleList); } - List arrayList = new ArrayList(); + List<String> arrayList = new ArrayList<>(); arrayList.add("foobar"); - List newList = new XmlSimpleList(arrayList); - gst.setListValue(newList); + List<String> newList = new XmlSimpleList<>(arrayList); + assertThrows(XmlValueOutOfRangeException.class, () -> gst.setListValue(newList)); doc.xsetListEltInt(gst); try { assertTrue(doc.validate(validateOptions)); @@ -98,7 +100,7 @@ public class ListType extends BaseCase { } } - @Test + @Ignore public void testListofLists() { //also,a list of union that contains a list is not OK fail("Compile Time eror"); @@ -111,11 +113,11 @@ public class ListType extends BaseCase { public void testListofUnions() throws Throwable { ListUnionDocument doc = ListUnionDocument.Factory.newInstance(); - List arrayList = new ArrayList(); + List<Object> arrayList = new ArrayList<>(); arrayList.add("small"); arrayList.add("large"); - arrayList.add(new Integer(-1)); - arrayList.add(new Integer(2)); + arrayList.add(-1); + arrayList.add(2); doc.setListUnion(arrayList); try { @@ -136,7 +138,7 @@ public class ListType extends BaseCase { "</ListUnion>"; ListUnionDocument doc = ListUnionDocument.Factory.parse(input); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$UNION @@ -150,11 +152,11 @@ public class ListType extends BaseCase { public void testListofUnions2() throws Throwable { ListUnion2Document doc = ListUnion2Document.Factory.newInstance(); - List arrayList = new ArrayList(); + List<Object> arrayList = new ArrayList<>(); arrayList.add("small"); arrayList.add("large"); - arrayList.add(new Integer(-1)); - arrayList.add(new Integer(2)); + arrayList.add(-1); + arrayList.add(2); arrayList.add("addVal1"); arrayList.add("addVal2"); arrayList.add("addVal3"); Modified: xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/UnionType.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/UnionType.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/UnionType.java (original) +++ xmlbeans/trunk/src/test/java/scomp/contentType/simple/detailed/UnionType.java Fri Dec 31 00:01:16 2021 @@ -64,7 +64,7 @@ public class UnionType extends BaseCase throw t; } doc.setUnionElt(5); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$UNION}; @@ -105,12 +105,10 @@ public class UnionType extends BaseCase "-2" + "</UnionElt>"; UnionEltDocument doc = UnionEltDocument.Factory.parse(input); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); - String[] errExpected = new String[]{ - XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID}; - assertTrue(compareErrorCodes(errExpected)); - + String[] errExpected = {XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID}; + assertTrue(compareErrorCodes(errExpected)); } /** @@ -170,7 +168,7 @@ public class UnionType extends BaseCase { doc.setUnionOfUnions("foobar"); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{"cvc-attribute"}; @@ -231,7 +229,7 @@ public class UnionType extends BaseCase @Test public void testUnionOfLists() throws Throwable { UnionOfListsDocument doc = UnionOfListsDocument.Factory.newInstance(); - List vals = new ArrayList(); + List<Object> vals = new ArrayList<>(); vals.add("small"); vals.add(-1); vals.add(-2); @@ -265,7 +263,7 @@ public class UnionType extends BaseCase //mixing and matching should not be allowed //the list shoudl have exactly one of the 2 union types vals.add("lstsmall"); - vals.add(new Integer(-1)); + vals.add(-1); // if the type in a union and cannot be converted into any of the union types, and in this case // since the list have enumerations, an exception is expected irrespective of validateOnSet XmlOption Modified: xmlbeans/trunk/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java (original) +++ xmlbeans/trunk/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java Fri Dec 31 00:01:16 2021 @@ -14,17 +14,17 @@ */ package scomp.derivation.restriction.detailed; -import org.junit.Test; -import xbean.scomp.derivation.elementRestriction.ElementDocument; -import xbean.scomp.derivation.elementRestriction.RestrictedEltT; +import org.apache.xmlbeans.XmlDecimal; +import org.apache.xmlbeans.XmlErrorCodes; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlString; -import org.apache.xmlbeans.XmlErrorCodes; -import org.apache.xmlbeans.XmlDecimal; +import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl; +import org.junit.Test; import scomp.common.BaseCase; +import xbean.scomp.derivation.elementRestriction.ElementDocument; +import xbean.scomp.derivation.elementRestriction.RestrictedEltT; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ElementRestriction extends BaseCase { @@ -65,12 +65,12 @@ public class ElementRestriction extends XmlDecimal dValue = XmlDecimal.Factory.newInstance(); dValue.setBigDecimalValue(new java.math.BigDecimal("3.5")); elt.setD(dValue); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$EXPECTED_DIFFERENT_ELEMENT, XmlErrorCodes.ELEM_LOCALLY_VALID$FIXED_VALID_MIXED_CONTENT, - XmlErrorCodes.DATATYPE_FRACTION_DIGITS_VALID, + XmlErrorCodes.INTEGER, }; assertTrue(compareErrorCodes(errExpected)); @@ -78,9 +78,9 @@ public class ElementRestriction extends elt.removeA(2); bValue.setStringValue("myval"); elt.setB(bValue); - elt.setD(new Integer(3)); + elt.setD(3); assertEquals("myval", - ((XmlString)elt.getB()).getStringValue()); + ((XmlAnyTypeImpl)elt.getB()).getStringValue()); try { assertTrue(doc.validate(validateOptions)); } Modified: xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java (original) +++ xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java Fri Dec 31 00:01:16 2021 @@ -22,8 +22,7 @@ import xbean.scomp.derivation.facets.lis import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** */ @@ -31,12 +30,12 @@ public class ListRestriction extends Bas @Test public void testLengthFacet() throws Throwable { LengthEltDocument doc = LengthEltDocument.Factory.newInstance(); - List vals = new ArrayList(); + List<String> vals = new ArrayList<>(); vals.add("lstsmall"); doc.setLengthElt(vals); //this should be too short - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH}; @@ -54,7 +53,7 @@ public class ListRestriction extends Bas vals.add("lstsmall"); doc.setLengthElt(vals); clearErrors(); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH @@ -91,7 +90,7 @@ public class ListRestriction extends Bas assertEquals("lstlarge", (String) doc.xgetMinLengthElt().getListValue().get(0)); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH @@ -108,14 +107,14 @@ public class ListRestriction extends Bas "lstsmall lstlarge lstsmall" + "</MaxLengthElt>"; MaxLengthEltDocument doc = MaxLengthEltDocument.Factory.parse(input); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH}; assertTrue(compareErrorCodes(errExpected)); MaxLengthFacet elt = MaxLengthFacet.Factory.newInstance(); - List vals = new ArrayList(); + List<String> vals = new ArrayList<>(); vals.add("lstsmall"); vals.add("lstsmall"); //why is there no xsetListValue method here? @@ -135,7 +134,7 @@ public class ListRestriction extends Bas @Test public void testEnum() throws Throwable { EnumEltDocument doc = EnumEltDocument.Factory.newInstance(); - List vals = new ArrayList(); + List<Object> vals = new ArrayList<>(); vals.add("small"); vals.add("medium"); vals.add("large"); @@ -147,9 +146,9 @@ public class ListRestriction extends Bas throw t; } vals.clear(); - vals.add(new Integer(2)); - vals.add(new Integer(3)); - vals.add(new Integer(1)); + vals.add(2); + vals.add(3); + vals.add(1); doc.setEnumElt(vals); try { assertTrue(doc.validate(validateOptions)); @@ -160,9 +159,9 @@ public class ListRestriction extends Bas vals.clear(); vals.add("small"); - vals.add(new Integer(10)); + vals.add(10); doc.setEnumElt(vals); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$UNION @@ -174,13 +173,13 @@ public class ListRestriction extends Bas @Test public void testPattern() throws Throwable { PatternEltDocument doc = PatternEltDocument.Factory.newInstance(); - List vals = new ArrayList(); - vals.add(new Integer(152)); - vals.add(new Integer(154)); - vals.add(new Integer(156)); - vals.add(new Integer(918)); + List<Integer> vals = new ArrayList<>(); + vals.add(152); + vals.add(154); + vals.add(156); + vals.add(918); - vals.add(new Integer(342)); + vals.add(342); doc.setPatternElt(vals); try { assertTrue(doc.validate(validateOptions)); Modified: xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java?rev=1896561&r1=1896560&r2=1896561&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java (original) +++ xmlbeans/trunk/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java Fri Dec 31 00:01:16 2021 @@ -15,14 +15,15 @@ package scomp.derivation.restriction.facets.detailed; +import org.apache.xmlbeans.XmlErrorCodes; import org.junit.Test; import scomp.common.BaseCase; -import xbean.scomp.derivation.facets.union.UnionPatternEltDocument; +import xbean.scomp.derivation.facets.union.SmallEnumUnion; import xbean.scomp.derivation.facets.union.SmallPatternUnion; import xbean.scomp.derivation.facets.union.UnionEnumEltDocument; -import xbean.scomp.derivation.facets.union.SmallEnumUnion; -import org.apache.xmlbeans.XmlErrorCodes; +import xbean.scomp.derivation.facets.union.UnionPatternEltDocument; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -42,7 +43,7 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionPatternElt(new Integer(1)); + doc.setUnionPatternElt(1); try { assertTrue(doc.validate(validateOptions)); } catch (Throwable t) { @@ -50,7 +51,7 @@ public class UnionRestriction extends Ba throw t; } SmallPatternUnion elt = SmallPatternUnion.Factory.newInstance(); - elt.setObjectValue(new Integer(2)); + elt.setObjectValue(2); doc.xsetUnionPatternElt(elt); try { assertTrue(doc.validate(validateOptions)); @@ -58,8 +59,8 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionPatternElt(new Integer(-1)); - assertTrue(!doc.validate(validateOptions)); + doc.setUnionPatternElt(-1); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID @@ -77,7 +78,7 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionEnumElt(new Integer(1)); + doc.setUnionEnumElt(1); try { assertTrue(doc.validate(validateOptions)); } catch (Throwable t) { @@ -85,7 +86,7 @@ public class UnionRestriction extends Ba throw t; } SmallEnumUnion elt = SmallEnumUnion.Factory.newInstance(); - elt.setObjectValue(new Integer(-1)); + elt.setObjectValue(-1); doc.xsetUnionEnumElt(elt); try { assertTrue(doc.validate(validateOptions)); @@ -93,8 +94,8 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionEnumElt(new Integer(2)); - assertTrue(!doc.validate(validateOptions)); + doc.setUnionEnumElt(2); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_ENUM_VALID --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
