Modified: xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java (original) +++ xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java Sun Feb 6 01:51:55 2022 @@ -18,10 +18,10 @@ package ValidatingXSRTests.detailed; import com.foo.sample.HeadingDocument; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.XmlBeans; +import org.apache.xmlbeans.XmlError; import org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.openuri.test.location.LocationDocument; import org.openuri.test.mixedContent.LetterDocument; import org.openuri.test.mixedContent.NoMixedDocument; @@ -42,8 +42,7 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.Collection; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; // Schema Imports @@ -63,131 +62,118 @@ public class ValidatingXmlStreamReaderTe // SO, any change to the xml files for these tests will not be // reflected till they make it into xmlcases.jar. (ant build.xmlcases) @Test - public void testDocWithNoSchema() throws Exception { + void testDocWithNoSchema() throws Exception { checkDocIsInvalid(getCasesFile(casesLoc + "po.xml"), null); } @Test - public void testValidLocationDoc() throws Exception { + void testValidLocationDoc() throws Exception { checkDocIsValid(getCasesFile(casesLoc + "location.xml"), null); } @Test - public void testInvalidLocationDoc() throws Exception { + void testInvalidLocationDoc() throws Exception { checkDocIsInvalid(getCasesFile(casesLoc + "location-inv.xml"), LocationDocument.type); } @Test - public void testValidPersonDoc() throws Exception { + void testValidPersonDoc() throws Exception { checkDocIsValid(getCasesFile(casesLoc + "person.xml"), PersonDocument.type); } @Test - public void testInvalidPersonDoc() throws Exception { + void testInvalidPersonDoc() throws Exception { checkDocIsInvalid(getCasesFile(casesLoc + "person-inv.xml"), PersonDocument.type); } @Test - public void testValidMixedContentDoc() throws Exception { - checkDocIsValid(getCasesFile(casesLoc + "mixed-content.xml"), - LetterDocument.type); + void testValidMixedContentDoc() throws Exception { + checkDocIsValid(getCasesFile(casesLoc + "mixed-content.xml"), LetterDocument.type); } @Test - public void testInvalidNomixedContentDoc() throws Exception { - checkDocIsInvalid(getCasesFile(casesLoc + "nomixed-content-inv.xml"), - NoMixedDocument.type); + void testInvalidNomixedContentDoc() throws Exception { + checkDocIsInvalid(getCasesFile(casesLoc + "nomixed-content-inv.xml"), NoMixedDocument.type); } @Test - public void testInvalidMissingAttributeDoc() throws Exception { - checkDocIsInvalid(getCasesFile(casesLoc + "foo-inv.xml"), - HeadingDocument.type); + void testInvalidMissingAttributeDoc() throws Exception { + checkDocIsInvalid(getCasesFile(casesLoc + "foo-inv.xml"), HeadingDocument.type); } @Test - public void testContentName() throws Exception { + void testContentName() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "person-frag.xml"); SchemaType type = Name.type; - assertTrue("Xml-fragment is not valid:\n" + sXml, - checkContent(sXml, type, true)); + assertTrue(checkContent(sXml, type, true), "Xml-fragment is not valid:\n" + sXml); } // Same as testContentName.. expect the xml has no chars before the first // start element @Test - public void testContentName2() throws Exception { + void testContentName2() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "person-frag2.xml"); SchemaType type = Name.type; - assertTrue("Xml-fragment is not valid:\n" + sXml, - checkContent(sXml, type, true)); + assertTrue(checkContent(sXml, type, true), "Xml-fragment is not valid:\n" + sXml); } @Test - public void testContentSibling() throws Exception { + void testContentSibling() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "person-sibling.xml"); SchemaType type = PersonType.type; - assertTrue("Xml-fragment is not valid:\n" + sXml, - checkContent(sXml, type, true)); + assertTrue(checkContent(sXml, type, true), "Xml-fragment is not valid:\n" + sXml); } @Test - public void testInvalidContentSibling() throws Exception { + void testInvalidContentSibling() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "person-sibling-inv.xml"); SchemaType type = PersonType.type; - assertTrue("Invalid Xml-fragment is getting validated:\n" + sXml, - !checkContent(sXml, type, true)); + assertFalse(checkContent(sXml, type, true), "Invalid Xml-fragment is getting validated:\n" + sXml); } @Test - public void testValidXsiType() throws Exception { + void testValidXsiType() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "person-justname.xml"); SchemaType type = Name.type; - assertTrue("Xml-fragment is not valid:\n" + sXml, - checkContent(sXml, type, true)); + assertTrue(checkContent(sXml, type, true), "Xml-fragment is not valid:\n" + sXml); } @Test - public void testInvalidXsiType() throws Exception { + void testInvalidXsiType() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "person-justname-inv.xml"); SchemaType type = Name.type; - assertTrue("Invalid Xml-fragment is getting validated:\n" + sXml, - !checkContent(sXml, type, true)); + assertFalse(checkContent(sXml, type, true), "Invalid Xml-fragment is getting validated:\n" + sXml); } @Test - public void testIncompatibleXsiType() throws Exception { + void testIncompatibleXsiType() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "person-xsi-inv.xml"); SchemaType type = Name.type; - assertTrue("Invalid Xml-fragment is getting validated:\n" + sXml, - !checkContent(sXml, type, true)); + assertFalse(checkContent(sXml, type, true), "Invalid Xml-fragment is getting validated:\n" + sXml); } @Test - public void testValidMixedContent() throws Exception { + void testValidMixedContent() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "mixed-content.xml"); SchemaType type = org.openuri.test.mixedContent.LetterType.type; - assertTrue("Xml-fragment is not valid:\n" + sXml, - checkContent(sXml, type, true)); + assertTrue(checkContent(sXml, type, true), "Xml-fragment is not valid:\n" + sXml); } @Test - @Ignore + @Disabled public void testGlobalAttribute() throws Exception { String sXml = JarUtil.getResourceFromJar(casesLoc + "global-attr.xml"); - - assertTrue("Global Attribute test failed:\n", - checkContent(sXml, null, true)); + assertTrue(checkContent(sXml, null, true), "Global Attribute test failed:\n"); } // Tests for increasing code-coverage metrics @Test - public void testValXsrReuse() throws Exception { - Collection errors = new ArrayList(); + void testValXsrReuse() throws Exception { + Collection<XmlError> errors = new ArrayList<>(); File[] xmls = new File[2]; xmls[0] = getCasesFile(casesLoc + "person.xml"); xmls[1] = getCasesFile(casesLoc + "person-inv.xml"); @@ -196,64 +182,23 @@ public class ValidatingXmlStreamReaderTe boolean[] ret = runValidator(xmls, type, errors); String common = "Test for ValidatingXmlStreamReader reuse failed"; - assertEquals(common + "\nReturn value has more than 2 elements", 2, ret.length); - assertTrue(common + "\nExpected: true & false. Actual: " - + ret[0] + " & " + ret[1], - ret[0] && !ret[1]); + assertEquals(2, ret.length, common + "\nReturn value has more than 2 elements"); + assertTrue(ret[0] && !ret[1], common + "\nExpected: true & false. Actual: " + ret[0] + " & " + ret[1]); } - public void testIllegalEvent() throws Exception { - // Will require writing another XSR wrapper.. albeit simple - } - - /*/ - public void testWalk() throws Exception { - walkXml(getCasesFile(casesLoc + "global-attr.xml")); - System.out.println(); - walkXml(getCasesFile(casesLoc + "person-sibling.xml")); - } - // */ - ////////////////////////////////////////////////////////////////////// - // Utility Methods - private void walkXml(File xml) throws Exception { - XMLStreamReader xr = XMLInputFactory.newInstance(). - createXMLStreamReader(new FileInputStream(xml)); - - //xsr.nextTag(); - XmlContentTestXSR xsr = new XmlContentTestXSR(xr); - - while(xsr.hasNext()) - { - int type = xsr.next(); - System.out.print(type); - //* - if (type == XMLEvent.START_ELEMENT) - { - System.out.print("\n" + xsr.getLocalName() + " "); - } - if (type == XMLEvent.END_ELEMENT) - { - System.out.println("/" + xsr.getLocalName()); - } - if (type == XMLEvent.CHARACTERS) - { - char[] arr = xsr.getTextCharacters(); - String str = new String(arr); - System.out.print("Char:" + str + " "); - } - //*/ - } - } + // public void testIllegalEvent() throws Exception { + // Will require writing another XSR wrapper.. albeit simple + // } private boolean runValidator(File xml, SchemaType type, - Collection errors) - throws IllegalArgumentException, Exception - { - if (errors == null) + Collection<XmlError> errors) + throws IllegalArgumentException, Exception { + if (errors == null) { throw new IllegalArgumentException( "Collection object cannot be null"); + } XMLStreamReader xsr = XMLInputFactory.newInstance(). createXMLStreamReader(new FileInputStream(xml)); @@ -267,8 +212,9 @@ public class ValidatingXmlStreamReaderTe errors); // Walk through the xml - while (valXsr.hasNext()) + while (valXsr.hasNext()) { valXsr.next(); + } return valXsr.isValid(); //return true; @@ -278,17 +224,16 @@ public class ValidatingXmlStreamReaderTe // but could come in handy later.. private boolean[] runValidator(File[] xml, SchemaType type, - Collection errors) - throws IllegalArgumentException, Exception - { - if (errors == null) + Collection<XmlError> errors) + throws IllegalArgumentException, Exception { + if (errors == null) { throw new IllegalArgumentException( "Collection object cannot be null"); + } ValidatingXMLStreamReader valXsr = new ValidatingXMLStreamReader(); boolean[] retArray = new boolean[xml.length]; - for (int i = 0; i < xml.length; i++) - { + for (int i = 0; i < xml.length; i++) { XMLStreamReader xsr = XMLInputFactory.newInstance(). createXMLStreamReader(new FileInputStream(xml[i])); @@ -300,8 +245,9 @@ public class ValidatingXmlStreamReaderTe errors); // Walk through the xml - while (valXsr.hasNext()) + while (valXsr.hasNext()) { valXsr.next(); + } retArray[i] = valXsr.isValid(); } @@ -310,20 +256,18 @@ public class ValidatingXmlStreamReaderTe } protected void checkDocIsValid(File file, SchemaType type) throws Exception { - Collection errors = new ArrayList(); + Collection<XmlError> errors = new ArrayList<>(); boolean isValid = runValidator(file, type, errors); - tools.xml.Utils.printXMLErrors(errors); - Assert.assertTrue("File '" + file.getName() + "' is invalid.", isValid); + assertTrue(isValid, "File '" + file.getName() + "' is invalid."); } protected void checkDocIsInvalid(File file, SchemaType type) throws Exception { - Collection errors = new ArrayList(); + Collection<XmlError> errors = new ArrayList<>(); boolean isValid = runValidator(file, type, errors); - assertTrue("File '" + file.getName() + "' is valid, but was expecting invalid.", - !isValid); + assertFalse(isValid, "File '" + file.getName() + "' is valid, but was expecting invalid."); } @@ -334,7 +278,7 @@ public class ValidatingXmlStreamReaderTe createXMLStreamReader(new StringReader(fragment)); XmlContentTestXSR cxsr = new XmlContentTestXSR(xsr); - Collection errors = new ArrayList(); + Collection<XmlError> errors = new ArrayList<>(); ValidatingXMLStreamReader valXsr = new ValidatingXMLStreamReader(); valXsr.init(cxsr, @@ -345,24 +289,19 @@ public class ValidatingXmlStreamReaderTe errors); // Walk through the xml - while (valXsr.hasNext()) + while (valXsr.hasNext()) { valXsr.next(); - - if (!valXsr.isValid()) - { - if (printErrors) - tools.xml.Utils.printXMLErrors(errors); - return false; } - return true; + + return valXsr.isValid(); } private static File getCasesFile(String path) - throws java.io.IOException - { - if (path.length()==0) + throws java.io.IOException { + if (path.length() == 0) { throw new IOException("getCasesFile was called with path of len 0"); + } return JarUtil.getResourceFromJarasFile(path); //return new File(casesRoot + path); } @@ -370,14 +309,11 @@ public class ValidatingXmlStreamReaderTe ///////////////////////////////////////////////////////////////////////// // XmlStreamReader extension for content Validation // will not work for Global Attribute - public class XmlContentTestXSR - extends StreamReaderDelegate - implements XMLStreamReader - { - private static final int TAGOPEN = 100; - private static final int TAGCLOSE = 101; - private static final int UNDEFINED = 99; - private static final int ATTRIBUTE = 102; + private static class XmlContentTestXSR extends StreamReaderDelegate implements XMLStreamReader { + private static final int TAGOPEN = 100; + private static final int TAGCLOSE = 101; + private static final int UNDEFINED = 99; + private static final int ATTRIBUTE = 102; private static final int ENDCONTENT = 103; int state = -1; @@ -388,54 +324,51 @@ public class ValidatingXmlStreamReaderTe // Constructor Wrappers public XmlContentTestXSR(XMLStreamReader xsr) - throws XMLStreamException - { + throws XMLStreamException { super(xsr); } - public boolean hasNext() - { - if (state == UNDEFINED || state == ENDCONTENT) + public boolean hasNext() { + if (state == UNDEFINED || state == ENDCONTENT) { return false; + } if (!initialized) // next() has not been called yet + { return true; - + } return true; } public int next() - throws XMLStreamException - { + throws XMLStreamException { int _next; - if (!initialized) - { + if (!initialized) { // First time next() is called.. // Scan for the first XMLEvent.START_ELEMENT _next = UNDEFINED; - while ((super.hasNext()) && (_next != XMLEvent.START_ELEMENT)) + while ((super.hasNext()) && (_next != XMLEvent.START_ELEMENT)) { _next = super.next(); + } - if (_next != XMLEvent.START_ELEMENT) + if (_next != XMLEvent.START_ELEMENT) { throw new XMLStreamException( "Could not find a start element"); + } initialized = true; // Now move past the first tag state = TAGOPEN; depth = 1; - if ((attributeCount = super.getAttributeCount()) > 0) - { + if ((attributeCount = super.getAttributeCount()) > 0) { // The first element has attributes.. this is part of // the content. So the first event should XMLEvent.ATTRIBUTE _next = XMLEvent.ATTRIBUTE; - } - else - { + } else { // return super.next(); /* If content is <xml-fragment/> then we will have returned @@ -444,8 +377,7 @@ public class ValidatingXmlStreamReaderTe END_DOCUMENT */ _next = super.next(); - if (_next == XMLEvent.END_ELEMENT) - { + if (_next == XMLEvent.END_ELEMENT) { _next = XMLEvent.END_DOCUMENT; state = ENDCONTENT; } @@ -454,8 +386,7 @@ public class ValidatingXmlStreamReaderTe } _next = super.next(); - switch (_next) - { + switch (_next) { case XMLEvent.START_ELEMENT: state = TAGOPEN; depth++; @@ -463,13 +394,10 @@ public class ValidatingXmlStreamReaderTe case XMLEvent.END_ELEMENT: --depth; - if (depth < 0 && state == TAGOPEN) - { + if (depth < 0 && state == TAGOPEN) { throw new XMLStreamException( "Illegal XML Stream state"); - } - else if (depth == 0 && state == TAGOPEN) - { + } else if (depth == 0 && state == TAGOPEN) { state = ENDCONTENT; // at this point we will return ENDDOCUMENT _next = XMLEvent.END_DOCUMENT;
Modified: xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatorUtilTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatorUtilTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatorUtilTests.java (original) +++ xmlbeans/trunk/src/test/java/ValidatingXSRTests/detailed/ValidatorUtilTests.java Sun Feb 6 01:51:55 2022 @@ -17,49 +17,36 @@ package ValidatingXSRTests.detailed; import ValidatingXSRTests.common.TestPrefixResolver; import org.apache.xmlbeans.SchemaType; +import org.apache.xmlbeans.XmlError; import org.apache.xmlbeans.impl.validator.ValidatorUtil; -import org.junit.Test; -import tools.xml.Utils; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collection; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ValidatorUtilTests { @Test - public void testValidQName() - throws Exception - { + void testValidQName() { String xml = "foo:foo"; TestPrefixResolver pRes = new TestPrefixResolver("foo", "http://openuri.org/test/My"); SchemaType type = org.openuri.test.simType.QNameType.type; - Collection errors = new ArrayList(); - boolean success = ValidatorUtil.validateSimpleType(type, xml, errors, pRes); - if (!success) - { - Utils.printXMLErrors(errors); - fail("testValidQName failed"); - } + Collection<XmlError> errors = new ArrayList<>(); + assertTrue(ValidatorUtil.validateSimpleType(type, xml, errors, pRes)); } @Test - public void testInvalidQName() { + void testInvalidQName() { String xml = "foo:bz"; TestPrefixResolver pRes = new TestPrefixResolver("foo", "http://openuri.org/test/My"); SchemaType type = org.openuri.test.simType.QNameType.type; - Collection errors = new ArrayList(); - boolean success = ValidatorUtil.validateSimpleType(type, xml, errors, pRes); - System.out.println("Expected Errors:"); - tools.xml.Utils.printXMLErrors(errors); - if (success) - fail("testInvalidQName failed: Invalid QName was validated"); + Collection<XmlError> errors = new ArrayList<>(); + assertFalse(ValidatorUtil.validateSimpleType(type, xml, errors, pRes)); } - - // TODO: add more simpleType tests... maybe create a generic test method - } Modified: xmlbeans/trunk/src/test/java/common/Common.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/common/Common.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/common/Common.java (original) +++ xmlbeans/trunk/src/test/java/common/Common.java Sun Feb 6 01:51:55 2022 @@ -23,7 +23,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Objects; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class Common { public static final String NEWLINE = System.getProperty("line.separator"); @@ -113,22 +113,9 @@ public class Common { /** * check list of errors/warnings/msgs and print them. Return true if errors found */ - public static boolean printOptionErrMsgs(List<XmlError> errors) { - boolean errFound = false; - if (!errors.isEmpty()) { - 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()); - errFound = true; - } else if (errSeverity == XmlError.SEVERITY_WARNING) { - System.out.println("Warning Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage()); - } else if (errSeverity == XmlError.SEVERITY_INFO) { - System.out.println("Info Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage()); - } - } - errors.clear(); - } + public static boolean hasSevereError(List<XmlError> errors) { + boolean errFound = errors.stream().anyMatch(e -> e.getSeverity() == XmlError.SEVERITY_ERROR); + errors.clear(); return errFound; } Modified: xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/checkin/CompilationTests.java Sun Feb 6 01:51:55 2022 @@ -22,19 +22,21 @@ import org.apache.xmlbeans.impl.tool.*; import org.apache.xmlbeans.impl.util.FilerImpl; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelComplexType; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.platform.launcher.Launcher; +import org.junit.platform.launcher.LauncherDiscoveryRequest; +import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; +import org.junit.platform.launcher.core.LauncherFactory; +import org.junit.platform.launcher.listeners.SummaryGeneratingListener; +import org.junit.platform.launcher.listeners.TestExecutionSummary; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; +import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -44,7 +46,9 @@ import java.util.stream.Stream; import static common.Common.SCOMP_CASE_ROOT; import static common.Common.getRootFile; import static java.util.Collections.singletonList; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; +import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClasspathRoots; @SuppressWarnings({"SpellCheckingInspection", "ResultOfMethodCallIgnored"}) @@ -133,7 +137,7 @@ public class CompilationTests { @Test - public void testJ2EE() { + void testJ2EE() { deltree(xbeanOutput("compile/scomp/j2ee")); // First, compile schema File srcdir = xbeanOutput("compile/scomp/j2ee/j2eeconfigxml/src"); @@ -159,12 +163,12 @@ public class CompilationTests { StringWriter message = new StringWriter(); if (!result) dumpErrors(errors, new PrintWriter(message)); - assertTrue("Build failed:" + message, result); - assertTrue("Cannot find " + outputjar, outputjar.exists()); + assertTrue(result, "Build failed:" + message); + assertTrue(outputjar.exists(), "Cannot find " + outputjar); } @Test - public void testIncrementalCompilation() throws IOException, XmlException { + void testIncrementalCompilation() throws IOException, XmlException { File[] files = new File[]{ xbeanCase("incr/incr1.xsd"), xbeanCase("incr/incr3.xsd"), @@ -188,7 +192,7 @@ public class CompilationTests { XmlOptions options = (new XmlOptions()).setErrorListener(errors); SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem(); system = XmlBeans.compileXsd(schemas, builtin, options); - Assert.assertNotNull("Compilation failed during inititial compile.", system); + assertNotNull(system, "Compilation failed during inititial compile."); System.out.println("-= Initial Compile =-"); for (int i = 0; i < system.globalTypes().length; i++) { @@ -208,7 +212,7 @@ public class CompilationTests { schemas1[0].documentProperties().setSourceName(url); errors.clear(); system = XmlBeans.compileXsd(system, schemas1, builtin, options); - Assert.assertNotNull("Compilation failed during incremental compile.", system); + assertNotNull(system, "Compilation failed during incremental compile."); SchemaCodeGenerator.saveTypeSystem(system, outincr, null, null, null); System.out.println("-= Incremental Compile =-"); for (int i = 0; i < system.globalTypes().length; i++) { @@ -224,7 +228,7 @@ public class CompilationTests { errors.clear(); schemas[n - 2] = schemas1[0]; system = XmlBeans.compileXsd(schemas, builtin, options); - Assert.assertNotNull("Compilation failed during reference compile.", system); + assertNotNull(system, "Compilation failed during reference compile."); Filer filer = new FilerImpl(out, null, null, false, false); system.save(filer); @@ -246,11 +250,11 @@ public class CompilationTests { List<XmlError> diffs = new ArrayList<>(); Diff.dirsAsTypeSystems(out, outincr, diffs); System.setProperty("xmlbeans.diff.diffIndex", oldPropValue == null ? "true" : oldPropValue); - assertEquals("Differences encountered", 0, diffs.size()); + assertEquals(0, diffs.size(), "Differences encountered"); } @Test - public void testSchemaBookmarks() throws XmlException, IOException { + void testSchemaBookmarks() throws XmlException, IOException { File srcSchema = xbeanCase("../../simple/person/person.xsd"); // Parse SchemaDocument.Schema parsed = SchemaDocument.Factory.parse(srcSchema).getSchema(); @@ -263,7 +267,7 @@ public class CompilationTests { found = true; break; } - assertTrue("Could not find the \"person\" complex type", found); + assertTrue(found, "Could not find the \"person\" complex type"); // Set the bookmark try (XmlCursor c = cTypes[i].newCursor()) { SchemaBookmark sb = new SchemaBookmark("MyBookmark"); @@ -272,17 +276,17 @@ public class CompilationTests { // Compile it into STS SchemaTypeSystem sts = XmlBeans.compileXsd(new XmlObject[]{parsed}, XmlBeans.getBuiltinTypeSystem(), null); - Assert.assertNotNull("Could not compile person.xsd", sts); + assertNotNull(sts, "Could not compile person.xsd"); SchemaType personType = sts.findType(QNameHelper.forLNS("person", "http://openuri.org/mytest")); - Assert.assertNotNull("Could not find the \"person\" schema type", personType); + assertNotNull(personType, "Could not find the \"person\" schema type"); // Check that the bookmark made it through Object val = personType.getUserData(); - Assert.assertNotNull("Schema user data not found!", val); - Assert.assertEquals("MyBookmark", val); + assertNotNull(val, "Schema user data not found!"); + assertEquals("MyBookmark", val); } @Test - public void testSimple() throws MalformedURLException, ClassNotFoundException { + void testSimple() throws MalformedURLException, ClassNotFoundException, URISyntaxException { deltree(xbeanOutput("compile/scomp/simple")); // First, compile schema @@ -300,24 +304,35 @@ public class CompilationTests { params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - assertTrue("Build failed", SchemaCompiler.compile(params)); + assertTrue(SchemaCompiler.compile(params), "Build failed"); // Then, compile java classes - File javasrc = new File(SCOMP_CASE_ROOT + "/simple"); + File javasrc = new File("src/test/java/scomp/simple"); File javaclasses = xbeanOutput("compile/scomp/simple/javaclasses"); javaclasses.mkdirs(); File[] testcp = Stream.concat(Stream.of(CodeGenUtil.systemClasspath()), Stream.of(outputjar)).toArray(File[]::new); CodeGenUtil.externalCompile(singletonList(javasrc), javaclasses, testcp, true); // Then run the test - URLClassLoader childcl = new URLClassLoader(new URL[]{outputjar.toURI().toURL()}, CompilationTests.class.getClassLoader()); - Class<?> cl = childcl.loadClass("scomp.simple.SimplePersonTest"); - Result result = JUnitCore.runClasses(cl); - assertEquals(0, result.getFailureCount()); + final LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors( + selectClass("scomp.simple.SimplePersonTest"), + selectClasspathRoots(Collections.singleton(outputjar.toPath())).get(0) + ) + .build(); + + final Launcher launcher = LauncherFactory.create(); + final SummaryGeneratingListener listener = new SummaryGeneratingListener(); + + launcher.registerTestExecutionListeners(listener); + launcher.execute(request); + + TestExecutionSummary summary = listener.getSummary(); + assertEquals(1, summary.getTestsSucceededCount()); + assertEquals(0, summary.getTestsFailedCount()); } @Test - @Ignore + @Disabled public void testDownload() { deltree(xbeanOutput("compile/scomp/include")); @@ -331,8 +346,8 @@ public class CompilationTests { params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - assertFalse("Build should have failed", SchemaCompiler.compile(params)); - assertFalse("Should not have created " + outputjar, outputjar.exists()); + assertFalse(SchemaCompiler.compile(params), "Build should have failed"); + assertFalse(outputjar.exists(), "Should not have created " + outputjar); } { @@ -346,13 +361,13 @@ public class CompilationTests { params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - assertTrue("Build failed", SchemaCompiler.compile(params)); - assertTrue("Cannout find " + outputjar, outputjar.exists()); + assertTrue(SchemaCompiler.compile(params), "Build failed"); + assertTrue(outputjar.exists(), "Cannout find " + outputjar); } } @Test - public void testPricequote() { + void testPricequote() { deltree(xbeanOutput("compile/scomp/pricequote")); // First, compile schema File srcdir = xbeanOutput("compile/scomp/pricequote/src"); @@ -363,23 +378,23 @@ public class CompilationTests { params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - assertTrue("Build failed " + fwroot, SchemaCompiler.compile(params)); - assertTrue("Cannout find " + outputjar, outputjar.exists()); + assertTrue(SchemaCompiler.compile(params), "Build failed " + fwroot); + assertTrue(outputjar.exists(), "Cannout find " + outputjar); } @Test - public void testInvalid() throws XmlException { + void testInvalid() throws XmlException { for (String schemaFile : invalidSchemas) { // Parse the invalid schema files SchemaDocument schema = SchemaDocument.Factory.parse(schemaFile); // Now compile the invalid schemas, test that they fail - assertThrows("Schema should have failed to compile:\n" + schemaFile, XmlException.class, - () -> XmlBeans.loadXsd(schema)); + assertThrows(XmlException.class, () -> XmlBeans.loadXsd(schema), + "Schema should have failed to compile:\n" + schemaFile); } } @Test - public void testValid() throws XmlException { + void testValid() throws XmlException { for (String schemaFile : validSchemas) { // Parse the valid schema files SchemaDocument schema = SchemaDocument.Factory.parse(schemaFile); @@ -390,7 +405,7 @@ public class CompilationTests { } @Test - public void partials() throws InterruptedException, IOException { + void partials() throws InterruptedException, IOException { String[] files = {"partials/RootDocument.java", "partials/impl/RootDocumentImpl.java"}; String[] templ = new String[files.length]; for (int i=0; i<files.length; i++) { @@ -428,13 +443,13 @@ public class CompilationTests { exp = exp.replaceAll("(?m)^.*<[^>]+_ELSE>(?s).+?</[^>]+_ELSE>$\\n", ""); // remove unused markers exp = exp.replaceAll("(?m)^.*//.*<.*>$\\n", ""); - assertEquals(files[i] + " - " + removeMethod + " failed", exp, act); + assertEquals(exp, act, files[i] + " - " + removeMethod + " failed"); } } } @Test - public void annotation2javadoc() throws Exception { + void annotation2javadoc() throws Exception { deltree(xbeanOutput("compile/scomp/javadoc")); File srcdir = xbeanOutput("compile/scomp/javadoc/src"); File classesdir = xbeanOutput("compile/scomp/javadoc/classes"); Modified: xmlbeans/trunk/src/test/java/compile/scomp/checkin/XmlBeansCompCheckinTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/checkin/XmlBeansCompCheckinTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/checkin/XmlBeansCompCheckinTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/checkin/XmlBeansCompCheckinTests.java Sun Feb 6 01:51:55 2022 @@ -18,8 +18,9 @@ import compile.scomp.common.mockobj.Test import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl; import org.hamcrest.MatcherAssert; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.ArrayList; @@ -30,7 +31,7 @@ import static common.Common.OUTPUTROOT; import static compile.scomp.common.CompileTestBase.ERR_XSD; import static compile.scomp.common.CompileTestBase.FOR_XSD; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class XmlBeansCompCheckinTests { private final List<XmlError> xm_errors = new ArrayList<>(); @@ -63,22 +64,22 @@ public class XmlBeansCompCheckinTests { xm_opts.setSavePrettyPrint(); } - @After + @AfterEach public void tearDown() throws Exception { if (xm_errors.size() > 0) xm_errors.clear(); } @Test - public void test_Filer_compilation() throws Exception { + void test_Filer_compilation() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(FOR_XSD); XmlObject[] schemas = new XmlObject[]{obj1}; TestFiler f = new TestFiler(); XmlBeans.compileXmlBeans("apiCompile", null, schemas, null, XmlBeans.getBuiltinTypeSystem(), f, xm_opts); - assertTrue("Binary File method not invoked", f.isCreateBinaryFile()); - assertTrue("Source File method not invoked", f.isCreateSourceFile()); + assertTrue(f.isCreateBinaryFile(), "Binary File method not invoked"); + assertTrue(f.isCreateSourceFile(), "Source File method not invoked"); assertNotNull(f.getBinFileVec()); MatcherAssert.assertThat(f.getBinFileVec(), is(expBinType)); @@ -91,7 +92,7 @@ public class XmlBeansCompCheckinTests { * Verify Partial SOM cannot be saved to file system */ @Test - public void test_sts_noSave() throws Exception + void test_sts_noSave() throws Exception { XmlObject obj3 = XmlObject.Factory.parse(ERR_XSD); XmlObject[] schemas3 = new XmlObject[]{obj3}; @@ -132,7 +133,7 @@ public class XmlBeansCompCheckinTests { throw e; } - assertTrue("Expected partial schema type system", ((SchemaTypeSystemImpl)sts).isIncomplete()); + assertTrue(((SchemaTypeSystemImpl)sts).isIncomplete(), "Expected partial schema type system"); // Check using saveToDirectory on Partial SOM @@ -142,30 +143,30 @@ public class XmlBeansCompCheckinTests { tempDir = new File(OUTPUTROOT, "psom_save"); tempDir.mkdirs(); tempDir.deleteOnExit(); - assertEquals("Output Directory Init needed to be empty", 0, tempDir.listFiles().length); + assertEquals(0, tempDir.listFiles().length, "Output Directory Init needed to be empty"); //This should not Work sts.saveToDirectory(tempDir); - fail("Expected IllegalStateException"); + Assertions.fail("Expected IllegalStateException"); } catch (IllegalStateException e) { // ok System.out.println("sts.saveToDirectory() threw IllegalStateException as expected"); } //make sure nothing was written - assertEquals("Partial SOM output dir needed to be empty", 0, tempDir.listFiles().length); + assertEquals(0, tempDir.listFiles().length, "Partial SOM output dir needed to be empty"); // Check using save(Filer) on Partial SOM TestFiler tf1 = new TestFiler(); assertThrows(IllegalStateException.class, () -> sts.save(tf1)); //make sure nothing was written - assertEquals("Filer -Bin- Partial SOM output dir needed to be empty", 0, tf1.getBinFileVec().size()); - assertEquals("Filer -SRC- Partial SOM output dir needed to be empty", 0, tf1.getSrcFileVec().size()); + assertEquals(0, tf1.getBinFileVec().size(), "Filer -Bin- Partial SOM output dir needed to be empty"); + assertEquals(0, tf1.getSrcFileVec().size(), "Filer -SRC- Partial SOM output dir needed to be empty"); - assertFalse("Filer Create Source File method should not have been invoked", tf1.isCreateSourceFile()); + assertFalse(tf1.isCreateSourceFile(), "Filer Create Source File method should not have been invoked"); - assertFalse("Filer Create Binary File method should not have been invoked", tf1.isCreateBinaryFile()); + assertFalse(tf1.isCreateBinaryFile(), "Filer Create Binary File method should not have been invoked"); // Check using filer in partial SOM compilation TestFiler tf2 = new TestFiler(); @@ -176,14 +177,14 @@ public class XmlBeansCompCheckinTests { //filer methods on partial SOM should not be returned XmlBeans.compileXmlBeans(null, null, schemas3, null, XmlBeans.getBuiltinTypeSystem(), tf2, opt); - assertFalse("Errors was not empty", err.isEmpty()); + assertFalse(err.isEmpty(), "Errors was not empty"); //make sure nothing was written - assertEquals("Filer -Bin- Partial SOM output dir needed to be empty", 0, tf2.getBinFileVec().size()); - assertEquals("Filer -SRC- Partial SOM output dir needed to be empty", 0, tf2.getSrcFileVec().size()); + assertEquals(0, tf2.getBinFileVec().size(), "Filer -Bin- Partial SOM output dir needed to be empty"); + assertEquals(0, tf2.getSrcFileVec().size(), "Filer -SRC- Partial SOM output dir needed to be empty"); - assertFalse("Filer Create Source File method should not have been invoked", tf2.isCreateSourceFile()); + assertFalse(tf2.isCreateSourceFile(), "Filer Create Source File method should not have been invoked"); - assertFalse("Filer Create Binary File method should not have been invoked", tf2.isCreateBinaryFile()); + assertFalse(tf2.isCreateBinaryFile(), "Filer Create Binary File method should not have been invoked"); } /** @@ -191,7 +192,7 @@ public class XmlBeansCompCheckinTests { * different configs with null values */ @Test - public void test_entrypoint_nullVals() throws Exception { + void test_entrypoint_nullVals() throws Exception { XmlObject[] schemas = {XmlObject.Factory.parse(FOR_XSD)}; XmlBeans.compileXmlBeans(null, null, schemas, null, XmlBeans.getBuiltinTypeSystem(), null, null); 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=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/common/CompileTestBase.java Sun Feb 6 01:51:55 2022 @@ -27,7 +27,7 @@ import java.util.List; import java.util.Objects; import java.util.stream.Stream; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * TODO: modify for deprecation warnings @@ -134,7 +134,7 @@ public class CompileTestBase extends Com throws XmlException, IOException { SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem(); SchemaTypeSystem sts = XmlBeans.compileXsd(system, schemas, builtin, options); - assertNotNull("Compilation failed during Incremental Compile.", sts); + assertNotNull(sts, "Compilation failed during Incremental Compile."); SchemaCodeGenerator.saveTypeSystem(sts, outDir, null, null, null); return sts; @@ -146,7 +146,7 @@ public class CompileTestBase extends Com SchemaTypeSystem system; SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem(); system = XmlBeans.compileXsd(schemas, builtin, options); - assertNotNull("Compilation failed during compile.", system); + assertNotNull(system, "Compilation failed during compile."); SchemaCodeGenerator.saveTypeSystem(system, outDir, null, null, null); return system; } @@ -162,8 +162,8 @@ public class CompileTestBase extends Com } public static void findElementbyQName(SchemaTypeSystem sts, QName[] lookup) { - assertTrue("Element was expected but not found", - Stream.of(lookup).map(sts::findElement).allMatch(Objects::nonNull)); + assertTrue(Stream.of(lookup).map(sts::findElement).allMatch(Objects::nonNull), + "Element was expected but not found"); } public static String getSchemaTop(String tns) { Modified: xmlbeans/trunk/src/test/java/compile/scomp/detailed/DetailedCompTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/detailed/DetailedCompTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/detailed/DetailedCompTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/detailed/DetailedCompTests.java Sun Feb 6 01:51:55 2022 @@ -17,7 +17,7 @@ package compile.scomp.detailed; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.xml.namespace.QName; import java.io.File; @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.Iterator; import static common.Common.SCOMP_CASE_ROOT; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DetailedCompTests { @@ -36,7 +36,7 @@ public class DetailedCompTests { * @throws Exception */ @Test - public void testLaxDocProcessing() throws Exception { + void testLaxDocProcessing() throws Exception { QName q = new QName("urn:lax.Doc.Compilation", "ItemRequest"); ArrayList err = new ArrayList(); XmlOptions xm_opt = new XmlOptions().setErrorListener(err); @@ -52,7 +52,7 @@ public class DetailedCompTests { try{ SchemaTypeSystem sts = XmlBeans.compileXmlBeans(null, null, schemas, null, XmlBeans.getBuiltinTypeSystem(), null, xm_opt); - assertNotNull("STS was null", sts); + assertNotNull(sts, "STS was null"); }catch(XmlException xmlEx){ valDocEx = true; System.err.println("Expected Error: "+xmlEx.getMessage()); @@ -146,7 +146,7 @@ public class DetailedCompTests { * This tests usage of the xs:NOTATION type */ @Test - public void testNotation() throws Exception + void testNotation() throws Exception { String schema; String xml; @@ -164,9 +164,8 @@ public class DetailedCompTests { parsedSchema[0] = SchemaDocument.Factory.parse(schema); errors.clear(); XmlBeans.compileXsd(parsedSchema, null, opts); - assertTrue("Expected error: NOTATION type cannot be used directly", errors.size() == 1); - assertEquals("Expected error: NOTATION type cannot be used directly", - XmlErrorCodes.ATTR_NOTATION_TYPE_FORBIDDEN, ((XmlError)errors.get(0)).getErrorCode()); + assertTrue(errors.size() == 1, "Expected error: NOTATION type cannot be used directly"); + assertEquals(XmlErrorCodes.ATTR_NOTATION_TYPE_FORBIDDEN, ((XmlError)errors.get(0)).getErrorCode(), "Expected error: NOTATION type cannot be used directly"); assertEquals(XmlError.SEVERITY_ERROR, ((XmlError)errors.get(0)).getSeverity()); // 2. Negative test - Error if xs:NOTATION restricted without enumeration @@ -175,9 +174,8 @@ public class DetailedCompTests { parsedSchema[0] = SchemaDocument.Factory.parse(schema); errors.clear(); XmlBeans.compileXsd(parsedSchema, null, opts); - assertTrue("Expected error: restriction of NOTATION must use enumeration facet", errors.size() == 1); - assertEquals("Expected error: restriction of NOTATION must use enumeration facet", - XmlErrorCodes.DATATYPE_ENUM_NOTATION, ((XmlError)errors.get(0)).getErrorCode()); + assertTrue(errors.size() == 1, "Expected error: restriction of NOTATION must use enumeration facet"); + assertEquals(XmlErrorCodes.DATATYPE_ENUM_NOTATION, ((XmlError)errors.get(0)).getErrorCode(), "Expected error: restriction of NOTATION must use enumeration facet"); assertEquals(XmlError.SEVERITY_ERROR, ((XmlError)errors.get(0)).getSeverity()); // 3. Warning if xs:NOTATION used as type of an element @@ -187,9 +185,8 @@ public class DetailedCompTests { parsedSchema[0] = SchemaDocument.Factory.parse(schema); errors.clear(); XmlBeans.compileXsd(parsedSchema, null, opts); - assertTrue("Expected warning: NOTATION-derived type should not be used on elements", errors.size() == 1); - assertEquals("Expected warning: NOTATION-derived type should not be used on elements", - XmlErrorCodes.ELEM_COMPATIBILITY_TYPE, ((XmlError)errors.get(0)).getErrorCode()); + assertTrue(errors.size() == 1, "Expected warning: NOTATION-derived type should not be used on elements"); + assertEquals(XmlErrorCodes.ELEM_COMPATIBILITY_TYPE, ((XmlError)errors.get(0)).getErrorCode(), "Expected warning: NOTATION-derived type should not be used on elements"); assertEquals(XmlError.SEVERITY_WARNING, ((XmlError)errors.get(0)).getSeverity()); // 4. Warning if xs:NOTATION is used in a Schema with target namespace @@ -199,9 +196,8 @@ public class DetailedCompTests { parsedSchema[0] = SchemaDocument.Factory.parse(schema); errors.clear(); XmlBeans.compileXsd(parsedSchema, null, opts); - assertTrue("Expected warning: NOTATION-derived type should not be used in a Schema with target namespace", errors.size() == 1); - assertEquals("Expected warning: NOTATION-derived type should not be used in a Schema with target namespace", - XmlErrorCodes.ATTR_COMPATIBILITY_TARGETNS, ((XmlError)errors.get(0)).getErrorCode()); + assertTrue(errors.size() == 1, "Expected warning: NOTATION-derived type should not be used in a Schema with target namespace"); + assertEquals(XmlErrorCodes.ATTR_COMPATIBILITY_TARGETNS, ((XmlError)errors.get(0)).getErrorCode(), "Expected warning: NOTATION-derived type should not be used in a Schema with target namespace"); assertEquals(XmlError.SEVERITY_WARNING, ((XmlError)errors.get(0)).getSeverity()); // 5. Warning - Deprecation of minLength, maxLength and length facets @@ -211,9 +207,8 @@ public class DetailedCompTests { parsedSchema[0] = SchemaDocument.Factory.parse(schema); errors.clear(); XmlBeans.compileXsd(parsedSchema, null, opts); - assertTrue("Expected warning: length facet cannot be used on a type derived from NOTATION", errors.size() == 1); - assertEquals("Expected warning: length facet cannot be used on a type derived from NOTATION", - XmlErrorCodes.FACETS_DEPRECATED_NOTATION, ((XmlError)errors.get(0)).getErrorCode()); + assertTrue(errors.size() == 1, "Expected warning: length facet cannot be used on a type derived from NOTATION"); + assertEquals(XmlErrorCodes.FACETS_DEPRECATED_NOTATION, ((XmlError)errors.get(0)).getErrorCode(), "Expected warning: length facet cannot be used on a type derived from NOTATION"); assertEquals(XmlError.SEVERITY_WARNING, ((XmlError)errors.get(0)).getSeverity()); // 6. Positive test - Test restriction via enumeration, then same as 2 @@ -222,7 +217,7 @@ public class DetailedCompTests { parsedSchema[0] = SchemaDocument.Factory.parse(schema); errors.clear(); typeSystem = XmlBeans.compileXsd(parsedSchema, null, opts); - assertTrue("Expected no errors or warnings", errors.size() == 0); + assertTrue(errors.size() == 0, "Expected no errors or warnings"); SchemaType docType = typeSystem.findDocumentType(new QName("", "root")); SchemaType type = docType.getElementProperty(new QName("", "root")).getType(). getAttributeProperty(new QName("", "att")).getType(); @@ -234,48 +229,46 @@ public class DetailedCompTests { // 7. Validation negative - Test error if QName has bad prefix xml = doc_begin + notation7 + doc_end; parsedDoc = loader.parse(xml, null, opts); - assertEquals("Did not find the root element in the Schema", docType, parsedDoc.schemaType()); + assertEquals(docType, parsedDoc.schemaType(), "Did not find the root element in the Schema"); errors.clear(); parsedDoc.validate(opts); // Both "prefix not found" and "pattern doesn't match" errors - assertTrue("Expected validation errors", errors.size() == 2); + assertTrue(errors.size() == 2, "Expected validation errors"); // Unfortunately, can't get the error code because it is logged via an intermediate exception - assertTrue("Expected prefix not found error", ((XmlError) errors.get(0)).getMessage(). - indexOf("Invalid QName") >= 0); + assertTrue(((XmlError) errors.get(0)).getMessage(). + indexOf("Invalid QName") >= 0, "Expected prefix not found error"); assertEquals(XmlError.SEVERITY_ERROR, ((XmlError) errors.get(0)).getSeverity()); // System.out.println(xml); // 8. Validation negative - Test error if QName has correct prefix but not in enumeration xml = doc_begin + notation8 + doc_end; parsedDoc = loader.parse(xml, null, opts); - assertEquals("Did not find the root element in the Schema", docType, parsedDoc.schemaType()); + assertEquals(docType, parsedDoc.schemaType(), "Did not find the root element in the Schema"); errors.clear(); parsedDoc.validate(opts); - assertTrue("Expected validation errors", errors.size() == 1); - assertEquals("Expected prefix not found error", XmlErrorCodes.DATATYPE_ENUM_VALID, - ((XmlError) errors.get(0)).getErrorCode()); + assertTrue(errors.size() == 1, "Expected validation errors"); + assertEquals(XmlErrorCodes.DATATYPE_ENUM_VALID, ((XmlError) errors.get(0)).getErrorCode(), "Expected prefix not found error"); assertEquals(XmlError.SEVERITY_ERROR, ((XmlError) errors.get(0)).getSeverity()); // System.out.println(xml); // 9. Validation negative - Test error if QName doesn't match the extra facet xml = doc_begin + notation9 + doc_end; parsedDoc = loader.parse(xml, null, opts); - assertEquals("Did not find the root element in the Schema", docType, parsedDoc.schemaType()); + assertEquals(docType, parsedDoc.schemaType(), "Did not find the root element in the Schema"); errors.clear(); parsedDoc.validate(opts); - assertTrue("Expected validation errors", errors.size() == 1); - assertEquals("Expected prefix not found error", XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID, - ((XmlError) errors.get(0)).getErrorCode()); + assertTrue(errors.size() == 1, "Expected validation errors"); + assertEquals(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID, ((XmlError) errors.get(0)).getErrorCode(), "Expected prefix not found error"); assertEquals(XmlError.SEVERITY_ERROR, ((XmlError) errors.get(0)).getSeverity()); // System.out.println(xml); // 10. Validation positive - Test that validation can be performed correctly xml = doc_begin + notation10 + doc_end; parsedDoc = loader.parse(xml, null, opts); - assertEquals("Did not find the root element in the Schema", docType, parsedDoc.schemaType()); + assertEquals(docType, parsedDoc.schemaType(), "Did not find the root element in the Schema"); errors.clear(); parsedDoc.validate(opts); - assertTrue("Expected no validation errors", errors.size() == 0); + assertTrue(errors.size() == 0, "Expected no validation errors"); // System.out.println(xml); } } Modified: xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java Sun Feb 6 01:51:55 2022 @@ -18,7 +18,7 @@ package compile.scomp.detailed; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.util.LongUTFDataInputStream; import org.apache.xmlbeans.impl.util.LongUTFDataOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.*; import java.util.ArrayList; @@ -26,11 +26,11 @@ import java.util.Arrays; import java.util.Random; import static common.Common.SCOMP_CASE_ROOT; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class LargeAnnotation { @Test - public void longUTFInOutput() throws IOException { + void longUTFInOutput() throws IOException { int leftLimit = 48; // numeral '0' int rightLimit = 0x01FF_FFFF; int targetStringLength = 0x0001_FFFF; @@ -106,7 +106,7 @@ public class LargeAnnotation { @Test - public void bug235and556() throws XmlException, IOException { + void bug235and556() throws XmlException, IOException { ArrayList<XmlError> err = new ArrayList<>(); XmlOptions xm_opt = new XmlOptions().setErrorListener(err); xm_opt.setSavePrettyPrint(); Modified: xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/detailed/SchemaCompilerTests.java Sun Feb 6 01:51:55 2022 @@ -17,14 +17,14 @@ package compile.scomp.detailed; import org.apache.xmlbeans.XmlError; import org.apache.xmlbeans.impl.tool.Parameters; import org.apache.xmlbeans.impl.tool.SchemaCompiler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.ArrayList; import java.util.List; import static common.Common.*; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * This class contains tests that need to invoke the SchemaCompiler class which is @@ -45,11 +45,11 @@ public class SchemaCompilerTests { params.setSrcDir(new File(schemaCompOutputDirPath + outputDirName + P + "src")); params.setClassesDir(new File(schemaCompOutputDirPath + outputDirName + P + "classes")); SchemaCompiler.compile(params); - assertFalse(testName + "(): failure when executing scomp", printOptionErrMsgs(errors)); + assertFalse(hasSevereError(errors), testName + "(): failure when executing scomp"); } @Test - public void testUnionRedefine() { + void testUnionRedefine() { File[] xsdFiles = { new File(scompTestFilesRoot + "union_initial.xsd"), new File(scompTestFilesRoot + "union_redefine.xsd") }; String outputDirName = "unionred"; @@ -61,7 +61,7 @@ public class SchemaCompilerTests { involving an enumeration fails. */ @Test - public void testEnumerationRedefine1() { + void testEnumerationRedefine1() { File[] xsdFiles = { new File(scompTestFilesRoot + "enum1.xsd_"), new File(scompTestFilesRoot + "enum1_redefine.xsd_") }; String outputDirName = "enumRedef1"; @@ -73,7 +73,7 @@ public class SchemaCompilerTests { involving an enumeration fails. */ @Test - public void testEnumerationRedefine2() { + void testEnumerationRedefine2() { File[] xsdFiles ={ new File(scompTestFilesRoot + "enum2.xsd_"), new File(scompTestFilesRoot + "enum2_redefine.xsd_") }; String outputDirName = "enumRedef2"; @@ -85,7 +85,7 @@ public class SchemaCompilerTests { involving an enumeration fails. */ @Test - public void testEnumerationRedefine3() { + void testEnumerationRedefine3() { File[] xsdFiles = { new File(scompTestFilesRoot + "enum1.xsd_"), new File(scompTestFilesRoot + "enum3.xsd_"), new File(scompTestFilesRoot + "enum3_redefine.xsd_") }; @@ -99,7 +99,7 @@ public class SchemaCompilerTests { * using static handlers for extension interfaces with same method names */ @Test - public void testExtensionHandlerMethodNameCollision() { + void testExtensionHandlerMethodNameCollision() { File[] xsdFiles = { new File(scompTestFilesRoot + "methodsColide_jira205_278.xsd_") }; File[] configFiles = { new File(scompTestFilesRoot + "methodsColide_jira205_278.xsdconfig_") }; File[] javaFiles = { new File(scompTestFilesRoot + "ext" + P + "I1.java"), @@ -118,7 +118,7 @@ public class SchemaCompilerTests { params.setClassesDir(new File(schemaCompOutputDirPath + outputDirName + P + "classes")); SchemaCompiler.compile(params); - assertFalse("testExtensionHandlerMethodNameCollision(): failure when executing scomp", printOptionErrMsgs(errors)); + assertFalse(hasSevereError(errors), "testExtensionHandlerMethodNameCollision(): failure when executing scomp"); } /** @@ -126,7 +126,7 @@ public class SchemaCompilerTests { * -noext flag for compilation */ @Test - public void testNoExt() { + void testNoExt() { File[] xsdFiles = { new File(scompTestFilesRoot + "methodsColide_jira205_278.xsd_") }; File[] configFiles = { new File(scompTestFilesRoot + "methodsColide_jira205_278.xsdconfig_") }; String outputDirName = "noExt"; @@ -144,6 +144,6 @@ public class SchemaCompilerTests { params.setNoExt(true); SchemaCompiler.compile(params); - assertFalse("testNoExt(): failure when executing scomp", printOptionErrMsgs(errors)); + assertFalse(hasSevereError(errors), "testNoExt(): failure when executing scomp"); } } Modified: xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java Sun Feb 6 01:51:55 2022 @@ -20,7 +20,7 @@ import compile.scomp.common.mockobj.Test import compile.scomp.common.mockobj.TestFiler; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.xml.namespace.QName; import java.io.File; @@ -30,8 +30,8 @@ import java.util.stream.Stream; import static common.Common.*; import static compile.scomp.common.CompileTestBase.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -44,7 +44,7 @@ public class XmlBeanCompilationTests { * Filer != null for BindingConfig to be used */ @Test - public void test_bindingconfig_extension_compilation() throws Exception { + void test_bindingconfig_extension_compilation() throws Exception { TestFiler f = new TestFiler(); //initialize all of the values String extCaseDir = XBEAN_CASE_ROOT + P + "extensions" + P; @@ -89,14 +89,14 @@ public class XmlBeanCompilationTests { SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null, schemas, bind, XmlBeans.getBuiltinTypeSystem(), f, xm_opts); - assertTrue("isIslookupPrefixForNamespace not invoked", bind.isIslookupPrefixForNamespace()); - assertTrue("isIslookupPackageForNamespace not invoked", bind.isIslookupPackageForNamespace()); - assertTrue("isIslookupSuffixForNamespace not invoked", bind.isIslookupSuffixForNamespace()); - assertTrue("isIslookupJavanameForQName not invoked", bind.isIslookupJavanameForQName()); - assertTrue("isIsgetInterfaceExtensionsString not invoked", bind.isIsgetInterfaceExtensionsString()); - assertTrue("isIsgetInterfaceExtensions not invoked", bind.isIsgetInterfaceExtensions()); - assertTrue("isIsgetPrePostExtensions not invoked", bind.isIsgetPrePostExtensions()); - assertTrue("isIsgetPrePostExtensionsString not invoked", bind.isIsgetPrePostExtensionsString()); + assertTrue(bind.isIslookupPrefixForNamespace(), "isIslookupPrefixForNamespace not invoked"); + assertTrue(bind.isIslookupPackageForNamespace(), "isIslookupPackageForNamespace not invoked"); + assertTrue(bind.isIslookupSuffixForNamespace(), "isIslookupSuffixForNamespace not invoked"); + assertTrue(bind.isIslookupJavanameForQName(), "isIslookupJavanameForQName not invoked"); + assertTrue(bind.isIsgetInterfaceExtensionsString(), "isIsgetInterfaceExtensionsString not invoked"); + assertTrue(bind.isIsgetInterfaceExtensions(), "isIsgetInterfaceExtensions not invoked"); + assertTrue(bind.isIsgetPrePostExtensions(), "isIsgetPrePostExtensions not invoked"); + assertTrue(bind.isIsgetPrePostExtensionsString(), "isIsgetPrePostExtensionsString not invoked"); } /** @@ -104,7 +104,7 @@ public class XmlBeanCompilationTests { * and compilation with partial SOM usages */ @Test - public void test_incrCompile() throws Exception { + void test_incrCompile() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(FOR_XSD); obj1.documentProperties().setSourceName("OBJ1"); XmlObject[] schemas = {obj1}; @@ -128,35 +128,35 @@ public class XmlBeanCompilationTests { //BASIC COMPILATION sts = XmlBeans.compileXmlBeans(null, null, schemas, null, XmlBeans.getBuiltinTypeSystem(), null, opt); - assertTrue("Errors should have been empty", err.isEmpty()); + assertTrue(err.isEmpty(), "Errors should have been empty"); // find element in the type System - assertTrue("Could Not find Type from first Type System: " + sts1, findGlobalElement(sts.globalElements(), sts1)); + assertTrue(findGlobalElement(sts.globalElements(), sts1), "Could Not find Type from first Type System: " + sts1); //SIMPLE INCR COMPILATION sts = XmlBeans.compileXmlBeans(null, sts, schemas2, null, XmlBeans.getBuiltinTypeSystem(), null, opt); - assertTrue("Errors should have been empty", err.isEmpty()); + assertTrue(err.isEmpty(), "Errors should have been empty"); // find element in the type System - assertTrue("Could Not find Type from first Type System: " + sts1, findGlobalElement(sts.globalElements(), sts1)); - assertTrue("Could Not find Type from 2nd Type System: " + sts2, findGlobalElement(sts.globalElements(), sts2)); + assertTrue(findGlobalElement(sts.globalElements(), sts1), "Could Not find Type from first Type System: " + sts1); + assertTrue(findGlobalElement(sts.globalElements(), sts2), "Could Not find Type from 2nd Type System: " + sts2); //BUILDING OFF BASE SIMPLE INCR COMPILATION sts = XmlBeans.compileXmlBeans(null, sts, schemas2, null, sts, null, opt); - assertTrue("Errors should have been empty", err.isEmpty()); + assertTrue(err.isEmpty(), "Errors should have been empty"); // find element in the type System - assertTrue("Could Not find Type from first Type System: " + sts1, findGlobalElement(sts.globalElements(), sts1)); - assertTrue("Could Not find Type from 2nd Type System: " + sts2, findGlobalElement(sts.globalElements(), sts2)); + assertTrue(findGlobalElement(sts.globalElements(), sts1), "Could Not find Type from first Type System: " + sts1); + assertTrue(findGlobalElement(sts.globalElements(), sts2), "Could Not find Type from 2nd Type System: " + sts2); //INCR COMPILATION WITH RECOVERABLE ERROR err.clear(); SchemaTypeSystem b = XmlBeans.compileXmlBeans(null, sts, schemas3, null, XmlBeans.getBuiltinTypeSystem(), null, opt); // find element in the type System - assertTrue("Could Not find Type from first Type System: " + sts1, findGlobalElement(b.globalElements(), sts1)); + assertTrue(findGlobalElement(b.globalElements(), sts1), "Could Not find Type from first Type System: " + sts1); - assertTrue("Could Not find Type from 2nd Type System: " + sts2, findGlobalElement(b.globalElements(), sts2)); + assertTrue(findGlobalElement(b.globalElements(), sts2), "Could Not find Type from 2nd Type System: " + sts2); - assertTrue("Could Not find Type from 3rd Type System: " + sts3, findGlobalElement(b.globalElements(), sts3)); + assertTrue(findGlobalElement(b.globalElements(), sts3), "Could Not find Type from 3rd Type System: " + sts3); //compare to the expected xm_errors assertEquals(1, err.size()); 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=1897795&r1=1897794&r2=1897795&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 Sun Feb 6 01:51:55 2022 @@ -17,9 +17,9 @@ package compile.scomp.incr.schemaCompile import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.util.FilerImpl; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import javax.xml.namespace.QName; import java.io.File; @@ -31,7 +31,7 @@ import java.util.*; import static compile.scomp.common.CompileTestBase.*; import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class IncrCompilationTests { @@ -120,7 +120,7 @@ public class IncrCompilationTests { xm.setSavePrettyPrint(); } - @Before + @BeforeEach public void setUp() throws IOException { clearOutputDirs(); errors.clear(); @@ -128,7 +128,7 @@ public class IncrCompilationTests { @Test - public void test_dupetype_diffns() throws Exception { + void test_dupetype_diffns() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "attrName", "string")); XmlObject[] schemas = {obj1}; SchemaTypeSystem base = compileSchemas(schemas, out, xm); @@ -137,16 +137,16 @@ public class IncrCompilationTests { XmlObject[] schemas2 = {obj2}; SchemaTypeSystem incr = incrCompileXsd(base, schemas2, outincr, xm); - assertNotNull("BASE: Baz elName was not found", base.findElement(new QName("http://baz", "elName"))); + assertNotNull(base.findElement(new QName("http://baz", "elName")), "BASE: Baz elName was not found"); // assertNotNull("INCR: Baz elName was not found", incr.findElement(new QName("http://baz", "elName"))); - assertNotNull("INCR: Bar elName was not found", incr.findElement(new QName("http://bar", "elName"))); + assertNotNull(incr.findElement(new QName("http://bar", "elName")), "INCR: Bar elName was not found"); // compareandPopErrors(out, outincr, errors); handleErrors(errors); } @Test - @Ignore("incremental build / test doesn't provide new elements") + @Disabled("incremental build / test doesn't provide new elements") public void test_dupens_difftypename() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "attrName", "string")); XmlObject obj2 = XmlObject.Factory.parse(getRedefSchema("baz", "elName2", "attrName2", "string")); @@ -168,7 +168,7 @@ public class IncrCompilationTests { } @Test - @Ignore("works in standalone, doesn't work in Jenkins") + @Disabled("works in standalone, doesn't work in Jenkins") public void test_dupens_attrnamechange() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "attrName", "string")); XmlObject obj2 = XmlObject.Factory.parse(getRedefSchema("baz", "elName", "attrName2", "string")); @@ -191,7 +191,7 @@ public class IncrCompilationTests { } @Test - @Ignore("works in standalone, doesn't work in Jenkins") + @Disabled("works in standalone, doesn't work in Jenkins") public void test_dupens_attrtypechange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "attrName", "string")); @@ -215,7 +215,7 @@ public class IncrCompilationTests { } @Test - @Ignore("works in standalone, doesn't work in Jenkins") + @Disabled("works in standalone, doesn't work in Jenkins") public void test_dupens_eltypechange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "attrName", "string")); @@ -240,7 +240,7 @@ public class IncrCompilationTests { } @Test - public void test_typechange() throws Exception { + void test_typechange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "attrName", "string")); XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "attrName2", "string")); @@ -264,7 +264,7 @@ public class IncrCompilationTests { // test regeneration of generated java files by the Filer @Test - public void test_schemaFilesRegeneration_01() throws Exception { + void test_schemaFilesRegeneration_01() throws Exception { // incremental compile with the same file again. There should be no regeneration of src files XmlObject obj1 = XmlObject.Factory.parse(schemaFilesRegeneration_schema1); @@ -280,7 +280,7 @@ public class IncrCompilationTests { // create a new filer here with the incrCompile flag value set to 'true' Filer filer = new FilerImpl(out, out, null, true, true); SchemaTypeSystem base = XmlBeans.compileXmlBeans("teststs",null,schemas,null,builtin,filer,xm); - assertNotNull("Compilation failed during Incremental Compile.", base); + assertNotNull(base, "Compilation failed during Incremental Compile."); base.saveToDirectory(out); // get timestamps for first compile @@ -292,22 +292,22 @@ public class IncrCompilationTests { 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); - assertNotNull("Compilation failed during Incremental Compile.", incr); + assertNotNull(incr, "Compilation failed during Incremental Compile."); incr.saveToDirectory(out); recordTimeStamps(out, recompileTimeStamps); // compare generated source timestamps here - assertEquals("Number of Files not equal for Incremental Schema Compilation using Filer",initialTimeStamps.size(), recompileTimeStamps.size()); + assertEquals(initialTimeStamps.size(), recompileTimeStamps.size(), "Number of Files not equal for Incremental Schema Compilation using Filer"); Set<String> keyset = initialTimeStamps.keySet(); for (String eachFile : keyset) { - assertEquals("Mismatch for File " + eachFile, initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile)); + assertEquals(initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile), "Mismatch for File " + eachFile); } handleErrors(errors); } @Test - public void test_schemaFilesRegeneration_02() throws Exception { + void test_schemaFilesRegeneration_02() throws Exception { // incremental compile with the changes. Specific files should be regenerated XmlObject obj1 = XmlObject.Factory.parse(schemaFilesRegeneration_schema1); XmlObject obj2 = XmlObject.Factory.parse(schemaFilesRegeneration_schema1_modified); @@ -322,7 +322,7 @@ public class IncrCompilationTests { // create a new filer here with the incrCompile flag value set to 'true' Filer filer = new FilerImpl(out, out, null, true, true); SchemaTypeSystem base = XmlBeans.compileXmlBeans("test",null,schemas,null,builtin,filer,xm); - assertNotNull("Compilation failed during Incremental Compile.", base); + assertNotNull(base, "Compilation failed during Incremental Compile."); base.saveToDirectory(out); // get timestamps for first compile @@ -333,12 +333,12 @@ public class IncrCompilationTests { 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); - assertNotNull("Compilation failed during Incremental Compile.", incr); + assertNotNull(incr, "Compilation failed during Incremental Compile."); incr.saveToDirectory(out); recordTimeStamps(out, recompileTimeStamps); // compare generated source timestamps here - assertEquals("Number of Files not equal for Incremental Schema Compilation using Filer",initialTimeStamps.size(), recompileTimeStamps.size()); + assertEquals(initialTimeStamps.size(), recompileTimeStamps.size(), "Number of Files not equal for Incremental Schema Compilation using Filer"); Set<String> keyset = initialTimeStamps.keySet(); // Atype has been modified, BType has been removed @@ -348,14 +348,14 @@ public class IncrCompilationTests { 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)); + assertNotSame(initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile), "File Should have been regenerated by Filer but has the same timestamp"); continue; } if (eachFile.equalsIgnoreCase(modifiedFileName2)) { - assertNotSame("File Should have been regenerated by Filer but has the same timestamp", initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile)); + assertNotSame(initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile), "File Should have been regenerated by Filer but has the same timestamp"); continue; } - assertEquals("Mismatch for File " + eachFile, initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile)); + assertEquals(initialTimeStamps.get(eachFile), recompileTimeStamps.get(eachFile), "Mismatch for File " + eachFile); } handleErrors(errors); 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=1897795&r1=1897794&r2=1897795&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 Sun Feb 6 01:51:55 2022 @@ -16,10 +16,10 @@ package compile.scomp.incr.schemaCompile.detailed; import org.apache.xmlbeans.*; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import javax.xml.namespace.QName; import java.io.File; @@ -32,10 +32,10 @@ import java.util.List; import static compile.scomp.common.CompileTestBase.*; import static compile.scomp.incr.schemaCompile.detailed.IncrCompilationTests.getBaseSchema; -import static org.junit.Assert.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNotSame; -@Ignore("Currently all tests receive a duplicate schema entry exception") +@Disabled("Currently all tests receive a duplicate schema entry exception") public class ModelGroupTests { private static final File outincr = xbeanOutput(INCR_PATH); @@ -51,7 +51,7 @@ public class ModelGroupTests { xm.setSavePrettyPrint(); } - @Before + @BeforeEach public void setUp() throws IOException { clearOutputDirs(); errors.clear(); @@ -60,7 +60,7 @@ public class ModelGroupTests { obj2File = File.createTempFile("obj2_", ".xsd"); } - @After + @AfterEach public void tearDown() throws Exception { obj1File.delete(); obj2File.delete(); @@ -84,7 +84,7 @@ public class ModelGroupTests { } @Test - public void test_model_diffns_choice2seqchange() throws Exception { + void test_model_diffns_choice2seqchange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject[] schemas = getSchema(obj1File, "<xs:element name=\"elName\" type=\"bas:aType\" xmlns:bas=\"http://baz\" />" + @@ -120,7 +120,7 @@ public class ModelGroupTests { } @Test - public void test_model_seq2choicechange() throws Exception { + void test_model_seq2choicechange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject[] schemas = getSchema(obj1File, "<xs:element name=\"elName\" type=\"bas:aType\" xmlns:bas=\"http://baz\" />" + @@ -155,7 +155,7 @@ public class ModelGroupTests { } @Test - public void test_model_seq2choicechange_diffns() throws Exception { + void test_model_seq2choicechange_diffns() throws Exception { XmlObject[] schemas = {XmlObject.Factory.parse(getBaseSchema("bar", "elName", "attrName", "string"))}; XmlObject[] schemas2 = getSchema(obj2File, @@ -184,7 +184,7 @@ public class ModelGroupTests { } @Test - public void test_model_seq2allchange() throws Exception { + void test_model_seq2allchange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject[] schemas = getSchema(obj1File, "<xs:element name=\"elName\" type=\"bas:aType\" xmlns:bas=\"http://baz\" />" + @@ -220,7 +220,7 @@ public class ModelGroupTests { } @Test - public void test_model_all2seqchange() throws Exception { + void test_model_all2seqchange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject[] schemas = getSchema(obj1File, "<xs:element name=\"elName\" type=\"bas:aType\" xmlns:bas=\"http://baz\" />" + @@ -256,7 +256,7 @@ public class ModelGroupTests { } @Test - public void test_model_all2choicechange() throws Exception { + void test_model_all2choicechange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject[] schemas = getSchema(obj1File, "<xs:element name=\"elName\" type=\"bas:aType\" xmlns:bas=\"http://baz\" />" + @@ -292,7 +292,7 @@ public class ModelGroupTests { } @Test - public void test_model_choice2choicechange() throws Exception { + void test_model_choice2choicechange() throws Exception { //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType")); XmlObject[] schemas = getSchema(obj1File, "<xs:element name=\"elName\" type=\"bas:aType\" xmlns:bas=\"http://baz\" />" + --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
