From commits-return-12011-archive-asf-public=cust-asf.ponee.io@poi.apache.org Sat Jan 19 00:08:57 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 02149180675 for ; Sat, 19 Jan 2019 00:08:54 +0100 (CET) Received: (qmail 19196 invoked by uid 500); 18 Jan 2019 23:08:54 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 19182 invoked by uid 99); 18 Jan 2019 23:08:54 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jan 2019 23:08:54 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 02DA23A26EC for ; Fri, 18 Jan 2019 23:08:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1851656 [3/28] - in /xmlbeans/trunk: ./ external/ lib/ resources/ resources/typeimpl/ resources/typeimpl/org/ resources/typeimpl/org/apache/ resources/typeimpl/org/apache/xmlbeans/ resources/typeimpl/org/apache/xmlbeans/impl/ resources/typ... Date: Fri, 18 Jan 2019 23:08:48 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20190118230853.02DA23A26EC@svn01-us-west.apache.org> Modified: xmlbeans/trunk/test/cases/xbean/xmlobject/japanese/pr-xml-utf-16.xml URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/cases/xbean/xmlobject/japanese/pr-xml-utf-16.xml?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== Binary files xmlbeans/trunk/test/cases/xbean/xmlobject/japanese/pr-xml-utf-16.xml (original) and xmlbeans/trunk/test/cases/xbean/xmlobject/japanese/pr-xml-utf-16.xml Fri Jan 18 23:08:44 2019 differ Modified: xmlbeans/trunk/test/cases/xbean/xmlobject/listandunion.xsd URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/cases/xbean/xmlobject/listandunion.xsd?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/cases/xbean/xmlobject/listandunion.xsd (original) +++ xmlbeans/trunk/test/cases/xbean/xmlobject/listandunion.xsd Fri Jan 18 23:08:44 2019 @@ -52,7 +52,7 @@ - + Modified: xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/TestUriValidation.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/TestUriValidation.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/TestUriValidation.java (original) +++ xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/TestUriValidation.java Fri Jan 18 23:08:44 2019 @@ -1,29 +1,18 @@ package ValidatingXSRTests.checkin; -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.framework.TestCase; -import junit.framework.Assert; -import org.apache.xmlbeans.impl.util.XsTypeConverter; import org.apache.xmlbeans.impl.common.InvalidLexicalValueException; +import org.apache.xmlbeans.impl.util.XsTypeConverter; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Created by Cezar Andrei (cezar dot andrei at gmail dot com) * Date: Jul 23, 2009 */ -public class TestUriValidation - extends TestCase -{ - public TestUriValidation(String name) - { - super(name); - } - - public static Test suite() - { - return new TestSuite(TestUriValidation.class); - } - +public class TestUriValidation { + @Test public void testLexAnyUriValid() { String[] validURIs = { @@ -66,12 +55,12 @@ public class TestUriValidation catch (RuntimeException e) { System.out.println("URI should be valid: " + validURIs[i] + " " + e.getCause().getCause().getMessage()); - Assert.assertTrue("URI should be valid: " + validURIs[i], false); - throw new IllegalStateException("URI should be valid: " + validURIs[i]); + fail("URI should be valid: " + validURIs[i]); } } } + @Test public void testLexAnyUriInvalid() { // From XQTS cvshead June 2009 @@ -98,12 +87,11 @@ public class TestUriValidation { XsTypeConverter.lexAnyURI(invalidURIs[i]); System.out.println("URI should be invalid: " + invalidURIs[i] ); - Assert.assertTrue("URI should be invalid: " + invalidURIs[i], false); - throw new IllegalStateException("URI should be invalid: " + invalidURIs[i]); + fail("URI should be invalid: " + invalidURIs[i]); } catch (InvalidLexicalValueException e) { - Assert.assertTrue("URI should be invalid: " + invalidURIs[i] + " " + e.getCause().getCause().getMessage(), true); + assertTrue("URI should be invalid: " + invalidURIs[i] + " " + e.getCause().getCause().getMessage(), true); } } } Modified: xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/ValidatingXMLStreamReaderTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/ValidatingXMLStreamReaderTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/ValidatingXMLStreamReaderTests.java (original) +++ xmlbeans/trunk/test/src/ValidatingXSRTests/checkin/ValidatingXMLStreamReaderTests.java Fri Jan 18 23:08:44 2019 @@ -14,51 +14,35 @@ */ package ValidatingXSRTests.checkin; -import junit.framework.TestCase; -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.framework.Assert; +import org.apache.xmlbeans.*; +import org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader; +import org.junit.Test; +import org.openuri.testNumerals.DocDocument; +import tools.util.JarUtil; +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +import javax.xml.stream.Location; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.Location; import javax.xml.stream.events.XMLEvent; -import javax.xml.namespace.QName; -import javax.xml.namespace.NamespaceContext; -import java.io.FileNotFoundException; -import java.io.FileInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; -import java.io.StringReader; -import java.util.Collection; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; -import org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader; -import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; -import org.apache.xmlbeans.XmlBeans; -import org.apache.xmlbeans.XmlError; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.XmlException; - -import org.openuri.testNumerals.DocDocument; - - -import tools.util.JarUtil; +import static org.junit.Assert.assertTrue; /** * */ -public class ValidatingXMLStreamReaderTests extends TestCase -{ - public ValidatingXMLStreamReaderTests(String name) { super(name); } - - public static Test suite() { return new TestSuite(ValidatingXMLStreamReaderTests.class); } - +public class ValidatingXMLStreamReaderTests { private final static String URI_NUMERALS = "http://openuri.org/testNumerals"; + @Test public void testValidateDoc() throws FileNotFoundException, XMLStreamException,Exception { File[] files = new File[] { @@ -113,9 +97,10 @@ public class ValidatingXMLStreamReaderTe if (!valXsr.isValid()) System.out.println("---------------\n"); - Assert.assertTrue("File '" + file.getName() +"' is invalid.", valXsr.isValid()); + assertTrue("File '" + file.getName() +"' is invalid.", valXsr.isValid()); } + @Test public void testValidateGlobalAtt1() throws XMLStreamException { XmlObject xo = XmlObject.Factory.newInstance(); @@ -148,10 +133,11 @@ public class ValidatingXMLStreamReaderTe } } - Assert.assertTrue("Global attribute validation is broken.", valXsr.isValid()); + assertTrue("Global attribute validation is broken.", valXsr.isValid()); } + @Test public void testValidateGlobalAtt2() throws XMLStreamException { @@ -178,7 +164,7 @@ public class ValidatingXMLStreamReaderTe System.out.println(sev + " " + err.getLine() + ":" + err.getColumn() + " " + err.getMessage() + " "); } - Assert.assertTrue("Global attribute validation 2 is broken.", valXsr.isValid()); + assertTrue("Global attribute validation 2 is broken.", valXsr.isValid()); } private static class TestXSR implements XMLStreamReader @@ -437,6 +423,7 @@ public class ValidatingXMLStreamReaderTe } + @Test public void testValidateContent1() throws XMLStreamException { XmlObject xo = XmlObject.Factory.newInstance(); @@ -470,7 +457,7 @@ public class ValidatingXMLStreamReaderTe } valXsr.next(); } - Assert.assertTrue("Content1 validation is broken.", valXsr.isValid()); + assertTrue("Content1 validation is broken.", valXsr.isValid()); } private static void printState(XMLStreamReader vxsr) @@ -509,7 +496,7 @@ public class ValidatingXMLStreamReaderTe } } - + @Test public void testValidateContent2() throws XMLStreamException { String doc = "57.654321"; @@ -556,6 +543,6 @@ loop: while(valXsr.hasNext()) System.out.println(sev + " " + err.getLine() + ":" + err.getColumn() + " " + err.getMessage() + " "); } - Assert.assertTrue("Content2 validation is broken.", valXsr.isValid()); + assertTrue("Content2 validation is broken.", valXsr.isValid()); } } Modified: xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java (original) +++ xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatingXmlStreamReaderTests.java Fri Jan 18 23:08:44 2019 @@ -15,39 +15,40 @@ */ package ValidatingXSRTests.detailed; +import com.foo.sample.HeadingDocument; +import org.apache.xmlbeans.SchemaType; +import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader; -import org.apache.xmlbeans.*; -import junit.framework.Assert; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.openuri.test.location.LocationDocument; +import org.openuri.test.mixedContent.LetterDocument; +import org.openuri.test.mixedContent.NoMixedDocument; +import org.openuri.test.person.Name; +import org.openuri.test.person.PersonDocument; +import org.openuri.test.person.PersonType; import tools.util.JarUtil; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.util.StreamReaderDelegate; import javax.xml.stream.events.XMLEvent; -import java.io.*; +import javax.xml.stream.util.StreamReaderDelegate; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.StringReader; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; -// Schema Imports -import org.openuri.test.numerals.*; -import org.openuri.test.location.*; -import org.openuri.test.person.*; -import org.openuri.test.mixedContent.LetterDocument; -import org.openuri.test.mixedContent.NoMixedDocument; -import com.foo.sample.HeadingDocument; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +// Schema Imports -public class ValidatingXmlStreamReaderTests - extends TestCase -{ - public ValidatingXmlStreamReaderTests(String name) - { - super(name); - } +public class ValidatingXmlStreamReaderTests { // Base variable static String casesLoc = "xbean/ValidatingStream/"; @@ -61,157 +62,131 @@ public class ValidatingXmlStreamReaderTe // the file in the same location, but packaged into xmlcases.jar // SO, any change to the xml files for these tests will not be // reflected till they make it into xmlcases.jar. (ant build.xmlcases) - - public void testDocWithNoSchema() - throws Exception - { - checkDocIsInvalid(getCasesFile(casesLoc + "po.xml"), - null); + @Test + public void testDocWithNoSchema() throws Exception { + checkDocIsInvalid(getCasesFile(casesLoc + "po.xml"), null); } - public void testValidLocationDoc() - throws Exception - { - checkDocIsValid(getCasesFile(casesLoc + "location.xml"), - null); + @Test + public void testValidLocationDoc() throws Exception { + checkDocIsValid(getCasesFile(casesLoc + "location.xml"), null); } - public void testInvalidLocationDoc() - throws Exception - { - checkDocIsInvalid(getCasesFile(casesLoc + "location-inv.xml"), - LocationDocument.type); + @Test + public void testInvalidLocationDoc() throws Exception { + checkDocIsInvalid(getCasesFile(casesLoc + "location-inv.xml"), LocationDocument.type); } - public void testValidPersonDoc() - throws Exception - { - checkDocIsValid(getCasesFile(casesLoc + "person.xml"), - PersonDocument.type); + @Test + public void testValidPersonDoc() throws Exception { + checkDocIsValid(getCasesFile(casesLoc + "person.xml"), PersonDocument.type); } - public void testInvalidPersonDoc() - throws Exception - { - checkDocIsInvalid(getCasesFile(casesLoc + "person-inv.xml"), - PersonDocument.type); + @Test + public void testInvalidPersonDoc() throws Exception { + checkDocIsInvalid(getCasesFile(casesLoc + "person-inv.xml"), PersonDocument.type); } - - public void testValidMixedContentDoc() - throws Exception - { + @Test + public void testValidMixedContentDoc() throws Exception { checkDocIsValid(getCasesFile(casesLoc + "mixed-content.xml"), - LetterDocument.type); + LetterDocument.type); } - public void testInvalidNomixedContentDoc() - throws Exception - { + @Test + public void testInvalidNomixedContentDoc() throws Exception { checkDocIsInvalid(getCasesFile(casesLoc + "nomixed-content-inv.xml"), - NoMixedDocument.type); + NoMixedDocument.type); } - public void testInvalidMissingAttributeDoc() - throws Exception - { + @Test + public void testInvalidMissingAttributeDoc() throws Exception { checkDocIsInvalid(getCasesFile(casesLoc + "foo-inv.xml"), - HeadingDocument.type); + HeadingDocument.type); } - public void testContentName() - throws Exception - { + @Test + public 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)); + checkContent(sXml, type, true)); } // Same as testContentName.. expect the xml has no chars before the first // start element - public void testContentName2() - throws Exception - { + @Test + public 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)); + checkContent(sXml, type, true)); } - public void testContentSibling() - throws Exception - { + @Test + public 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)); + checkContent(sXml, type, true)); } - public void testInvalidContentSibling() - throws Exception - { + @Test + public 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)); + !checkContent(sXml, type, true)); } - public void testValidXsiType() - throws Exception - { + @Test + public 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)); + checkContent(sXml, type, true)); } - public void testInvalidXsiType() - throws Exception - { + @Test + public 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)); + !checkContent(sXml, type, true)); } - public void testIncompatibleXsiType() - throws Exception - { + @Test + public 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)); + !checkContent(sXml, type, true)); } - public void testValidMixedContent() - throws Exception - { + @Test + public 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)); + checkContent(sXml, type, true)); } - /* - public void testGlobalAttribute() - throws Exception - { - String sXml = JarUtil.getResourceFromJar("xmlcases.jar", - casesLoc + "global-attr.xml"); + + @Test + @Ignore + public void testGlobalAttribute() throws Exception { + String sXml = JarUtil.getResourceFromJar(casesLoc + "global-attr.xml"); assertTrue("Global Attribute test failed:\n", checkContent(sXml, null, true)); - } - */ + // Tests for increasing code-coverage metrics - public void testValXsrReuse() - throws Exception - { + @Test + public void testValXsrReuse() throws Exception { Collection errors = new ArrayList(); File[] xmls = new File[2]; xmls[0] = getCasesFile(casesLoc + "person.xml"); @@ -221,24 +196,19 @@ public class ValidatingXmlStreamReaderTe boolean[] ret = runValidator(xmls, type, errors); String common = "Test for ValidatingXmlStreamReader reuse failed"; - assertTrue(common + "\nReturn value has more than 2 elements", - ret.length == 2); + 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]); + + ret[0] + " & " + ret[1], + ret[0] && !ret[1]); } - public void testIllegalEvent() - throws Exception - { + public void testIllegalEvent() throws Exception { // Will require writing another XSR wrapper.. albeit simple } /*/ - public void testWalk() - throws Exception - { + public void testWalk() throws Exception { walkXml(getCasesFile(casesLoc + "global-attr.xml")); System.out.println(); walkXml(getCasesFile(casesLoc + "person-sibling.xml")); @@ -246,11 +216,9 @@ public class ValidatingXmlStreamReaderTe // */ ////////////////////////////////////////////////////////////////////// // Utility Methods - private void walkXml(File xml) - throws Exception - { + private void walkXml(File xml) throws Exception { XMLStreamReader xr = XMLInputFactory.newInstance(). - createXMLStreamReader(new FileInputStream(xml)); + createXMLStreamReader(new FileInputStream(xml)); //xsr.nextTag(); XmlContentTestXSR xsr = new XmlContentTestXSR(xr); @@ -281,22 +249,22 @@ public class ValidatingXmlStreamReaderTe private boolean runValidator(File xml, SchemaType type, Collection errors) - throws IllegalArgumentException, Exception + throws IllegalArgumentException, Exception { if (errors == null) throw new IllegalArgumentException( - "Collection object cannot be null"); + "Collection object cannot be null"); XMLStreamReader xsr = XMLInputFactory.newInstance(). - createXMLStreamReader(new FileInputStream(xml)); + createXMLStreamReader(new FileInputStream(xml)); ValidatingXMLStreamReader valXsr = new ValidatingXMLStreamReader(); valXsr.init(xsr, - false, - type, - XmlBeans.typeLoaderForClassLoader(ValidatingXMLStreamReader.class.getClassLoader()), - null, - errors); + false, + type, + XmlBeans.typeLoaderForClassLoader(ValidatingXMLStreamReader.class.getClassLoader()), + null, + errors); // Walk through the xml while (valXsr.hasNext()) @@ -309,27 +277,27 @@ public class ValidatingXmlStreamReaderTe // This method is primarily for testing re-use of the ValXSR object. // but could come in handy later.. private boolean[] runValidator(File[] xml, - SchemaType type, - Collection errors) - throws IllegalArgumentException, Exception + SchemaType type, + Collection errors) + throws IllegalArgumentException, Exception { if (errors == null) throw new IllegalArgumentException( - "Collection object cannot be null"); + "Collection object cannot be null"); ValidatingXMLStreamReader valXsr = new ValidatingXMLStreamReader(); boolean[] retArray = new boolean[xml.length]; for (int i = 0; i < xml.length; i++) { XMLStreamReader xsr = XMLInputFactory.newInstance(). - createXMLStreamReader(new FileInputStream(xml[i])); + createXMLStreamReader(new FileInputStream(xml[i])); valXsr.init(xsr, - false, - type, - XmlBeans.typeLoaderForClassLoader(ValidatingXMLStreamReader.class.getClassLoader()), - null, - errors); + false, + type, + XmlBeans.typeLoaderForClassLoader(ValidatingXMLStreamReader.class.getClassLoader()), + null, + errors); // Walk through the xml while (valXsr.hasNext()) @@ -341,9 +309,7 @@ public class ValidatingXmlStreamReaderTe return retArray; } - protected void checkDocIsValid(File file, SchemaType type) - throws Exception - { + protected void checkDocIsValid(File file, SchemaType type) throws Exception { Collection errors = new ArrayList(); boolean isValid = runValidator(file, type, errors); @@ -352,35 +318,31 @@ public class ValidatingXmlStreamReaderTe } - protected void checkDocIsInvalid(File file, SchemaType type) - throws Exception - { + protected void checkDocIsInvalid(File file, SchemaType type) throws Exception { Collection errors = new ArrayList(); boolean isValid = runValidator(file, type, errors); - Assert.assertTrue("File '" + file.getName() + "' is valid, but was expecting invalid.", - !isValid); + assertTrue("File '" + file.getName() + "' is valid, but was expecting invalid.", + !isValid); } public boolean checkContent(String fragment, - SchemaType type, - boolean printErrors) - throws Exception - { + SchemaType type, + boolean printErrors) throws Exception { XMLStreamReader xsr = XMLInputFactory.newInstance(). - createXMLStreamReader(new StringReader(fragment)); + createXMLStreamReader(new StringReader(fragment)); XmlContentTestXSR cxsr = new XmlContentTestXSR(xsr); Collection errors = new ArrayList(); ValidatingXMLStreamReader valXsr = new ValidatingXMLStreamReader(); valXsr.init(cxsr, - false, - type, - XmlBeans.typeLoaderForClassLoader(ValidatingXMLStreamReader.class.getClassLoader()), - null, - errors); + false, + type, + XmlBeans.typeLoaderForClassLoader(ValidatingXMLStreamReader.class.getClassLoader()), + null, + errors); // Walk through the xml while (valXsr.hasNext()) @@ -409,8 +371,8 @@ public class ValidatingXmlStreamReaderTe // XmlStreamReader extension for content Validation // will not work for Global Attribute public class XmlContentTestXSR - extends StreamReaderDelegate - implements XMLStreamReader + extends StreamReaderDelegate + implements XMLStreamReader { private static final int TAGOPEN = 100; private static final int TAGCLOSE = 101; @@ -455,11 +417,11 @@ public class ValidatingXmlStreamReaderTe // Scan for the first XMLEvent.START_ELEMENT _next = UNDEFINED; while ((super.hasNext()) && (_next != XMLEvent.START_ELEMENT)) - _next = super.next(); + _next = super.next(); if (_next != XMLEvent.START_ELEMENT) throw new XMLStreamException( - "Could not find a start element"); + "Could not find a start element"); initialized = true; // Now move past the first tag @@ -504,7 +466,7 @@ public class ValidatingXmlStreamReaderTe if (depth < 0 && state == TAGOPEN) { throw new XMLStreamException( - "Illegal XML Stream state"); + "Illegal XML Stream state"); } else if (depth == 0 && state == TAGOPEN) { Modified: xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatorUtilTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatorUtilTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatorUtilTests.java (original) +++ xmlbeans/trunk/test/src/ValidatingXSRTests/detailed/ValidatorUtilTests.java Fri Jan 18 23:08:44 2019 @@ -15,31 +15,19 @@ package ValidatingXSRTests.detailed; -import junit.framework.TestCase; - -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.events.XMLEvent; -import java.util.Collection; -import java.util.ArrayList; - +import ValidatingXSRTests.common.TestPrefixResolver; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.impl.validator.ValidatorUtil; +import org.junit.Test; import tools.xml.Utils; -import ValidatingXSRTests.common.TestPrefixResolver; -public class ValidatorUtilTests - extends TestCase -{ - public ValidatorUtilTests(String name) - { - super(name); - } - - // Base variable - static String casesLoc = "xbean/ValidatingStream/"; +import java.util.ArrayList; +import java.util.Collection; +import static org.junit.Assert.fail; +public class ValidatorUtilTests { + @Test public void testValidQName() throws Exception { @@ -58,9 +46,8 @@ public class ValidatorUtilTests } - public void testInvalidQName() - throws Exception - { + @Test + public void testInvalidQName() { String xml = "foo:bz"; TestPrefixResolver pRes = new TestPrefixResolver("foo", "http://openuri.org/test/My"); SchemaType type = org.openuri.test.simType.QNameType.type; Modified: xmlbeans/trunk/test/src/common/Common.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/common/Common.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/common/Common.java (original) +++ xmlbeans/trunk/test/src/common/Common.java Fri Jan 18 23:08:44 2019 @@ -15,20 +15,16 @@ 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 junit.framework.Assert; -import junit.framework.TestCase; - -import javax.xml.namespace.QName; +import static org.junit.Assert.assertNotNull; -/** - * - */ -public class Common extends TestCase +public class Common { public static final String NEWLINE = System.getProperty("line.separator"); public static final String P = File.separator; @@ -41,14 +37,10 @@ public class Common extends TestCase public static String OUTPUTROOT = FWROOT+P+"build" + P + "test" + P + "output"; - public LinkedList errorList; - public XmlOptions xmOpts; + public final LinkedList errorList = new LinkedList(); + public final XmlOptions xmOpts = new XmlOptions(); - public Common(String name) - { - super(name); - errorList = new LinkedList(); - xmOpts = new XmlOptions(); + public Common() { xmOpts.setErrorListener(errorList); } @@ -238,7 +230,7 @@ public class Common extends TestCase } } } finally { - Assert.assertNotNull(xobj); + assertNotNull(xobj); return xobj; } } @@ -265,7 +257,7 @@ public class Common extends TestCase ioe.printStackTrace(); ioe.getMessage(); } finally { - Assert.assertNotNull(xobj); + assertNotNull(xobj); return xobj; } } Modified: xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java (original) +++ xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java Fri Jan 18 23:08:44 2019 @@ -15,53 +15,42 @@ package compile.scomp.checkin; -import junit.framework.TestCase; -import junit.framework.Assert; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.common.QNameHelper; -import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator; -import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.apache.xmlbeans.impl.tool.CodeGenUtil; import org.apache.xmlbeans.impl.tool.Diff; +import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator; +import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelComplexType; -import org.apache.xmlbeans.SchemaBookmark; -import org.apache.xmlbeans.SchemaType; -import org.apache.xmlbeans.SchemaTypeSystem; -import org.apache.xmlbeans.XmlBeans; -import org.apache.xmlbeans.XmlError; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlOptions; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import tools.util.TestRunUtil; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; -import java.util.List; import java.util.Arrays; import java.util.Collections; +import java.util.List; -import tools.util.TestRunUtil; - - -public class CompilationTests extends TestCase -{ - public CompilationTests(String name) { super(name); } - public static Test suite() { return new TestSuite(CompilationTests.class); } +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; - public void testJ2EE() throws Throwable - { +public class CompilationTests { + @Test + public void testJ2EE() throws Throwable { deltree(xbeanOutput("compile/scomp/j2ee")); // First, compile schema File srcdir = xbeanOutput("compile/scomp/j2ee/j2eeconfigxml/src"); File classesdir = xbeanOutput("compile/scomp/j2ee/j2eeconfigxml/classes"); File outputjar = xbeanOutput("compile/scomp/j2ee/j2eeconfigxml.jar"); SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[] { + params.setXsdFiles(new File[]{ xbeanCase("j2ee/application-client_1_4.xsd"), xbeanCase("j2ee/application_1_4.xsd"), xbeanCase("j2ee/connector_1_5.xsd"), @@ -81,13 +70,13 @@ public class CompilationTests extends Te StringWriter message = new StringWriter(); if (!result) dumpErrors(errors, new PrintWriter(message)); - Assert.assertTrue("Build failed:" + message, result); - Assert.assertTrue("Cannot find " + outputjar, outputjar.exists()); + assertTrue("Build failed:" + message, result); + assertTrue("Cannot find " + outputjar, outputjar.exists()); } - public void testIncrementalCompilation() throws Throwable - { - File[] files = new File[] { + @Test + public void testIncrementalCompilation() throws Throwable { + File[] files = new File[]{ xbeanCase("incr/incr1.xsd"), xbeanCase("incr/incr3.xsd"), xbeanCase("incr/incr4.xsd"), @@ -105,14 +94,14 @@ public class CompilationTests extends Te schemas[i] = SchemaDocument.Factory.parse(files[i]).getSchema(); // Compile incrementally // Initial compile - schemas[n - 2] = SchemaDocument.Factory.parse(files[n-2]).getSchema(); + schemas[n - 2] = SchemaDocument.Factory.parse(files[n - 2]).getSchema(); List errors = new ArrayList(); XmlOptions options = (new XmlOptions()).setErrorListener(errors); SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem(); system = XmlBeans.compileXsd(schemas, builtin, options); Assert.assertNotNull("Compilation failed during inititial compile.", system); System.out.println("-= Initial Compile =-"); - + for (int i = 0; i < system.globalTypes().length; i++) { System.out.println("[" + i + "]-" + system.globalTypes()[i].getName()); } @@ -126,7 +115,7 @@ public class CompilationTests extends Te // Incremental compile String url = schemas[n - 2].documentProperties().getSourceName(); SchemaDocument.Schema[] schemas1 = new SchemaDocument.Schema[1]; - schemas1[0] = SchemaDocument.Factory.parse(files[n-1]).getSchema(); + schemas1[0] = SchemaDocument.Factory.parse(files[n - 1]).getSchema(); schemas1[0].documentProperties().setSourceName(url); errors.clear(); system = XmlBeans.compileXsd(system, schemas1, builtin, options); @@ -144,7 +133,7 @@ public class CompilationTests extends Te } // Now compile non-incrementally for the purpose of comparing the result errors.clear(); - schemas[n-2] = schemas1[0]; + schemas[n - 2] = schemas1[0]; system = XmlBeans.compileXsd(schemas, builtin, options); Assert.assertNotNull("Compilation failed during reference compile.", system); SchemaCodeGenerator.saveTypeSystem(system, out, null, null, null); @@ -166,19 +155,18 @@ public class CompilationTests extends Te errors.clear(); Diff.dirsAsTypeSystems(out, outincr, errors); System.setProperty("xmlbeans.diff.diffIndex", oldPropValue == null ? "true" : oldPropValue); - if (errors.size() > 0) - { + if (errors.size() > 0) { StringWriter message = new StringWriter(); for (int i = 0; i < errors.size(); i++) message.write(((String) errors.get(i)) + "\n"); - Assert.fail("Differences encountered:" + message); + fail("Differences encountered:" + message); } } - public void testSchemaBookmarks() throws Throwable - { - File srcSchema = xbeanCase("simple/person.xsd"); + @Test + public void testSchemaBookmarks() throws Throwable { + File srcSchema = xbeanCase("../../simple/person/person.xsd"); // Parse SchemaDocument.Schema parsed = SchemaDocument.Factory.parse(srcSchema).getSchema(); // Navigate to the type definition @@ -186,12 +174,11 @@ public class CompilationTests extends Te boolean found = false; int i; for (i = 0; i < cTypes.length; i++) - if ("person".equals(cTypes[i].getName())) - { + if ("person".equals(cTypes[i].getName())) { found = true; break; } - Assert.assertTrue("Could not find the \"person\" complex type", found); + assertTrue("Could not find the \"person\" complex type", found); // Set the bookmark SchemaBookmark sb = new SchemaBookmark("MyBookmark"); cTypes[i].newCursor().setBookmark(sb); @@ -207,44 +194,44 @@ public class CompilationTests extends Te Assert.assertEquals("MyBookmark", val); } - - public void __testSimple() throws Throwable - { + @Test + @Ignore + public void testSimple() throws Throwable { deltree(xbeanOutput("compile/scomp/simple")); // First, compile schema // First, compile schema - File inputfile1 = xbeanCase("simple/person.xsd"); - File inputfile2 = xbeanCase("simple/simplec.xsd"); + File inputfile1 = xbeanCase("../../simple/person.xsd"); + File inputfile2 = xbeanCase("../../simple/simplec.xsd"); - File srcdir = xbeanOutput("simple/simpletypes/src"); + File srcdir = xbeanOutput("simple/simpletypes/src"); File classesdir = xbeanOutput("compile/scomp/simple/simpletypes/classes"); File outputjar = xbeanOutput("compile/scomp/simple/simpletypes.jar"); SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[] { inputfile1, inputfile2 }); + params.setXsdFiles(new File[]{inputfile1, inputfile2}); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - Assert.assertTrue("Build failed", SchemaCompiler.compile(params)); + assertTrue("Build failed", SchemaCompiler.compile(params)); // Then, compile java classes File javasrc = xbeanCase("simple/javasrc"); File javaclasses = xbeanOutput("compile/scomp/simple/javaclasses"); javaclasses.mkdirs(); - List testcp = new ArrayList(); - testcp.addAll(Arrays.asList(CodeGenUtil.systemClasspath())); + List testcp = Arrays.asList(CodeGenUtil.systemClasspath()); testcp.add(outputjar); - CodeGenUtil.externalCompile(Arrays.asList(new File[] { javasrc }), javaclasses, (File[])testcp.toArray(new File[testcp.size()]), true); + CodeGenUtil.externalCompile(Arrays.asList(javasrc), javaclasses, testcp.toArray(new File[0]), true); // Then run the test testcp.add(javaclasses); - TestRunUtil.run("SimplePersonTest", new File[] { outputjar, javaclasses }); + TestRunUtil.run("SimplePersonTest", new File[]{outputjar, javaclasses}); } - public void __testDownload() throws Throwable - { + @Test + @Ignore + public void testDownload() throws Throwable { deltree(xbeanOutput("compile/scomp/include")); { @@ -253,14 +240,14 @@ public class CompilationTests extends Te File classesdir = xbeanOutput("compile/scomp/include/shouldfail/classes"); File outputjar = xbeanOutput("compile/scomp/include/shouldfail.jar"); SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[] { - xbeanCase ("compile/scomp/j2ee/j2ee_1_4.xsd") + params.setXsdFiles(new File[]{ + xbeanCase("compile/scomp/j2ee/j2ee_1_4.xsd") }); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - Assert.assertTrue("Build should have failed", !SchemaCompiler.compile(params)); - Assert.assertTrue("Should not have created " + outputjar, !outputjar.exists()); + assertTrue("Build should have failed", !SchemaCompiler.compile(params)); + assertTrue("Should not have created " + outputjar, !outputjar.exists()); } { @@ -270,35 +257,36 @@ public class CompilationTests extends Te File outputjar = xbeanOutput("compile/scomp/include/shouldsucceed.jar"); SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); params.setDownload(true); - params.setXsdFiles(new File[] { + params.setXsdFiles(new File[]{ xbeanCase("compile/scomp/j2ee/j2ee_1_4.xsd") }); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - Assert.assertTrue("Build failed", SchemaCompiler.compile(params)); - Assert.assertTrue("Cannout find " + outputjar, outputjar.exists()); + assertTrue("Build failed", SchemaCompiler.compile(params)); + assertTrue("Cannout find " + outputjar, outputjar.exists()); } } - public void __testPricequote() throws Throwable - { + @Test + @Ignore + public void testPricequote() throws Throwable { deltree(xbeanOutput("compile/scomp/pricequote")); // First, compile schema File srcdir = xbeanOutput("compile/scomp/pricequote/src"); File classesdir = xbeanOutput("compile/scomp/pricequote/classes"); File outputjar = xbeanOutput("compile/scomp/pricequote/pricequote.jar"); SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[] { - xbeanCase("compile/scomp/pricequote/PriceQuote.xsd") }); + params.setXsdFiles(new File[]{ + xbeanCase("compile/scomp/pricequote/PriceQuote.xsd")}); params.setSrcDir(srcdir); params.setClassesDir(classesdir); params.setOutputJar(outputjar); - Assert.assertTrue("Build failed "+fwroot, SchemaCompiler.compile(params)); - Assert.assertTrue("Cannout find " + outputjar, outputjar.exists()); + assertTrue("Build failed " + fwroot, SchemaCompiler.compile(params)); + assertTrue("Cannout find " + outputjar, outputjar.exists()); } - static String [] invalidSchemas = { + private static String[] invalidSchemas = { "\n" + " \n" + " \n" + @@ -336,7 +324,7 @@ public class CompilationTests extends Te "\n", }; - static String [] validSchemas = { + static String[] validSchemas = { "\n" + " \n" + " \n" + @@ -374,36 +362,34 @@ public class CompilationTests extends Te "\n", }; - public void __testFinal() throws Throwable - { + @Test + @Ignore + public void testFinal() throws Throwable { SchemaDocument[] schemas = new SchemaDocument[invalidSchemas.length]; // Parse the invalid schema files - for (int i = 0 ; i < invalidSchemas.length ; i++) + for (int i = 0; i < invalidSchemas.length; i++) schemas[i] = SchemaDocument.Factory.parse(invalidSchemas[i]); // Now compile the invalid schemas, test that they fail - for (int i = 0 ; i < schemas.length ; i++) - { + for (int i = 0; i < schemas.length; i++) { try { - XmlBeans.loadXsd(new XmlObject[] {schemas[i]}); + XmlBeans.loadXsd(new XmlObject[]{schemas[i]}); fail("Schema should have failed to compile:\n" + invalidSchemas[i]); + } catch (XmlException success) { } - catch (XmlException success) {} } // Parse the valid schema files schemas = new SchemaDocument[validSchemas.length]; - for (int i = 0 ; i < validSchemas.length ; i++) + for (int i = 0; i < validSchemas.length; i++) schemas[i] = SchemaDocument.Factory.parse(validSchemas[i]); // Compile the valid schemas. They should not fail - for (int i = 0 ; i < schemas.length ; i++) - { + for (int i = 0; i < schemas.length; i++) { try { XmlBeans.loadXsd(new XmlObject[]{schemas[i]}); - } - catch (XmlException fail) { + } catch (XmlException fail) { fail("Failed to compile schema:\n" + validSchemas[i]); } } @@ -411,70 +397,54 @@ public class CompilationTests extends Te //TESTENV: - private static File fwroot = getRootFile(); + private static File fwroot = getRootFile(); private static File caseroot = new File(fwroot, "test/cases"); //location of files under "cases folder" - static String fileLocation="/xbean/compile/scomp/"; + static String fileLocation = "/xbean/compile/scomp/"; private static File outputroot = new File(fwroot, "build/test/output"); - private static void dumpErrors(List errors, PrintWriter out) - { + private static void dumpErrors(List errors, PrintWriter out) { // Display the errors - for (int i = 0; i < errors.size(); i++) - { + for (int i = 0; i < errors.size(); i++) { XmlError error = (XmlError) errors.get(i); if (error.getSeverity() == XmlError.SEVERITY_ERROR) out.println(error.toString()); } } - public static File getRootFile() throws IllegalStateException - { - try - { - return new File( System.getProperty( "xbean.rootdir" ) ).getCanonicalFile(); - } - catch( IOException e ) - { + private static File getRootFile() throws IllegalStateException { + try { + return new File(System.getProperty("xbean.rootdir")).getCanonicalFile(); + } catch (IOException e) { throw new IllegalStateException(e.toString()); } } - public static File xbeanCase(String str) - { - return (new File(caseroot.getPath()+fileLocation, str)); + private static File xbeanCase(String str) { + return (new File(caseroot.getPath() + fileLocation, str)); } - public static File xbeanOutput(String str) - { + private static File xbeanOutput(String str) { File result = (new File(outputroot, str)); File parentdir = result.getParentFile(); parentdir.mkdirs(); return result; } - public static void deltree(File dir) - throws InterruptedException - { - if (dir.exists()) - { - if (dir.isDirectory()) - { + private static void deltree(File dir) + throws InterruptedException { + if (dir.exists()) { + if (dir.isDirectory()) { String[] list = dir.list(); for (int i = 0; i < list.length; i++) deltree(new File(dir, list[i])); } - if (!dir.delete()) - { - for (int i=0; i<5; i++) - { - try - { + if (!dir.delete()) { + for (int i = 0; i < 5; i++) { + try { System.out.println("Sleep 1s and try do delete it again: " + dir.getCanonicalPath()); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(System.out); } Thread.currentThread().sleep(1000); Modified: xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java (original) +++ xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java Fri Jan 18 23:08:44 2019 @@ -14,35 +14,29 @@ */ package compile.scomp.checkin; -import org.apache.xmlbeans.*; -import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl; -import compile.scomp.common.mockobj.TestFiler; import compile.scomp.common.CompileCommon; import compile.scomp.common.CompileTestBase; +import compile.scomp.common.mockobj.TestFiler; +import org.apache.xmlbeans.*; +import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl; +import org.junit.After; +import org.junit.Test; +import java.io.File; import java.util.ArrayList; import java.util.Iterator; -import java.util.Vector; import java.util.List; -import java.io.File; -import java.io.IOException; +import java.util.Vector; -import junit.framework.Assert; +import static org.junit.Assert.*; -/** - * - * - */ public class XmlBeansCompCheckinTests extends CompileTestBase -{ public List xm_errors; - public XmlOptions xm_opts; - Vector expBinType; - Vector expSrcType; +{ public final List xm_errors = new ArrayList(); + public final XmlOptions xm_opts = new XmlOptions(); + final Vector expBinType = new Vector(); + final Vector expSrcType = new Vector(); - public XmlBeansCompCheckinTests(String name) - { - super(name); - expBinType = new Vector(); + public XmlBeansCompCheckinTests() { expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/atypedb57type.xsb"); expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/elname429edoctype.xsb"); expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/elnameelement.xsb"); @@ -54,26 +48,22 @@ public class XmlBeansCompCheckinTests ex expBinType.add("schemaorg_apache_xmlbeans/javaname/baz/AType.xsb"); expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/TypeSystemHolder.class"); - expSrcType = new Vector(); expSrcType.add("baz.AType"); expSrcType.add("baz.impl.ATypeImpl"); expSrcType.add("baz.ElNameDocument"); expSrcType.add("baz.impl.ElNameDocumentImpl"); - xm_errors = new ArrayList(); - xm_opts = new XmlOptions(); xm_opts.setErrorListener(xm_errors); xm_opts.setSavePrettyPrint(); } - public void tearDown() throws Exception - { - super.tearDown(); - + @After + public void tearDown() throws Exception { if (xm_errors.size() > 0) xm_errors.clear(); } + @Test public void test_Filer_compilation() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(forXsd); @@ -108,9 +98,8 @@ public class XmlBeansCompCheckinTests ex /** * Verify Partial SOM cannot be saved to file system - * - * @throws Exception */ + @Test public void test_sts_noSave() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(forXsd); @@ -160,7 +149,7 @@ public class XmlBeansCompCheckinTests ex throw e; } - Assert.assertTrue("Expected partial schema type system", ((SchemaTypeSystemImpl)sts).isIncomplete()); + assertTrue("Expected partial schema type system", ((SchemaTypeSystemImpl)sts).isIncomplete()); //call some stupid methods on STS @@ -173,50 +162,47 @@ public class XmlBeansCompCheckinTests ex tempDir = new File(OUTPUTROOT, "psom_save"); tempDir.mkdirs(); tempDir.deleteOnExit(); - Assert.assertTrue("Output Directory Init needed to be empty", - tempDir.listFiles().length == 0); + assertEquals("Output Directory Init needed to be empty", 0, tempDir.listFiles().length); //This should not Work sts.saveToDirectory(tempDir); - Assert.fail("Expected IllegalStateException"); + fail("Expected IllegalStateException"); } catch (IllegalStateException e) { // ok System.out.println("sts.saveToDirectory() threw IllegalStateException as expected"); } //make sure nothing was written - Assert.assertTrue("Partial SOM output dir needed to be empty", - tempDir.listFiles().length == 0); + assertEquals("Partial SOM output dir needed to be empty", 0, tempDir.listFiles().length); // Check using save(Filer) on Partial SOM TestFiler tf = null; try { //setUp outputDirectory tf = new TestFiler(); - Assert.assertTrue("Filer Source should have been size 0", - tf.getBinFileVec().size() == 0); + assertEquals("Filer Source should have been size 0", 0, tf.getBinFileVec().size()); //This should not Work sts.save(tf); - Assert.fail("Expected IllegalStateException"); + fail("Expected IllegalStateException"); } catch (IllegalStateException e) { // ok System.out.println("sts.save() threw IllegalStateException as expected"); } //make sure nothing was written - Assert.assertTrue("Filer -Bin- Partial SOM " + + assertTrue("Filer -Bin- Partial SOM " + "output dir needed to be empty", tf.getBinFileVec().size() == 0); - Assert.assertTrue("Filer -SRC- Partial SOM " + + assertTrue("Filer -SRC- Partial SOM " + "output dir needed to be empty", tf.getSrcFileVec().size() == 0); - Assert.assertFalse("Filer Create Source File " + + assertFalse("Filer Create Source File " + "method should not have been invoked", tf.isCreateSourceFile()); - Assert.assertFalse("Filer Create Binary File " + + assertFalse("Filer Create Binary File " + "method should not have been invoked", tf.isCreateBinaryFile()); @@ -224,7 +210,7 @@ public class XmlBeansCompCheckinTests ex try { tf = new TestFiler(); - Assert.assertTrue("Filer Source should have been size 0", + assertTrue("Filer Source should have been size 0", tf.getBinFileVec().size() == 0); //reset data @@ -236,20 +222,20 @@ public class XmlBeansCompCheckinTests ex null, schemas3, null, XmlBeans.getBuiltinTypeSystem(), tf, opt); - Assert.assertTrue("Errors was not empty", !err.isEmpty()); + assertTrue("Errors was not empty", !err.isEmpty()); //make sure nothing was written - Assert.assertTrue("Filer -Bin- Partial SOM " + + assertTrue("Filer -Bin- Partial SOM " + "output dir needed to be empty", tf.getBinFileVec().size() == 0); - Assert.assertTrue("Filer -SRC- Partial SOM " + + assertTrue("Filer -SRC- Partial SOM " + "output dir needed to be empty", tf.getSrcFileVec().size() == 0); - Assert.assertFalse("Filer Create Source File " + + assertFalse("Filer Create Source File " + "method should not have been invoked", tf.isCreateSourceFile()); - Assert.assertFalse("Filer Create Binary File " + + assertFalse("Filer Create Binary File " + "method should not have been invoked", tf.isCreateBinaryFile()); } catch (Exception e) { @@ -265,6 +251,7 @@ public class XmlBeansCompCheckinTests ex * ensure that entry point properly handles * different configs with null values */ + @Test public void test_entrypoint_nullVals() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(forXsd); Modified: xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java (original) +++ xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java Fri Jan 18 23:08:44 2019 @@ -14,22 +14,14 @@ */ package compile.scomp.common; -import java.util.Vector; - import common.Common; -/** - * - * - */ +import java.util.Vector; + public class CompileCommon extends Common{ public static String fileLocation = XBEAN_CASE_ROOT +P + "compile" + P + "scomp" + P; - public CompileCommon(String name){ - super(name); - } - /** compare contents of two vectors */ public static void comparefNameVectors(Vector act, Vector exp) throws Exception { Modified: xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java (original) +++ xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java Fri Jan 18 23:08:44 2019 @@ -14,19 +14,21 @@ */ package compile.scomp.common; -import junit.framework.Assert; -import org.apache.xmlbeans.impl.tool.SchemaCompiler; +import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.tool.Diff; import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator; -import org.apache.xmlbeans.*; +import org.apache.xmlbeans.impl.tool.SchemaCompiler; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; import javax.xml.namespace.QName; import java.io.File; import java.io.IOException; import java.io.StringWriter; -import java.util.List; import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; /** * TODO: modify for deprecation warnings @@ -84,8 +86,7 @@ public class CompileTestBase extends Com " " + ""; - public CompileTestBase(String name) { - super(name); + public CompileTestBase() { out = xbeanOutput(outPath); sanity = xbeanOutput(sanityPath); outincr = xbeanOutput(incrPath); @@ -188,7 +189,7 @@ public class CompileTestBase extends Com SchemaTypeSystem sts; sts = XmlBeans.compileXsd(system, schemas, builtin, options); - Assert.assertNotNull("Compilation failed during Incremental Compile.", sts); + assertNotNull("Compilation failed during Incremental Compile.", sts); SchemaCodeGenerator.saveTypeSystem(sts, outincr, null, null, null); return sts; @@ -202,7 +203,7 @@ public class CompileTestBase extends Com SchemaTypeSystem system; SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem(); system = XmlBeans.compileXsd(schemas, builtin, options); - Assert.assertNotNull("Compilation failed during compile.", system); + assertNotNull("Compilation failed during compile.", system); SchemaCodeGenerator.saveTypeSystem(system, outDir, null, null, null); return system; } @@ -214,7 +215,7 @@ public class CompileTestBase extends Com SchemaTypeSystem system; SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem(); system = XmlBeans.compileXsd(schemas, builtin, options); - Assert.assertNotNull("Compilation failed during compile.", system); + assertNotNull("Compilation failed during compile.", system); SchemaCodeGenerator.saveTypeSystem(system, out, null, null, null); return system; } @@ -224,7 +225,7 @@ public class CompileTestBase extends Com StringWriter message = new StringWriter(); for (int i = 0; i < errors.size(); i++) message.write(((String) errors.get(i)) + "\n"); - Assert.fail("\nDifferences encountered:\n" + message); + fail("\nDifferences encountered:\n" + message); } } Modified: xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java (original) +++ xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java Fri Jan 18 23:08:44 2019 @@ -15,35 +15,28 @@ package compile.scomp.detailed; -import junit.framework.TestCase; -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.framework.Assert; +import compile.scomp.common.CompileCommon; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; - -import java.io.File; -import java.util.*; - -import compile.scomp.common.CompileCommon; +import org.junit.Test; import javax.xml.namespace.QName; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; - -public class DetailedCompTests extends TestCase -{ - public DetailedCompTests(String name) { super(name); } - public static Test suite() { return new TestSuite(DetailedCompTests.class); } +import static org.junit.Assert.*; +public class DetailedCompTests { /** * This test requires laxDoc.xsd to be compiled and * on the classpath ahead of time, otherwise documentation * element processing would not occur * @throws Exception */ - public void testLaxDocProcessing() throws Exception - { + @Test + public void testLaxDocProcessing() throws Exception { QName q = new QName("urn:lax.Doc.Compilation", "ItemRequest"); ArrayList err = new ArrayList(); XmlOptions xm_opt = new XmlOptions().setErrorListener(err); @@ -60,7 +53,7 @@ public class DetailedCompTests extends T try{ SchemaTypeSystem sts = XmlBeans.compileXmlBeans(null, null, schemas, null, XmlBeans.getBuiltinTypeSystem(), null, xm_opt); - Assert.assertTrue("STS was null", sts != null); + assertNotNull("STS was null", sts); }catch(XmlException xmlEx){ valDocEx = true; System.err.println("Expected Error: "+xmlEx.getMessage()); @@ -152,8 +145,8 @@ public class DetailedCompTests extends T /** * This tests usage of the xs:NOTATION type - * @throws Exception */ + @Test public void testNotation() throws Exception { String schema; Modified: xmlbeans/trunk/test/src/compile/scomp/detailed/SchemaCompilerTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/detailed/SchemaCompilerTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/compile/scomp/detailed/SchemaCompilerTests.java (original) +++ xmlbeans/trunk/test/src/compile/scomp/detailed/SchemaCompilerTests.java Fri Jan 18 23:08:44 2019 @@ -14,14 +14,15 @@ */ package compile.scomp.detailed; -import junit.framework.TestCase; +import common.Common; +import org.apache.xmlbeans.impl.tool.SchemaCompiler; +import org.junit.Test; -import java.util.List; -import java.util.ArrayList; import java.io.File; +import java.util.ArrayList; +import java.util.List; -import org.apache.xmlbeans.impl.tool.SchemaCompiler; -import common.Common; +import static org.junit.Assert.fail; /** * This class contains tests that need to invoke the SchemaCompiler class which is @@ -30,15 +31,11 @@ import common.Common; * The tests need to be run with cmd line param that points to the test case root directory and xmlbeans root * ex: -Dcases.location=D:\svnnew\xmlbeans\trunk\test\cases -Dxbean.rootdir=D:\svnnew\xmlbeans\trunk */ -public class SchemaCompilerTests extends Common +public class SchemaCompilerTests extends Common { public static String scompTestFilesRoot = XBEAN_CASE_ROOT + P + "compile" + P + "scomp" + P + "schemacompiler" + P; public static String schemaCompOutputDirPath = OUTPUTROOT + P + "compile" + P + "scomp" + P; - public SchemaCompilerTests(String name){ - super(name); - } - private void _testCompile(File[] xsdFiles, String outputDirName, String testName) @@ -56,6 +53,7 @@ public class SchemaCompilerTests extend } } + @Test public void testUnionRedefine() { File[] xsdFiles = @@ -69,6 +67,7 @@ public class SchemaCompilerTests extend /** This tests a bug where compilation of a schema redefining a type involving an enumeration fails. */ + @Test public void testEnumerationRedefine1() { File[] xsdFiles = @@ -82,6 +81,7 @@ public class SchemaCompilerTests extend /** This tests a bug where compilation of a schema redefining a type involving an enumeration fails. */ + @Test public void testEnumerationRedefine2() { File[] xsdFiles = @@ -95,6 +95,7 @@ public class SchemaCompilerTests extend /** This tests a bug where compilation of a schema redefining a type involving an enumeration fails. */ + @Test public void testEnumerationRedefine3() { File[] xsdFiles = @@ -110,6 +111,7 @@ public class SchemaCompilerTests extend * [XMLBEANS-205]: * using static handlers for extension interfaces with same method names */ + @Test public void testExtensionHandlerMethodNameCollision() { File[] xsdFiles = @@ -143,6 +145,7 @@ public class SchemaCompilerTests extend * [XMLBEANS-278]: * -noext flag for compilation */ + @Test public void testNoExt() { File[] xsdFiles = Modified: xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java (original) +++ xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java Fri Jan 18 23:08:44 2019 @@ -15,116 +15,86 @@ package compile.scomp.detailed; -import junit.framework.Assert; -import org.apache.xmlbeans.*; -import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument; - -import java.io.*; -import java.util.*; - -import compile.scomp.common.CompileCommon; import compile.scomp.common.CompileTestBase; -import compile.scomp.common.mockobj.TestFiler; import compile.scomp.common.mockobj.TestBindingConfig; +import compile.scomp.common.mockobj.TestFiler; +import org.apache.xmlbeans.*; +import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument; +import org.junit.After; +import org.junit.Test; import javax.xml.namespace.QName; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import static org.junit.Assert.assertTrue; /** * Ensure that several compilation mechanisms all generate * the same schematypesystem - * */ -public class XmlBeanCompilationTests extends CompileTestBase -{ - public List xm_errors; - public XmlOptions xm_opts; - Vector expBinType; - Vector expSrcType; - - public XmlBeanCompilationTests(String name) - { - super(name); - expBinType = new Vector(); - expBinType.add("schema/system/apiCompile/atypedb57type.xsb"); - expBinType.add("schema/system/apiCompile/elname429edoctype.xsb"); - expBinType.add("schema/system/apiCompile/elnameelement.xsb"); - expBinType.add("schema/system/apiCompile/index.xsb"); - expBinType.add("schema/element/http_3A_2F_2Fbaz/elName.xsb"); - expBinType.add("schema/type/http_3A_2F_2Fbaz/aType.xsb"); - expBinType.add("schema/namespace/http_3A_2F_2Fbaz/xmlns.xsb"); - expBinType.add("schema/javaname/baz/ElNameDocument.xsb"); - expBinType.add("schema/javaname/baz/AType.xsb"); - expBinType.add("schema/system/apiCompile/TypeSystemHolder.class"); - - expSrcType = new Vector(); - expSrcType.add("baz.AType"); - expSrcType.add("baz.impl.ATypeImpl"); - expSrcType.add("baz.ElNameDocument"); - expSrcType.add("baz.impl.ElNameDocumentImpl"); +public class XmlBeanCompilationTests extends CompileTestBase { + private final List xm_errors = new ArrayList(); + private final XmlOptions xm_opts = new XmlOptions(); - xm_errors = new ArrayList(); - xm_opts = new XmlOptions(); + public XmlBeanCompilationTests() { xm_opts.setErrorListener(xm_errors); xm_opts.setSavePrettyPrint(); - } - - public void tearDown() throws Exception - { - super.tearDown(); + @After + public void tearDown() throws Exception { if (xm_errors.size() > 0) xm_errors.clear(); } /** * Filer != null for BindingConfig to be used - * - * @throws Exception */ - public void test_bindingconfig_extension_compilation() throws Exception - { + @Test + public void test_bindingconfig_extension_compilation() throws Exception { TestFiler f = new TestFiler(); //initialize all of the values String extCaseDir = XBEAN_CASE_ROOT + P + "extensions" + P; String extSrcDir = CASEROOT + P + - ".." + P + "src" + P + "xmlobject" + P + "extensions" + P; + ".." + P + "src" + P + "xmlobject" + P + "extensions" + P; File[] cPath = CompileTestBase.getClassPath(); String dir = extCaseDir + P + "interfaceFeature" + P + "averageCase"; String dir2 = extCaseDir + P + "prePostFeature" + P + - "ValueRestriction"; + "ValueRestriction"; ConfigDocument.Config bConf = ConfigDocument.Factory.parse( - new File(dir + P + "po.xsdconfig")) - .getConfig(); + new File(dir + P + "po.xsdconfig")) + .getConfig(); ConfigDocument.Config cConf = ConfigDocument.Factory.parse( - new File(dir2 + P + "company.xsdconfig")) - .getConfig(); + new File(dir2 + P + "company.xsdconfig")) + .getConfig(); String simpleConfig = "\n" + - "\n" + - "com.easypo\n" + - ""; + "xmlns:xb=\"http://xml.apache.org/xmlbeans/2004/02/xbean/config\"\n" + + " xmlns:ep=\"http://xbean.interface_feature/averageCase/PurchaseOrder\">\n" + + "\n" + + "com.easypo\n" + + ""; ConfigDocument.Config confDoc = ConfigDocument.Factory.parse(simpleConfig).getConfig(); ConfigDocument.Config[] confs = new ConfigDocument.Config[]{bConf, confDoc, cConf}; String fooHandlerPath = extSrcDir + P + "interfaceFeature" + P + - "averageCase" + P + "existing" + P + "FooHandler.java"; + "averageCase" + P + "existing" + P + "FooHandler.java"; String iFooPath = extSrcDir + P + "interfaceFeature" + P + - "averageCase" + P + "existing" + P + "IFoo.java"; + "averageCase" + P + "existing" + P + "IFoo.java"; String iSetterPath = extSrcDir + P + "prePostFeature" + P + - "ValueRestriction" + P + "existing" + P + "ISetter.java"; + "ValueRestriction" + P + "existing" + P + "ISetter.java"; String setterHandlerPath = extSrcDir + P + "prePostFeature" + P + - "ValueRestriction" + P + "existing" + P + "SetterHandler.java"; + "ValueRestriction" + P + "existing" + P + "SetterHandler.java"; File[] fList = new File[]{new File(fooHandlerPath), new File(iFooPath), - new File(iSetterPath), - new File(setterHandlerPath)}; + new File(iSetterPath), + new File(setterHandlerPath)}; //use created BindingConfig TestBindingConfig bind = new TestBindingConfig(confs, fList, cPath); @@ -132,12 +102,12 @@ public class XmlBeanCompilationTests ext //set XSDs XmlObject obj1 = XmlObject.Factory.parse(new File(dir + P + "po.xsd")); XmlObject obj2 = XmlObject.Factory.parse( - new File(dir2 + P + "company.xsd")); + new File(dir2 + P + "company.xsd")); XmlObject[] schemas = new XmlObject[]{obj1, obj2}; //filer must be present on this method SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null, - schemas, bind, XmlBeans.getBuiltinTypeSystem(), f, xm_opts); + schemas, bind, XmlBeans.getBuiltinTypeSystem(), f, xm_opts); if (!bind.isIslookupPrefixForNamespace()) throw new Exception("isIslookupPrefixForNamespace not invoked"); @@ -153,8 +123,6 @@ public class XmlBeanCompilationTests ext throw new Exception("isIsgetInterfaceExtensions not invoked"); if (!bind.isIsgetPrePostExtensions()) throw new Exception("isIsgetPrePostExtensions not invoked"); - if (!bind.isIsgetInterfaceExtensions()) - throw new Exception("isIsgetInterfaceExtensions not invoked"); if (!bind.isIsgetPrePostExtensionsString()) throw new Exception("isIsgetPrePostExtensionsString not invoked"); } @@ -163,8 +131,8 @@ public class XmlBeanCompilationTests ext * Verify basic incremental compilation * and compilation with partial SOM usages */ - public void test_incrCompile() throws Exception - { + @Test + public void test_incrCompile() throws Exception { XmlObject obj1 = XmlObject.Factory.parse(forXsd); obj1.documentProperties().setSourceName("OBJ1"); XmlObject[] schemas = new XmlObject[]{obj1}; @@ -187,63 +155,63 @@ public class XmlBeanCompilationTests ext //BASIC COMPILATION sts = XmlBeans.compileXmlBeans(null, - null, schemas, null, - XmlBeans.getBuiltinTypeSystem(), null, opt); + null, schemas, null, + XmlBeans.getBuiltinTypeSystem(), null, opt); - Assert.assertTrue("Errors should have been empty", err.isEmpty()); + assertTrue("Errors should have been empty", err.isEmpty()); // find element in the type System if (!findGlobalElement(sts.globalElements(), sts1)) throw new Exception( - "Could Not find Type from first Type System: " + sts1); + "Could Not find Type from first Type System: " + sts1); //SIMPLE INCR COMPILATION sts = XmlBeans.compileXmlBeans(null, - sts, schemas2, null, - XmlBeans.getBuiltinTypeSystem(), null, opt); - Assert.assertTrue("Errors should have been empty", err.isEmpty()); + sts, schemas2, null, + XmlBeans.getBuiltinTypeSystem(), null, opt); + assertTrue("Errors should have been empty", err.isEmpty()); // find element in the type System if (!findGlobalElement(sts.globalElements(), sts1)) throw new Exception("Could Not find Type from first Type System: " + - sts1); + sts1); if (!findGlobalElement(sts.globalElements(), sts2)) throw new Exception("Could Not find Type from 2nd Type System: " + - sts2); + sts2); System.out.println("Building over Existing"); //BUILDING OFF BASE SIMPLE INCR COMPILATION sts = XmlBeans.compileXmlBeans(null, - sts, schemas2, null, - sts, null, opt); - Assert.assertTrue("Errors should have been empty", err.isEmpty()); + sts, schemas2, null, + sts, null, opt); + assertTrue("Errors should have been empty", err.isEmpty()); // find element in the type System if (!findGlobalElement(sts.globalElements(), sts1)) throw new Exception("Could Not find Type from first Type System: " + - sts1); + sts1); if (!findGlobalElement(sts.globalElements(), sts2)) throw new Exception("Could Not find Type from 2nd Type System: " + - sts2); + sts2); //INCR COMPILATION WITH RECOVERABLE ERROR err.clear(); SchemaTypeSystem b = XmlBeans.compileXmlBeans(null, - sts, schemas3, null, - XmlBeans.getBuiltinTypeSystem(), null, opt); + sts, schemas3, null, + XmlBeans.getBuiltinTypeSystem(), null, opt); // find element in the type System if (!findGlobalElement(b.globalElements(), sts1)) throw new Exception("Could Not find Type from first Type System: " + - sts1); + sts1); if (!findGlobalElement(b.globalElements(), sts2)) throw new Exception("Could Not find Type from 2nd Type System: " + - sts2); + sts2); if (!findGlobalElement(b.globalElements(), sts3)) throw new Exception("Could Not find Type from 3rd Type System: " + - sts3); + sts3); printSTS(b); @@ -252,15 +220,15 @@ public class XmlBeanCompilationTests ext // print out the recovered xm_errors if (!err.isEmpty()) { System.out.println( - "Schema invalid: partial schema type system recovered"); - for (Iterator i = err.iterator(); i.hasNext();) { + "Schema invalid: partial schema type system recovered"); + for (Iterator i = err.iterator(); i.hasNext(); ) { XmlError xErr = (XmlError) i.next(); System.out.println(xErr); //compare to the expected xm_errors if ((xErr.getErrorCode().compareTo("src-resolve") == 0) && - (xErr.getMessage().compareTo( - "type 'bType@http://baz' not found.") == - 0)) + (xErr.getMessage().compareTo( + "type 'bType@http://baz' not found.") == + 0)) psom_expError = true; } } @@ -270,58 +238,54 @@ public class XmlBeanCompilationTests ext } +/* + @Test + public void test_diff_compilationMethods() throws IOException, + XmlException, Exception { + + //initialize the schema compiler + SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); + params.setXsdFiles(new File[]{scompFile}); + params.setSrcDir(scompDirFile); + params.setClassesDir(scompDirFile); + + //save out schema for use in scomp later + XmlObject obj1 = XmlObject.Factory.parse(forXsd); + obj1.save(scompFile); + //scomp saved out schema + SchemaCompiler.compile(params); + //use new api to get typesystem + XmlObject[] schemas = new XmlObject[]{obj1}; + SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null, + schemas, null, XmlBeans.getBuiltinTypeSystem(), null, xm_opts); + //use alternative api to get typesystem + SchemaTypeSystem altSts = XmlBeans.compileXsd(schemas, + XmlBeans.getBuiltinTypeSystem(), null); + + //save out sts for diff later + SchemaCodeGenerator.saveTypeSystem(apiSts, apiDirFile, null, null, + null); + SchemaCodeGenerator.saveTypeSystem(altSts, baseDirFile, null, null, + null); - /*public void test_diff_compilationMethods() throws IOException, - XmlException, Exception - { - - - //initialize the schema compiler - SchemaCompiler.Parameters params = new SchemaCompiler.Parameters(); - params.setXsdFiles(new File[]{scompFile}); - params.setSrcDir(scompDirFile); - params.setClassesDir(scompDirFile); - - //save out schema for use in scomp later - XmlObject obj1 = XmlObject.Factory.parse(forXsd); - obj1.save(scompFile); - - //scomp saved out schema - SchemaCompiler.compile(params); - - //use new api to get typesystem - XmlObject[] schemas = new XmlObject[]{obj1}; - SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null, - schemas, null, XmlBeans.getBuiltinTypeSystem(), null, xm_opts); - - //use alternative api to get typesystem - SchemaTypeSystem altSts = XmlBeans.compileXsd(schemas, - XmlBeans.getBuiltinTypeSystem(), null); - - //save out sts for diff later - SchemaCodeGenerator.saveTypeSystem(apiSts, apiDirFile, null, null, - null); - SchemaCodeGenerator.saveTypeSystem(altSts, baseDirFile, null, null, - null); - - //diff new api to old api - xm_errors = null; - xm_errors = new ArrayList(); - Diff.dirsAsTypeSystems(apiDirFile, baseDirFile, xm_errors); - if (xm_errors.size() >= 1) - throw new Exception("API STS ERRORS: " + xm_errors.toString()); - - //diff scomp sts to new api - xm_errors = null; - xm_errors = new ArrayList(); - Diff.dirsAsTypeSystems(apiDirFile, scompDirFile, xm_errors); - if (xm_errors.size() >= 1) - throw new Exception("API SCOMP ERRORS: " + xm_errors.toString()); - } */ + //diff new api to old api + xm_errors = null; + xm_errors = new ArrayList(); + Diff.dirsAsTypeSystems(apiDirFile, baseDirFile, xm_errors); + if (xm_errors.size() >= 1) + throw new Exception("API STS ERRORS: " + xm_errors.toString()); + //diff scomp sts to new api + xm_errors = null; + xm_errors = new ArrayList(); + Diff.dirsAsTypeSystems(apiDirFile, scompDirFile, xm_errors); + if (xm_errors.size() >= 1) + throw new Exception("API SCOMP ERRORS: " + xm_errors.toString()); + } +*/ } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org