Modified: xmlbeans/trunk/test/src/misc/detailed/LargeEnumTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/LargeEnumTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/misc/detailed/LargeEnumTest.java (original) +++ xmlbeans/trunk/test/src/misc/detailed/LargeEnumTest.java Fri Jan 18 23:08:44 2019 @@ -1,72 +1,59 @@ package misc.detailed; -import org.apache.xmlbeans.*; - -import java.util.*; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import junit.framework.TestSuite; -import junit.framework.TestCase; -import junit.framework.Test; -import junit.framework.Assert; +import org.apache.xmlbeans.SchemaType; +import org.apache.xmlbeans.XmlError; +import org.apache.xmlbeans.XmlOptions; +import org.apache.xmlbeans.XmlToken; +import org.junit.Test; import xmlbeans307.*; +import java.util.ArrayList; + +import static org.junit.Assert.*; + /** * This test was put together for: * http://issues.apache.org/jira/browse/XMLBEANS-307 * XMLBeans scomp throws error "code too large" */ -public class LargeEnumTest extends TestCase { - - public LargeEnumTest(String name) { - super(name); - } - - public static Test suite() { - return new TestSuite(LargeEnumTest.class); - } - +public class LargeEnumTest { /** * These are tests for a enumeration type - * - * @throws Exception */ + @Test public void testEnumCount_closeToMax() throws Exception { SchemaType mType = MaxAllowedEnumType.type; - assertTrue("Enumeration SchemaType was null", mType.getEnumerationValues() != null); - assertTrue("EnumerationValue was not 3665 as expected was" + mType.getEnumerationValues().length, - mType.getEnumerationValues().length == 3665); + assertNotNull("Enumeration SchemaType was null", mType.getEnumerationValues()); + assertEquals("EnumerationValue was not 3665 as expected was" + mType.getEnumerationValues().length, 3665, mType.getEnumerationValues().length); SchemaType mElem = MaxAllowedElementDocument.type; - assertTrue("Enumeration SchemaType was null", mElem.getEnumerationValues() == null); + assertNull("Enumeration SchemaType was null", mElem.getEnumerationValues()); // Test that the Java type associated to this is an enum type assertNotNull("This type does not correspond to a Java enumeration", mType.getStringEnumEntries()); } - + @Test public void testEnumCount_greaterThanMax() throws Exception { // TODO: verify if any xpath/xquery issues SchemaType mType = MoreThanAllowedEnumType.type; assertNotNull("Enumeration should be null as type should be base type " + mType.getEnumerationValues(), mType.getEnumerationValues()); - assertTrue("EnumerationValue was not 3678 as expected was " + mType.getEnumerationValues().length, - mType.getEnumerationValues().length == 3678); + assertEquals("EnumerationValue was not 3678 as expected was " + mType.getEnumerationValues().length, 3678, mType.getEnumerationValues().length); System.out.println("GET BASE TYPE: " + mType.getBaseType()); System.out.println("GET BASE TYPE: " + mType.getPrimitiveType()); - assertTrue("type should have been base type, was " + mType.getBaseType(), - mType.getBaseType().getBuiltinTypeCode() == XmlToken.type.getBuiltinTypeCode()); + assertEquals("type should have been base type, was " + mType.getBaseType(), mType.getBaseType().getBuiltinTypeCode(), XmlToken.type.getBuiltinTypeCode()); SchemaType mElem = GlobalMoreThanElementDocument.type; - assertTrue("Enumeration SchemaType was null", mElem.getBaseEnumType() == null); + assertNull("Enumeration SchemaType was null", mElem.getBaseEnumType()); // Test that the Java type associated to this is not an enum type assertNull("This type corresponds to a Java enumeration, even though it has too many enumeration values", mType.getStringEnumEntries()); } + @Test public void testEnumCount_validate_invalid_enum() throws Exception { MoreThanAllowedEnumType mType = MoreThanAllowedEnumType.Factory.newInstance(); @@ -81,13 +68,12 @@ public class LargeEnumTest extends TestC xErr[i] = (XmlError)errors.get(i); } - Assert.assertTrue("NO Expected Errors after validating enumType after set", errors.size() ==1 ); - Assert.assertTrue("Expected ERROR CODE was not as expected", - xErr[0].getErrorCode().compareTo("cvc-enumeration-valid") ==0 ); + assertEquals("NO Expected Errors after validating enumType after set", 1, errors.size()); + assertEquals("Expected ERROR CODE was not as expected", 0, xErr[0].getErrorCode().compareTo("cvc-enumeration-valid")); // string value '12345AAA' is not a valid enumeration value for MoreThanAllowedEnumType in } - + @Test public void test_MoreEnum_Operations() throws Exception { MoreThanAllowedEnumType mType = MoreThanAllowedEnumType.Factory.newInstance(); @@ -99,7 +85,7 @@ public class LargeEnumTest extends TestC for (int i = 0; i < errors.size(); i++) { System.out.println("ERROR: " + errors.get(i)); } - Assert.assertTrue("There were errors validating enumType after set", errors.size() == 0); + assertEquals("There were errors validating enumType after set", 0, errors.size()); GlobalMoreThanElementDocument mDoc = GlobalMoreThanElementDocument.Factory.newInstance(); mDoc.setGlobalMoreThanElement("AAA"); @@ -112,7 +98,7 @@ public class LargeEnumTest extends TestC System.out.println("ERROR: " + errors.get(i)); } - Assert.assertTrue("There were errors validating enumDoc after set", errors.size() == 0); + assertEquals("There were errors validating enumDoc after set", 0, errors.size()); MoreThanAllowedComplexType mcType = MoreThanAllowedComplexType.Factory.newInstance(); mcType.setComplexTypeMoreThanEnum("AAA"); @@ -124,7 +110,7 @@ public class LargeEnumTest extends TestC System.out.println("ERROR: " + errors.get(i)); } - Assert.assertTrue("There were errors validating complxType after set", errors.size() == 0); + assertEquals("There were errors validating complxType after set", 0, errors.size()); }
Modified: xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java (original) +++ xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java Fri Jan 18 23:08:44 2019 @@ -14,8 +14,8 @@ */ package misc.detailed; -import junit.framework.TestCase; - +import org.junit.Before; +import org.junit.Test; import tools.ant.*; import org.apache.tools.ant.Project; import org.apache.tools.ant.Target; @@ -29,24 +29,19 @@ import java.util.ArrayList; * Date: Feb 8, 2005 * Time: 11:30:24 AM */ -public class SampleRunner - extends TestCase -{ - +public class SampleRunner { - protected void setUp() - throws Exception - { + @Before + protected void setUp() throws Exception { proj = new Project(); proj.setName("Samples Task Tests"); XMLBEANS_HOME = proj.getBaseDir().getAbsolutePath(); samples = new ArrayList(); - runSampleTest = new SamplesBuildFileTest("Sample Ant Task Wrapper"); + runSampleTest = new SamplesBuildFileTest(); } - public void testSamples() - throws Exception - { + @Test + public void testSamples() throws Exception { loadSampleDirs(new File("./samples")); ArrayList exceptions = new ArrayList(); for (int i = 0; i < samples.size(); i++) @@ -97,21 +92,13 @@ public class SampleRunner } } - private class SamplesBuildFileTest - extends BuildFileTest - { - public SamplesBuildFileTest(String name) - { - super(name); - } - + private class SamplesBuildFileTest extends BuildFileTest { public void call_samples_task(String projectPath, String taskName) { configureProject(projectPath); Project proj = getProject(); proj.setProperty("xmlbeans.home", XMLBEANS_HOME); executeTarget(proj.getDefaultTarget()); - return; } public BuildException getAnyExceptions() Modified: xmlbeans/trunk/test/src/misc/detailed/SystemCacheClassloadersTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/SystemCacheClassloadersTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/misc/detailed/SystemCacheClassloadersTest.java (original) +++ xmlbeans/trunk/test/src/misc/detailed/SystemCacheClassloadersTest.java Fri Jan 18 23:08:44 2019 @@ -16,36 +16,27 @@ package misc.detailed; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.XmlBeans; -import org.apache.xmlbeans.impl.common.SystemCache; +import org.junit.Test; import javax.xml.namespace.QName; import java.io.File; import java.net.URL; import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; /* Test class loading using XmlBeans.getContextLoader() after changes to SystemCache.java (r240333) * Now a custom implementation of the SystemCache can be provided */ -public class SystemCacheClassloadersTest extends TestCase -{ - public SystemCacheClassloadersTest(String name) - { - super(name); - } - - public static Test suite() - { - return new TestSuite(SystemCacheClassloadersTest.class); - } - +public class SystemCacheClassloadersTest { - public static void testSystemCacheAndThreadLocal() + @Test + public void testSystemCacheAndThreadLocal() { Thread testThread = new SystemCacheThread("SchemTypeLoader Test Thread"); @@ -67,17 +58,11 @@ public class SystemCacheClassloadersTest } - - public static void main(String[] args) throws Throwable - { - testSystemCacheAndThreadLocal(); - } - public static class SystemCacheThread extends Thread { private String name; - public SystemCacheThread(String threadName) + SystemCacheThread(String threadName) { super(); name = threadName; @@ -100,7 +85,7 @@ public class SystemCacheClassloadersTest } } - public void testDefaultSystemCacheClassLoading() + void testDefaultSystemCacheClassLoading() { try { // create classloaders here @@ -109,81 +94,68 @@ public class SystemCacheClassloadersTest xbean_home = new File(".").getAbsolutePath(); } - File xbeanFile = new File(xbean_home + "/build/lib/xbean.jar"); - //File xbeanFile = new File(xbean_home + "/xbean.jar"); - if (!xbeanFile.exists()) { - throw new Exception("File " + xbeanFile + "does not exist"); - } - URL xbeanjar = xbeanFile.toURL(); + String[] domPaths = { + "build/classes", + "build/test-syscache/2/classes", + "build/test-syscache/2/generated-resources" + }; - File domFile = new File(xbean_home + "/build/test/lib/schemajars/dom.jar"); - if (!domFile.exists()) { - throw new Exception("File does not exist : " + domFile.toString()); + List<URL> domUrls = new ArrayList<URL>(); + for (String p : domPaths) { + domUrls.add(new File(xbean_home, p).toURI().toURL()); } - URL domjar = domFile.toURL(); - File miscFile = new File(xbean_home + "/build/test/lib/schemajars/misc.jar"); - if (!miscFile.exists()) { - throw new Exception("File does not exist"); - } - URL miscjar = miscFile.toURL(); + String[] miscPaths = { + "build/classes", + "build/test-syscache/1/classes", + "build/test-syscache/1/generated-resources" + }; - // dom.jar - URLClassLoader domTestsLoader = new URLClassLoader(new URL[]{xbeanjar, domjar}); - // misc.jar - URLClassLoader miscTestsLoader = new URLClassLoader(new URL[]{xbeanjar, miscjar}); - - System.out.println("Contents of domTestsLoader URL"); - URL[] urls = domTestsLoader.getURLs(); - for (int i = 0; i < urls.length; i++) { - System.out.println("URL:" + urls[i].toString()); + List<URL> miscUrls = new ArrayList<URL>(); + for (String p : miscPaths) { + miscUrls.add(new File(xbean_home, p).toURI().toURL()); } - System.out.println("------------------"); - System.out.println("Contents of miscTestsLoader URL"); - urls = miscTestsLoader.getURLs(); - for (int i = 0; i < urls.length; i++) { - System.out.println("URL:" + urls[i].toString()); - } - System.out.println("------------------"); + URLClassLoader domCL = new URLClassLoader(domUrls.toArray(new URL[0])); + URLClassLoader miscCL = new URLClassLoader(miscUrls.toArray(new URL[0])); // define the Qnames of types to look for in the compiled xbeans after switching the class loaders - QName domTypeQName = new QName("http://xbean/dom/ComplexTypeTest", "elementT"); - QName miscPersonTypeQName = new QName("http://xbean/misc/SyscacheTests", "personType", "test"); + QName domTypeQName = new QName("http://xbean/misc/SyscacheTests2", "elementT"); + QName miscPersonTypeQName = new QName("http://xbean/misc/SyscacheTests1", "personType", "test"); - setContextClassLoader(domTestsLoader); + setContextClassLoader(domCL); //System.out.println("Testing elementT Type From dom tests complexTypeTest.xsd"); SchemaTypeLoader initialDomLoader = XmlBeans.getContextTypeLoader(); SchemaType domSchemaType = initialDomLoader.findType(domTypeQName); assertNotNull(domSchemaType); - assertEquals("Invalid Type!", domSchemaType.getFullJavaImplName(), "xbean.dom.complexTypeTest.impl.ElementTImpl"); + assertEquals("Invalid Type!", domSchemaType.getFullJavaImplName(), "xbean.misc.syscacheTests2.impl.ElementTImpl"); // -ve test, look for the person type from cases\misc\syscachetest.xsd SchemaType personTypeFromMiscTests = initialDomLoader.findType(miscPersonTypeQName); assertNull(personTypeFromMiscTests); // switch the SchemaTypeLoader - setContextClassLoader(miscTestsLoader); + setContextClassLoader(miscCL); //System.out.println("Testing Person Type From misc syscachetests.xsd"); SchemaTypeLoader initialMiscSchemaLoader = XmlBeans.getContextTypeLoader(); SchemaType miscPersonType = initialMiscSchemaLoader.findType(miscPersonTypeQName); - assertTrue(miscPersonType != null); - assertEquals("Invalid Type!", miscPersonType.getFullJavaImplName(), "xbean.misc.syscacheTests.impl.PersonTypeImpl"); + assertNotNull(miscPersonType); + assertEquals("Invalid Type!", miscPersonType.getFullJavaImplName(), "xbean.misc.syscacheTests1.impl.PersonTypeImpl"); // -ve test SchemaType personTypeFromMisc = initialMiscSchemaLoader.findType(domTypeQName); assertNull(personTypeFromMisc); // reload the original loader - setContextClassLoader(domTestsLoader); + setContextClassLoader(domCL); SchemaTypeLoader secondDomLoader = XmlBeans.getContextTypeLoader(); assertNotNull(secondDomLoader.findType(domTypeQName)); - assertTrue("SchemaTypeLoaders expected to be equal", initialDomLoader == secondDomLoader); + assertSame("SchemaTypeLoaders expected to be equal", initialDomLoader, secondDomLoader); - setContextClassLoader(miscTestsLoader); + setContextClassLoader(miscCL); SchemaTypeLoader secondMiscLoader = XmlBeans.getContextTypeLoader(); - assertTrue("SchemaTypeLoaders expected to be equal", initialMiscSchemaLoader == secondMiscLoader); + assertSame("SchemaTypeLoaders expected to be equal", initialMiscSchemaLoader, secondMiscLoader); } catch (Throwable t) { Modified: xmlbeans/trunk/test/src/misc/detailed/SystemCacheTestImpl.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/SystemCacheTestImpl.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/misc/detailed/SystemCacheTestImpl.java (original) +++ xmlbeans/trunk/test/src/misc/detailed/SystemCacheTestImpl.java Fri Jan 18 23:08:44 2019 @@ -21,25 +21,20 @@ import org.apache.xmlbeans.impl.common.S // This class provides an alternative implementation to the SystemCache that essentially does nothing special // Used in testing the SystemCache.set() API to test an alternate implementation being picked up. Used in // SystemCacheTests -public class SystemCacheTestImpl extends SystemCache -{ - private static int _accessed; +public class SystemCacheTestImpl extends SystemCache { + private static int _accessed; - public SystemCacheTestImpl() - { - System.out.println("constructor SystemCacheTestImpl"); - _accessed++; - } + public SystemCacheTestImpl() { + _accessed++; + } - public String testCacheImpl() - { - return (this.getClass().getName()); - } + public String testCacheImpl() { + return (this.getClass().getName()); + } - public static final int getAccessed() - { - return _accessed; - } + public static final int getAccessed() { + return _accessed; + } } Modified: xmlbeans/trunk/test/src/misc/detailed/SystemCacheTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/SystemCacheTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/misc/detailed/SystemCacheTests.java (original) +++ xmlbeans/trunk/test/src/misc/detailed/SystemCacheTests.java Fri Jan 18 23:08:44 2019 @@ -16,57 +16,28 @@ package misc.detailed; -import junit.framework.TestCase; -import common.Common; - -import java.util.Random; -import java.util.Collection; -import java.util.ArrayList; -import java.util.Iterator; -import java.io.File; -import java.net.URL; -import java.net.URLClassLoader; -import java.lang.reflect.Method; - -import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.common.SystemCache; +import org.junit.Test; -import javax.xml.namespace.QName; +import static org.junit.Assert.assertEquals; -public class SystemCacheTests extends TestCase -{ - public void testSystemCacheImplFromAPITest() throws Throwable - { - try - { - // store the default SystemCache implementation before switch - SystemCache defaultImpl = SystemCache.get(); - - //assertEquals("org.apache.xmlbeans.impl.common.SystemCache",defaultImpl.getClass().getName()); - // The expected default impl does not get picked up as the test is not run from a single jvm - // when run from the test infrastructure. Hence compare against the actual impl that gets picked up - // The assert above commented out will hold good if this test is invoked as follows: - // ant run.junit -Dtest.area=misc -Dtest.spec=misc.detailed.SystemCacheTests - assertEquals("org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$SchemaTypeLoaderCache",defaultImpl.getClass().getName()); - - // switch the Impl to the test Impl - SystemCacheTestImpl testImpl = new SystemCacheTestImpl(); - SystemCache.set(testImpl); - assertEquals("misc.detailed.SystemCacheTestImpl",testImpl.getClass().getName()); - assertEquals(testImpl.getAccessed(), 1); - - // switch back to default impl - SystemCache.set(defaultImpl); - System.out.println("Third 1:" + defaultImpl.getClass().getName()); - System.out.println("Third 2:" + defaultImpl.getClass().getName()); - //assertEquals("org.apache.xmlbeans.impl.common.SystemCache",defaultImpl.getClass().getName()); - assertEquals("org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$SchemaTypeLoaderCache",defaultImpl.getClass().getName()); - } - catch(ExceptionInInitializerError err) - { - System.out.println(err.getMessage()); - throw new Exception("File does not exist"); - } +public class SystemCacheTests { + @Test + public void testSystemCacheImplFromAPITest() throws Throwable { + // store the default SystemCache implementation before switch + SystemCache defaultImpl = SystemCache.get(); + + assertEquals("org.apache.xmlbeans.impl.common.SystemCache", defaultImpl.getClass().getName()); + + // switch the Impl to the test Impl + SystemCacheTestImpl testImpl = new SystemCacheTestImpl(); + SystemCache.set(testImpl); + assertEquals("misc.detailed.SystemCacheTestImpl", testImpl.getClass().getName()); + assertEquals(testImpl.getAccessed(), 1); + + // switch back to default impl + SystemCache.set(defaultImpl); + assertEquals("org.apache.xmlbeans.impl.common.SystemCache", defaultImpl.getClass().getName()); } } Modified: xmlbeans/trunk/test/src/misc/detailed/XMLStreamReaderTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/XMLStreamReaderTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/misc/detailed/XMLStreamReaderTest.java (original) +++ xmlbeans/trunk/test/src/misc/detailed/XMLStreamReaderTest.java Fri Jan 18 23:08:44 2019 @@ -14,21 +14,19 @@ */ package misc.detailed; -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; +import org.junit.Test; -import junit.framework.TestCase; +import javax.xml.stream.XMLStreamReader; + +import static org.junit.Assert.assertTrue; /** * Adapted from testcase submitted by Brian Bonner for JIRA issue * XMLBEANS-222, based on comments by Cezar Andrei. */ -public class XMLStreamReaderTest extends TestCase { +public class XMLStreamReaderTest { private static final String soapMsg = "<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" @@ -41,7 +39,7 @@ public class XMLStreamReaderTest extends + "</PriceandAvailabilityResponse>" + "</SOAP:Body>" + "</SOAP:Envelope>"; - + @Test public void testXmlStreamReader1() throws Exception { XmlObject object = XmlObject.Factory.parse(soapMsg); @@ -66,7 +64,8 @@ public class XMLStreamReaderTest extends } assertTrue("xsi namespace is not found", foundXsiNamespace); } - + + @Test public void testXmlStreamReader2() throws Exception { XmlObject object = XmlObject.Factory.parse(soapMsg); Modified: xmlbeans/trunk/test/src/random/checkin/RandomTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/random/checkin/RandomTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/random/checkin/RandomTest.java (original) +++ xmlbeans/trunk/test/src/random/checkin/RandomTest.java Fri Jan 18 23:08:44 2019 @@ -16,27 +16,30 @@ package random.checkin; import org.apache.xmlbeans.impl.tool.CommandLine; +import org.junit.Before; +import org.junit.Test; +import random.common.Random; import java.util.Arrays; -import random.common.Random; -import junit.framework.TestCase; - -public class RandomTest extends TestCase { +public class RandomTest { long seed; int iterations; int threads; int docs; + @Before public void setUp() { seed = System.currentTimeMillis(); iterations = Integer.MAX_VALUE; threads = 1; docs = 10; } - public static void testNoQuery() throws Exception { + + @Test + public void testNoQuery() { String[] args = new String[]{"-seed", "0", "-i", "20", "-noquery"}; CommandLine cl = new CommandLine(args, Arrays.asList(new String[]{"?", "help", "readonly", "noquery", "nosave"}), Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/AttrGroupTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/AttrGroupTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/AttrGroupTest.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/AttrGroupTest.java Fri Jan 18 23:08:44 2019 @@ -15,21 +15,21 @@ package scomp.attributes.detailed; +import org.apache.xmlbeans.*; +import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.attribute.attributeGroup.AttGroupEltDocument; import xbean.scomp.attribute.attributeGroup.GlobalT; -import org.apache.xmlbeans.*; import javax.xml.namespace.QName; import java.math.BigDecimal; import java.math.BigInteger; -/** - * - * - * - */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class AttrGroupTest extends BaseCase { + @Test public void testAttributeGroup() throws Throwable { AttGroupEltDocument doc = AttGroupEltDocument.Factory.newInstance(); GlobalT elt = doc.addNewAttGroupElt(); @@ -70,7 +70,5 @@ public class AttrGroupTest extends BaseC showErrors(); throw t; } - - } } Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrDefault.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrDefault.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrDefault.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrDefault.java Fri Jan 18 23:08:44 2019 @@ -14,21 +14,21 @@ */ package scomp.attributes.detailed; +import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlException; +import org.junit.Test; +import scomp.common.BaseCase; import xbean.scomp.attribute.globalAttrDefault.GlobalAttrDefaultDocDocument; import xbean.scomp.attribute.globalAttrDefault.GlobalAttrDefaultT; -import scomp.common.BaseCase; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlErrorCodes; -/** - * - * - * - */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class GlobalAttrDefault extends BaseCase { /** * If value is missing default should appear */ + @Test public void testMissing() { GlobalAttrDefaultT testDoc = GlobalAttrDefaultDocDocument.Factory.newInstance() @@ -39,6 +39,7 @@ public class GlobalAttrDefault extends B /** * Test val preservation */ + @Test public void testPresent() { GlobalAttrDefaultT testDoc = GlobalAttrDefaultDocDocument.Factory.newInstance() @@ -50,20 +51,19 @@ public class GlobalAttrDefault extends B /** * Test empty string: should be preserved */ + @Test public void testPresentEmpty() throws Throwable { GlobalAttrDefaultT testDoc = - GlobalAttrDefaultDocDocument.Factory.parse("<pre:GlobalAttrDefaultDoc" + + GlobalAttrDefaultDocDocument.Factory.parse("<pre:GlobalAttrDefaultDoc" + " xmlns:pre=\"http://xbean/scomp/attribute/GlobalAttrDefault\" " + " pre:testattribute=\"\"/>").getGlobalAttrDefaultDoc(); assertEquals("", testDoc.getTestattribute()); try { - assertTrue(testDoc.validate(validateOptions)); - } - catch (Throwable t) { - showErrors(); - throw t; - } - + assertTrue(testDoc.validate(validateOptions)); + } catch (Throwable t) { + showErrors(); + throw t; + } } Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrFixed.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrFixed.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrFixed.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrFixed.java Fri Jan 18 23:08:44 2019 @@ -16,29 +16,24 @@ package scomp.attributes.detailed; +import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlException; +import org.junit.Test; +import scomp.common.BaseCase; import xbean.scomp.attribute.globalAttrFixed.GlobalAttrFixedDocDocument; -import xbean.scomp.attribute.globalAttrFixed.TestattributeStrAttribute; -import xbean.scomp.attribute.globalAttrFixed.TestattributeIntAttribute; import xbean.scomp.attribute.globalAttrFixed.GlobalAttrFixedT; -import scomp.common.BaseCase; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.XmlError; -import org.apache.xmlbeans.XmlErrorCodes; import java.math.BigInteger; -import java.util.ArrayList; -/** - * - * - * - */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class GlobalAttrFixed extends BaseCase { /** * Missing OK */ + @Test public void testValidMissing() throws Exception { GlobalAttrFixedT testDoc = GlobalAttrFixedDocDocument.Factory.parse("<pre:GlobalAttrFixedDoc" + @@ -48,6 +43,7 @@ public class GlobalAttrFixed extends Bas } + @Test public void testBothValid() throws Throwable { GlobalAttrFixedT testDoc = GlobalAttrFixedDocDocument.Factory.parse("<pre:GlobalAttrFixedDoc" + @@ -68,6 +64,7 @@ public class GlobalAttrFixed extends Bas /** * value does not match fixed */ + @Test public void testStringInvalidSpace() throws Exception { GlobalAttrFixedT testAtt = GlobalAttrFixedDocDocument.Factory.parse("<pre:GlobalAttrFixedDoc" + @@ -85,6 +82,7 @@ public class GlobalAttrFixed extends Bas //catch XmlExceptionHere; } + @Test public void testStringInvalidValue() throws Exception { GlobalAttrFixedT testAtt = GlobalAttrFixedDocDocument.Factory.parse("<pre:GlobalAttrFixedDoc" + @@ -97,13 +95,12 @@ public class GlobalAttrFixed extends Bas assertEquals(1, errorList.size()); showErrors(); assertTrue(compareErrorCodes(errExpected)); - - } /** * Test empty string: should be preserved */ + @Test public void testIntInvalidType() throws XmlException { GlobalAttrFixedT testAtt = GlobalAttrFixedDocDocument.Factory.parse("<pre:GlobalAttrFixedDoc" + @@ -117,10 +114,9 @@ public class GlobalAttrFixed extends Bas XmlErrorCodes.DECIMAL }; assertTrue(compareErrorCodes(errExpected)); - - } + @Test public void testIntInvalidValue() throws XmlException { GlobalAttrFixedT testAtt = GlobalAttrFixedDocDocument.Factory.parse("<pre:GlobalAttrFixedDoc" + @@ -136,6 +132,7 @@ public class GlobalAttrFixed extends Bas } + @Test public void testIntValidValue() throws Throwable { GlobalAttrFixedT testAtt = GlobalAttrFixedDocDocument.Factory.parse("<pre:GlobalAttrFixedDoc" + @@ -151,7 +148,8 @@ public class GlobalAttrFixed extends Bas //catch XmlExceptionHere; } - public void testSetValue() throws XmlException { + @Test + public void testSetValue() { GlobalAttrFixedDocDocument testAtt = GlobalAttrFixedDocDocument.Factory.newInstance(); GlobalAttrFixedT testDoc = testAtt.addNewGlobalAttrFixedDoc(); @@ -164,7 +162,5 @@ public class GlobalAttrFixed extends Bas String[] errExpected = new String[]{ XmlErrorCodes.ATTR_LOCALLY_VALID$FIXED}; assertTrue(compareErrorCodes(errExpected)); - } - } Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrIdTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrIdTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrIdTest.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrIdTest.java Fri Jan 18 23:08:44 2019 @@ -14,6 +14,7 @@ */ package scomp.attributes.detailed; +import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.attribute.globalAttrId.GlobalAttrIdT; import xbean.scomp.attribute.globalAttrId.GlobalAttrIdDocument; @@ -22,12 +23,10 @@ import org.apache.xmlbeans.XmlString; import javax.xml.namespace.QName; -/** - * - * - * - */ +import static org.junit.Assert.assertTrue; + public class GlobalAttrIdTest extends BaseCase { + @Test public void testId() throws Throwable { GlobalAttrIdDocument testDoc = GlobalAttrIdDocument.Factory.newInstance(); @@ -43,8 +42,5 @@ public class GlobalAttrIdTest extends Ba showErrors(); throw t; } - } - - } Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrType.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrType.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrType.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/GlobalAttrType.java Fri Jan 18 23:08:44 2019 @@ -14,6 +14,7 @@ */ package scomp.attributes.detailed; +import org.junit.Test; import scomp.common.BaseCase; import org.apache.xmlbeans.*; import xbean.scomp.attribute.globalAttrType.GlobalAttrTypeDocDocument; @@ -22,12 +23,11 @@ import xbean.scomp.attribute.globalAttrT import java.util.ArrayList; import java.math.BigInteger; -/** - * - * - * - */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class GlobalAttrType extends BaseCase { + @Test public void testAllValid() throws Throwable { GlobalAttrTypeT testDoc = GlobalAttrTypeDocDocument.Factory.parse("<pre:GlobalAttrTypeDoc" + @@ -52,6 +52,7 @@ public class GlobalAttrType extends Base /** * This should awlays be valid */ + @Test public void testAnyType() throws Throwable { GlobalAttrTypeT testDoc = GlobalAttrTypeDocDocument.Factory.parse("<pre:GlobalAttrTypeDoc" + @@ -80,8 +81,8 @@ public class GlobalAttrType extends Base testDoc.setAttAnyType(ival); - // assertEquals(BigInteger.ZERO,testDoc.getAttAnyType().changeType(XmlInteger.type)); -assertEquals(BigInteger.ZERO.toString(), + // assertEquals(BigInteger.ZERO,testDoc.getAttAnyType().changeType(XmlInteger.type)); + assertEquals(BigInteger.ZERO.toString(), testDoc.getAttAnyType().getStringValue()); try { @@ -116,6 +117,7 @@ assertEquals(BigInteger.ZERO.toString(), } } + @Test public void testAnonType() throws Throwable { GlobalAttrTypeT testDoc = GlobalAttrTypeDocDocument.Factory @@ -134,7 +136,7 @@ assertEquals(BigInteger.ZERO.toString(), assertEquals(1, testDoc.getAttAnonymous().intValue()); testDoc.setAttAnonymous( BigInteger.ZERO ); - assertTrue( 0 == testDoc.getAttAnonymous().intValue()); + assertEquals(0, testDoc.getAttAnonymous().intValue()); try { assertTrue(testDoc.validate(validateOptions)); } Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrFixedDefault.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrFixedDefault.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrFixedDefault.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrFixedDefault.java Fri Jan 18 23:08:44 2019 @@ -14,16 +14,15 @@ */ package scomp.attributes.detailed; +import org.apache.xmlbeans.XmlErrorCodes; +import org.junit.Test; import scomp.common.BaseCase; -import xbean.scomp.attribute.localAttrFixedDefault.LocalAttrFixedDefaultT; import xbean.scomp.attribute.localAttrFixedDefault.LocalAttrFixedDefaultDocument; -import org.apache.xmlbeans.XmlErrorCodes; +import xbean.scomp.attribute.localAttrFixedDefault.LocalAttrFixedDefaultT; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -/** - * - * - * - */ public class LocalAttrFixedDefault extends BaseCase { /** * Verify that a local attribute can add a fixed value but can not overwrite @@ -32,27 +31,27 @@ public class LocalAttrFixedDefault exten */ //ensure default val is shadowed locally //fixed can not be... - public void testDefault() throws Throwable{ - LocalAttrFixedDefaultT testDoc = + @Test + public void testDefault() throws Throwable { + LocalAttrFixedDefaultT testDoc = LocalAttrFixedDefaultDocument.Factory.newInstance() - .addNewLocalAttrFixedDefault(); - assertTrue(testDoc.validate()); - assertEquals(2,testDoc.getAttDefault().intValue()); + .addNewLocalAttrFixedDefault(); + assertTrue(testDoc.validate()); + assertEquals(2, testDoc.getAttDefault().intValue()); //second fixed value is ignored testDoc.setAttFixed("NEWXBeanAttrStr"); assertTrue(!testDoc.validate(validateOptions)); showErrors(); - String[] errExpected = new String[]{ - XmlErrorCodes.ATTR_LOCALLY_VALID$FIXED - }; - assertTrue(compareErrorCodes(errExpected)); + String[] errExpected = new String[]{ + XmlErrorCodes.ATTR_LOCALLY_VALID$FIXED + }; + assertTrue(compareErrorCodes(errExpected)); testDoc.setAttFixed("XBeanAttrStr"); - try { + try { assertTrue(testDoc.validate(validateOptions)); - } - catch (Throwable t) { + } catch (Throwable t) { showErrors(); throw t; } Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrForm.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrForm.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrForm.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrForm.java Fri Jan 18 23:08:44 2019 @@ -14,6 +14,7 @@ */ package scomp.attributes.detailed; +import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.namespace.attributeFormDefault.AttributeUnqualifiedDocument; @@ -21,17 +22,14 @@ import javax.xml.namespace.QName; import org.apache.xmlbeans.XmlErrorCodes; -/** - * - * - * - */ +import static org.junit.Assert.assertTrue; + public class LocalAttrForm extends BaseCase{ /** * attrFormDefault is "qualified", overwrite locally to "unqualified" - * @throws Throwable */ + @Test public void testRun() throws Throwable{ String input="<ns:AttributeUnqualified " + Modified: xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrUse.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrUse.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrUse.java (original) +++ xmlbeans/trunk/test/src/scomp/attributes/detailed/LocalAttrUse.java Fri Jan 18 23:08:44 2019 @@ -15,30 +15,27 @@ package scomp.attributes.detailed; -import scomp.common.BaseCase; -import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlErrorCodes; - +import org.apache.xmlbeans.XmlException; +import org.junit.Test; +import scomp.common.BaseCase; import xbean.scomp.attribute.localAttrUse.LocalAttrUseDocDocument; import xbean.scomp.attribute.localAttrUse.LocalAttrUseT; import xbean.scomp.derivation.attributeUseProhibited.AttrProhibitedEltDocument; import xbean.scomp.derivation.attributeUseProhibited.AttrUseProhibited; -import java.util.Calendar; import java.math.BigInteger; +import java.util.Calendar; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -/** - * - * - * - */ public class LocalAttrUse extends BaseCase { /** * Default use of an attribute should be optional * Optional attributes can be missing - * - * @throws XmlException */ + @Test public void testDefaultOptional() throws Throwable { //figure out the deal w/ namespaces here... LocalAttrUseT testDoc = @@ -60,9 +57,8 @@ public class LocalAttrUse extends BaseCa /** * test that an optional attr is not set before it is set - * - * @throws XmlException */ + @Test public void testOptional() throws Throwable { LocalAttrUseDocDocument testDoc = LocalAttrUseDocDocument.Factory.newInstance(); @@ -74,9 +70,8 @@ public class LocalAttrUse extends BaseCa /** * test that an optional attr is not set before it is set - * - * @throws XmlException */ + @Test public void testOptionalParse() throws Throwable { LocalAttrUseT testDoc = LocalAttrUseDocDocument.Factory.parse("<pre:LocalAttrUseDoc" + @@ -92,6 +87,7 @@ public class LocalAttrUse extends BaseCa } + @Test public void testRequired() throws XmlException { //required attRequired is missing LocalAttrUseT testDoc = @@ -120,9 +116,8 @@ public class LocalAttrUse extends BaseCa /** * can not overwrite an existing value - * - * @throws XmlException */ + @Test public void testRequiredFixed() throws XmlException { LocalAttrUseT testDoc = LocalAttrUseDocDocument.Factory.parse("<foo:LocalAttrUseDoc" + @@ -143,6 +138,7 @@ public class LocalAttrUse extends BaseCa } + @Test public void testRequiredDefault() throws XmlException { LocalAttrUseT testDoc = LocalAttrUseDocDocument.Factory.parse("<pre:LocalAttrUseDoc" + @@ -164,7 +160,7 @@ public class LocalAttrUse extends BaseCa } - + @Test public void testUseProhibited() throws Throwable { AttrProhibitedEltDocument doc = AttrProhibitedEltDocument.Factory.newInstance(); Modified: xmlbeans/trunk/test/src/scomp/common/BaseCase.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/common/BaseCase.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/common/BaseCase.java (original) +++ xmlbeans/trunk/test/src/scomp/common/BaseCase.java Fri Jan 18 23:08:44 2019 @@ -14,25 +14,19 @@ */ package scomp.common; -import junit.framework.TestCase; -import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.XmlError; -import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlOptions; +import org.junit.Before; import java.util.ArrayList; -import java.util.Collection; -/** - * - * - * - */ -public class BaseCase extends TestCase { +public class BaseCase { protected boolean bVerbose = true; protected XmlOptions validateOptions; protected ArrayList errorList; + @Before public void setUp() { validateOptions = new XmlOptions(); errorList = new ArrayList(); Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/AnonymousTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/AnonymousTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/AnonymousTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/AnonymousTest.java Fri Jan 18 23:08:44 2019 @@ -15,35 +15,26 @@ package scomp.contentType.complex.detailed; -import xbean.scomp.contentType.anonymous.AnonymousEltDocument.*; -import xbean.scomp.contentType.anonymous.AnonymousMixedEltDocument.*; - -import java.math.BigInteger; - -import org.apache.xmlbeans.XmlInteger; import org.apache.xmlbeans.XmlCursor; +import org.apache.xmlbeans.XmlInteger; +import org.junit.Test; import scomp.common.BaseCase; +import xbean.scomp.contentType.anonymous.AnonymousEltDocument.AnonymousElt; +import xbean.scomp.contentType.anonymous.AnonymousMixedEltDocument.AnonymousMixedElt; -/** - * - * - * - */ +import java.math.BigInteger; + +import static org.junit.Assert.*; /** * testing anonymous complex types */ -public class AnonymousTest - extends BaseCase -{ - - - public void testSimpleAnonymous() - throws Throwable - { +public class AnonymousTest extends BaseCase { + @Test + public void testSimpleAnonymous() throws Throwable { AnonymousElt testElt = AnonymousElt.Factory.newInstance(); - assertEquals(null, testElt.getChild1()); - assertEquals(null, testElt.xgetChild1()); + assertNull(testElt.getChild1()); + assertNull(testElt.xgetChild1()); XmlInteger ival = XmlInteger.Factory.newInstance(); testElt.xsetChild1(ival); testElt.setChild2(new BigInteger("5")); @@ -70,12 +61,11 @@ public class AnonymousTest } } - public void testMixedAnonymous() - throws Throwable - { + @Test + public void testMixedAnonymous() throws Throwable { AnonymousMixedElt testElt = AnonymousMixedElt.Factory.newInstance(); - assertEquals(null, testElt.getChild1()); - assertEquals(null, testElt.xgetChild1()); + assertNull(testElt.getChild1()); + assertNull(testElt.xgetChild1()); testElt.setChild2(new BigInteger("5")); assertEquals(5, testElt.getChild2().intValue()); assertTrue(XmlInteger.Factory.parse("<xml-fragment>5</xml-fragment>") Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ComplexContentTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ComplexContentTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ComplexContentTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ComplexContentTest.java Fri Jan 18 23:08:44 2019 @@ -15,30 +15,24 @@ package scomp.contentType.complex.detailed; +import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.XmlOptions; +import org.junit.Test; import scomp.common.BaseCase; -import org.apache.xmlbeans.*; import java.util.ArrayList; -import java.util.List; import java.util.Iterator; -import java.util.Collection; +import java.util.List; -import junit.framework.Assert; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -/** - * - * - * - */ public class ComplexContentTest extends BaseCase { - //TODO: this should be a detailed - // test on a complex elt w/ annotations and other such - public void testRun() { - fail("Implement me"); - } // complex types with simple content whose content is declared via an inline <simpleType> // Issue fixed with Svn revision 165352 + @Test public void testSimpleContentDerivation() { String sInputXsd = "<?xml version=\"1.0\"?>\n" + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" + @@ -69,7 +63,7 @@ public class ComplexContentTest extends } catch (XmlException xme) { xme.printStackTrace(); - Assert.fail("XmlException thrown when compiling schema"); + fail("XmlException thrown when compiling schema"); } // check for errors @@ -77,7 +71,7 @@ public class ComplexContentTest extends System.out.println("Xsd Compilation Errors : " + iterator.next()); } if (!errors.isEmpty()) { - Assert.fail("Errors found when compiling schema"); + fail("Errors found when compiling schema"); } } } Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ElementOnlyContentTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ElementOnlyContentTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ElementOnlyContentTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/ElementOnlyContentTest.java Fri Jan 18 23:08:44 2019 @@ -15,31 +15,25 @@ package scomp.contentType.complex.detailed; -import junit.framework.TestCase; - -import java.math.BigInteger; - -import org.apache.xmlbeans.XmlInteger; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlErrorCodes; - -import xbean.scomp.contentType.complexTypeTest.EltTypeDocument; -import xbean.scomp.contentType.complexTypeTest.ElementT; +import org.apache.xmlbeans.XmlInteger; +import org.junit.Test; import scomp.common.BaseCase; +import xbean.scomp.contentType.complexTypeTest.ElementT; +import xbean.scomp.contentType.complexTypeTest.EltTypeDocument; + +import java.math.BigInteger; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -/** - * - * - * - */ public class ElementOnlyContentTest extends BaseCase { /** * Element only content - * - * @throws Throwable */ - + @Test public void testElementOnly() throws Throwable { EltTypeDocument doc = EltTypeDocument.Factory.newInstance(); ElementT testElt @@ -72,6 +66,7 @@ public class ElementOnlyContentTest exte /** * Mixed content is invalid for element only types */ + @Test public void testInvalidContent() { EltTypeDocument doc = EltTypeDocument.Factory.newInstance(); ElementT testElt Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/EmptyContentTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/EmptyContentTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/EmptyContentTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/EmptyContentTest.java Fri Jan 18 23:08:44 2019 @@ -14,21 +14,19 @@ */ package scomp.contentType.complex.detailed; -import xbean.scomp.contentType.complexTypeTest.EmptyTypeDocument; -import xbean.scomp.contentType.complexTypeTest.EmptyT; -import xbean.scomp.contentType.complexTypeTest.EmptyMixedTypeDocument; import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlString; -import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlString; +import org.junit.Test; import scomp.common.BaseCase; +import xbean.scomp.contentType.complexTypeTest.EmptyT; +import xbean.scomp.contentType.complexTypeTest.EmptyTypeDocument; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -/** - * - * - * - */ public class EmptyContentTest extends BaseCase { + @Test public void testIllegalContent() { EmptyTypeDocument doc = EmptyTypeDocument.Factory.newInstance(); EmptyT elt = doc.addNewEmptyType(); @@ -43,11 +41,12 @@ public class EmptyContentTest extends Ba String[] errExpected = new String[]{ XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$ELEMENT_NOT_ALLOWED }; - assertTrue(compareErrorCodes(errExpected)); + assertTrue(compareErrorCodes(errExpected)); } - public void testLegalContent() throws XmlException { + @Test + public void testLegalContent() { EmptyTypeDocument doc = EmptyTypeDocument.Factory.newInstance(); EmptyT elt = doc.addNewEmptyType(); assertTrue(!elt.isSetEmptyAttr()); Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/MixedContentTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/MixedContentTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/MixedContentTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/MixedContentTest.java Fri Jan 18 23:08:44 2019 @@ -14,31 +14,29 @@ */ package scomp.contentType.complex.detailed; -import junit.framework.TestCase; -import xbean.scomp.contentType.complexTypeTest.MixedTypeDocument; -import xbean.scomp.contentType.complexTypeTest.MixedT; -import xbean.scomp.contentType.complexTypeTest.MixedFixedEltDocument; - -import java.math.BigInteger; - -import org.apache.xmlbeans.XmlInteger; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlErrorCodes; import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlInteger; +import org.junit.Before; +import org.junit.Test; import scomp.common.BaseCase; +import xbean.scomp.contentType.complexTypeTest.MixedFixedEltDocument; +import xbean.scomp.contentType.complexTypeTest.MixedT; +import xbean.scomp.contentType.complexTypeTest.MixedTypeDocument; + +import java.math.BigInteger; + +import static org.junit.Assert.*; -/** - * - * - * - */ public class MixedContentTest extends BaseCase { + @Test public void testElementsOnly() throws Throwable { testElt = doc.addNewMixedType(); - assertEquals(null, testElt.getChild1()); - assertEquals(null, testElt.xgetChild1()); + assertNull(testElt.getChild1()); + assertNull(testElt.xgetChild1()); testElt.setChild2(new BigInteger("5")); testElt.setChild3(new BigInteger("1")); testElt.setChild1(new BigInteger("0")); @@ -65,13 +63,13 @@ public class MixedContentTest extends Ba * mixed model in XML 1.0. Under the XML Schema mixed model, the order and * number of child elements appearing in an instance must agree with the * order and number of child elements specified in the model - * @throws Throwable */ - public void testTextOnly() throws Throwable { + @Test + public void testTextOnly() { testElt = doc.addNewMixedType(); - assertEquals(null, testElt.getChild1()); - assertEquals(null, testElt.xgetChild1()); + assertNull(testElt.getChild1()); + assertNull(testElt.xgetChild1()); XmlCursor cur = testElt.newCursor(); cur.insertChars("Random mixed content"); assertTrue( !testElt.validate(validateOptions) ); @@ -84,10 +82,11 @@ public class MixedContentTest extends Ba } + @Test public void testMixed() throws Throwable { testElt = doc.addNewMixedType(); - assertEquals(null, testElt.getChild1()); - assertEquals(null, testElt.xgetChild1()); + assertNull(testElt.getChild1()); + assertNull(testElt.xgetChild1()); testElt.setChild2(new BigInteger("5")); testElt.setChild3(new BigInteger("1")); testElt.setChild1(new BigInteger("0")); @@ -119,6 +118,8 @@ public class MixedContentTest extends Ba "<child1>0</child1>Random mixed content1<child2>5</child2>" + "<child3>1</child3></xml-fragment>",testElt.xmlText() ); } + + @Test public void testInsertDelete() throws Throwable{ testElt = doc.addNewMixedType(); testElt.setChild2(new BigInteger("5")); @@ -158,14 +159,14 @@ public class MixedContentTest extends Ba } - /** - * see CR related to CR194159: - -clause 5.2.2.1 of - "Validation Rule: Element Locally Valid (Element)" says - if there is a fixed value constraint, the element may not have element children. - * @throws XmlException - */ + /** + * see CR related to CR194159: + * <p> + * clause 5.2.2.1 of + * "Validation Rule: Element Locally Valid (Element)" says + * if there is a fixed value constraint, the element may not have element children. + */ + @Test public void testMixedFixed() throws XmlException{ MixedFixedEltDocument doc= MixedFixedEltDocument.Factory @@ -180,11 +181,12 @@ clause 5.2.2.1 of assertTrue(compareErrorCodes(expected)); } + + @Before public void setUp() { doc = MixedTypeDocument.Factory.newInstance(); - testElt - = doc.getMixedType(); - assertEquals(null, testElt); + testElt = doc.getMixedType(); + assertNull(testElt); super.setUp(); } Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/NamedTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/NamedTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/NamedTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/detailed/NamedTest.java Fri Jan 18 23:08:44 2019 @@ -14,34 +14,29 @@ */ package scomp.contentType.complex.detailed; -import junit.framework.TestCase; - - -import java.math.BigInteger; - -import org.apache.xmlbeans.XmlInteger; import org.apache.xmlbeans.XmlCursor; -import xbean.scomp.contentType.named.NamedEltDocument; +import org.apache.xmlbeans.XmlInteger; +import org.junit.Test; +import scomp.common.BaseCase; import xbean.scomp.contentType.named.ElementT; -import xbean.scomp.contentType.named.NamedMixedEltDocument; import xbean.scomp.contentType.named.MixedT; +import xbean.scomp.contentType.named.NamedEltDocument; +import xbean.scomp.contentType.named.NamedMixedEltDocument; -import scomp.common.BaseCase; +import java.math.BigInteger; + +import static org.junit.Assert.*; -/** - * - * - * - */ public class NamedTest extends BaseCase { + @Test public void testSimpleAnonymous() throws Throwable { NamedEltDocument doc = NamedEltDocument.Factory.newInstance(); ElementT testElt = doc.getNamedElt(); - assertEquals(null, testElt); + assertNull(testElt); testElt = doc.addNewNamedElt(); - assertEquals(null, testElt.getChild1()); - assertEquals(null, testElt.xgetChild1()); + assertNull(testElt.getChild1()); + assertNull(testElt.xgetChild1()); testElt.setChild2(new BigInteger("5")); testElt.setChild3(new BigInteger("1")); assertEquals("<xml-fragment><child2>5</child2>" + @@ -60,15 +55,16 @@ public class NamedTest extends BaseCase } } + @Test public void testMixedAnonymous() throws Throwable { NamedMixedEltDocument doc = NamedMixedEltDocument.Factory.newInstance(); MixedT testElt = doc.getNamedMixedElt(); - assertEquals(null, testElt); + assertNull(testElt); testElt = doc.addNewNamedMixedElt(); - assertEquals(null, testElt.getChild1()); - assertEquals(null, testElt.xgetChild1()); + assertNull(testElt.getChild1()); + assertNull(testElt.xgetChild1()); testElt.setChild2(new BigInteger("5")); assertEquals(5, testElt.getChild2().intValue()); XmlInteger expected = XmlInteger.Factory.newInstance(); Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/AllTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/AllTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/AllTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/AllTest.java Fri Jan 18 23:08:44 2019 @@ -15,82 +15,64 @@ package scomp.contentType.complex.modelGroup.detailed; +import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlException; +import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.contentType.modelGroup.AllEltDocument; import xbean.scomp.contentType.modelGroup.AllT; import java.math.BigInteger; -import org.apache.xmlbeans.XmlErrorCodes; +import static org.junit.Assert.assertTrue; -/** - * - * - * - */ public class AllTest extends BaseCase { /** * Instance should be valid w/ child1 missing */ - public void testChild1Optional() throws Throwable { + @Test + public void testChild1Optional() { doc = AllEltDocument.Factory.newInstance(); AllT elt = doc.addNewAllElt(); elt.setChild2("doo"); elt.setChild3(BigInteger.ONE); - try { - assertTrue(doc.validate(validateOptions)); - } - catch (Throwable t) { - showErrors(); - throw t; - } - + assertTrue(doc.validate(validateOptions)); } /** * All group doesn't care about field order - * - * @throws Throwable */ - public void testOrder() throws Throwable { + @Test + public void testOrder() throws XmlException { String input = - "<pre:AllElt xmlns:pre=\"http://xbean/scomp/contentType/ModelGroup\">" + - "<child3>5</child3><child1>2</child1><child2>bar</child2>" + - "</pre:AllElt>"; + "<pre:AllElt xmlns:pre=\"http://xbean/scomp/contentType/ModelGroup\">" + + "<child3>5</child3><child1>2</child1><child2>bar</child2>" + + "</pre:AllElt>"; doc = AllEltDocument.Factory.parse(input); - try { - assertTrue(doc.validate(validateOptions)); - } - catch (Throwable t) { - showErrors(); - throw t; - } - - + assertTrue(doc.validate(validateOptions)); } /** * maxOccurs is always 1 - * - * @throws Throwable */ - public void testIllegal() throws Throwable { + @Test + public void testIllegal() throws XmlException { String input = - "<pre:AllElt xmlns:pre=\"http://xbean/scomp/contentType/ModelGroup\">" + - "<child3>5</child3><child3>2</child3><child2>bar</child2>" + - "</pre:AllElt>"; + "<pre:AllElt xmlns:pre=\"http://xbean/scomp/contentType/ModelGroup\">" + + "<child3>5</child3><child3>2</child3><child2>bar</child2>" + + "</pre:AllElt>"; doc = AllEltDocument.Factory.parse(input); assertTrue(!doc.validate(validateOptions)); showErrors(); //$TODO: QUESTIONABLE ERRORS: if <child3>2</child3> is replaced by <child1>2</child1> //all will be good: why 2 errors? - String[] errExpected = new String[]{ + String[] errExpected = { XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$EXPECTED_DIFFERENT_ELEMENT, - XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$ELEMENT_NOT_ALLOWED, - XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$EXPECTED_ELEMENT +// XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$ELEMENT_NOT_ALLOWED, +// XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$EXPECTED_ELEMENT }; - assertTrue(compareErrorCodes(errExpected)); + assertTrue(compareErrorCodes(errExpected)); } Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/ChoiceTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/ChoiceTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/ChoiceTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/ChoiceTest.java Fri Jan 18 23:08:44 2019 @@ -15,25 +15,23 @@ package scomp.contentType.complex.modelGroup.detailed; +import org.apache.xmlbeans.XmlCursor; +import org.apache.xmlbeans.XmlErrorCodes; +import org.junit.Test; +import scomp.common.BaseCase; import xbean.scomp.contentType.modelGroup.ChoiceEltDocument; import xbean.scomp.contentType.modelGroup.ChoiceT; import xbean.scomp.contentType.modelGroup.MixedChoiceEltDocument; import xbean.scomp.contentType.modelGroup.MixedChoiceT; -import scomp.common.BaseCase; import java.math.BigInteger; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlErrorCodes; - -/** - * - * - * - */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; //TODO: assert that order of elements in a choice group doesn't matter public class ChoiceTest extends BaseCase { + @Test public void testValidCase() throws Throwable { ChoiceEltDocument doc = ChoiceEltDocument.Factory.newInstance(); ChoiceT elt = doc.addNewChoiceElt(); @@ -49,6 +47,7 @@ public class ChoiceTest extends BaseCase //more than 1 from choice group //TODO: test should pass but error message not good + @Test public void testChoiceViolation() throws Throwable { ChoiceEltDocument doc = ChoiceEltDocument.Factory.newInstance(); ChoiceT elt = doc.addNewChoiceElt(); Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/NestSequenceChoiceTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/NestSequenceChoiceTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/NestSequenceChoiceTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/NestSequenceChoiceTest.java Fri Jan 18 23:08:44 2019 @@ -14,20 +14,19 @@ */ package scomp.contentType.complex.modelGroup.detailed; +import org.apache.xmlbeans.XmlErrorCodes; +import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.contentType.modelGroup.NestedChoiceInSequenceDocument; import xbean.scomp.contentType.modelGroup.NestedChoiceInSequenceT; -import org.apache.xmlbeans.XmlErrorCodes; -/** - * - * - * - */ +import static org.junit.Assert.assertTrue; + public class NestSequenceChoiceTest extends BaseCase { /** * Choice group is optional */ + @Test public void testChoiceMissing() throws Throwable { NestedChoiceInSequenceDocument doc = NestedChoiceInSequenceDocument.Factory.newInstance(); @@ -42,9 +41,9 @@ public class NestSequenceChoiceTest exte showErrors(); throw t; } - } + @Test public void testAllPresent() throws Throwable { NestedChoiceInSequenceDocument doc = NestedChoiceInSequenceDocument.Factory.newInstance(); @@ -85,6 +84,7 @@ public class NestSequenceChoiceTest exte /** * Missing elt. from the sequence in the choice */ + @Test public void testIllegal() throws Throwable { NestedChoiceInSequenceDocument doc = NestedChoiceInSequenceDocument.Factory.newInstance(); @@ -110,12 +110,12 @@ public class NestSequenceChoiceTest exte showErrors(); throw t; } - } /** * Incorrect order in inner sequence */ + @Test public void testIllegalOrderInner() throws Throwable { String input = "<pre:NestedChoiceInSequence " + @@ -135,13 +135,12 @@ public class NestSequenceChoiceTest exte XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$MISSING_ELEMENT }; assertTrue(compareErrorCodes(errExpected)); - - } /** * Incorrect order in outer sequence */ + @Test public void testIllegalOrderOuter() throws Throwable { String input = "<pre:NestedChoiceInSequence " + @@ -155,7 +154,5 @@ public class NestSequenceChoiceTest exte NestedChoiceInSequenceDocument.Factory.parse(input); assertTrue(!doc.validate(validateOptions)); showErrors(); - } - } Modified: xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/SequenceTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/SequenceTest.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/SequenceTest.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/complex/modelGroup/detailed/SequenceTest.java Fri Jan 18 23:08:44 2019 @@ -14,21 +14,21 @@ */ package scomp.contentType.complex.modelGroup.detailed; -import xbean.scomp.contentType.modelGroup.SequenceEltDocument; -import xbean.scomp.contentType.modelGroup.SequenceT; -import org.apache.xmlbeans.XmlString; import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlString; +import org.junit.Test; import scomp.common.BaseCase; +import xbean.scomp.contentType.modelGroup.SequenceEltDocument; +import xbean.scomp.contentType.modelGroup.SequenceT; import java.math.BigInteger; -/** - * - * - * - */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class SequenceTest extends BaseCase { + @Test public void testWrongOrder() throws Throwable { SequenceEltDocument doc = SequenceEltDocument.Factory .parse("<foo:SequenceElt xmlns:foo=\"http://xbean/scomp/contentType/ModelGroup\">" + @@ -42,10 +42,9 @@ public class SequenceTest extends BaseCa String[] errExpected = new String[]{ XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$EXPECTED_DIFFERENT_ELEMENT}; assertTrue(compareErrorCodes(errExpected)); - - } + @Test public void testWrongCardinality() { SequenceEltDocument doc = SequenceEltDocument.Factory.newInstance(); SequenceT elt = doc.addNewSequenceElt(); Modified: xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/BuiltInType.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/BuiltInType.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/BuiltInType.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/BuiltInType.java Fri Jan 18 23:08:44 2019 @@ -15,27 +15,24 @@ package scomp.contentType.simple.detailed; +import org.apache.xmlbeans.*; +import org.junit.Test; import scomp.common.BaseCase; -import xbean.scomp.contentType.builtIn.string.*; -import xbean.scomp.contentType.builtIn.number.*; import xbean.scomp.contentType.builtIn.date.*; -import org.apache.xmlbeans.*; +import xbean.scomp.contentType.builtIn.number.*; +import xbean.scomp.contentType.builtIn.string.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; -/** - * - * - * - */ +import static org.junit.Assert.*; + public class BuiltInType extends BaseCase { /** * testing types String, normalizedString and token - * - * @throws Throwable */ + @Test public void testStringBasedTypes1() throws Throwable { String[] exp = new String[]{ "\tLead tab,A string on\n 2 lines with 2 spaces", @@ -79,10 +76,9 @@ public class BuiltInType extends BaseCas /** * testing types Name, NCName, Language - * - * @throws Throwable */ - public void testStringBasedTypes2() throws Throwable { + @Test + public void testStringBasedTypes2() { NameEltDocument nameDoc = NameEltDocument.Factory.newInstance(); nameDoc.setNameElt("_eltName"); assertTrue(nameDoc.validate(validateOptions)); @@ -144,6 +140,7 @@ public class BuiltInType extends BaseCas return sb.toString(); } + @Test public void testNumericypes() throws Throwable { FloatEltDocument flDoc = FloatEltDocument @@ -152,11 +149,11 @@ public class BuiltInType extends BaseCas ">12.34e+5</FloatElt>"); assertTrue(flDoc.validate(validateOptions)); flDoc.setFloatElt(13.5f); - assertTrue(13.5f == flDoc.getFloatElt()); + assertEquals(13.5f, flDoc.getFloatElt(), 0.0); DoubleEltDocument doubDoc = DoubleEltDocument.Factory.newInstance(); - assertTrue(0 == doubDoc.getDoubleElt()); + assertEquals(0, doubDoc.getDoubleElt(), 0.0); XmlDouble val = XmlDouble.Factory.newInstance(); val.setDoubleValue(13.4d); doubDoc.xsetDoubleElt(val); @@ -169,7 +166,7 @@ public class BuiltInType extends BaseCas assertTrue(decDoc.validate(validateOptions)); BigDecimal bdval = new BigDecimal(new BigInteger("10")); decDoc.setDecimalElt(bdval); - assertTrue(bdval == decDoc.getDecimalElt()); + assertSame(bdval, decDoc.getDecimalElt()); IntegerEltDocument integerDoc = IntegerEltDocument.Factory.parse("<IntegerElt " + @@ -177,7 +174,7 @@ public class BuiltInType extends BaseCas ">124353</IntegerElt>"); assertTrue(decDoc.validate(validateOptions)); integerDoc.setIntegerElt(BigInteger.ONE); - assertTrue(BigInteger.ONE == integerDoc.getIntegerElt()); + assertSame(BigInteger.ONE, integerDoc.getIntegerElt()); LongEltDocument longDoc = LongEltDocument.Factory.newInstance(); @@ -199,7 +196,7 @@ public class BuiltInType extends BaseCas " xmlns=\"http://xbean/scomp/contentType/builtIn/Number\"" + ">-32768</ShortElt>"); assertTrue(shDoc.validate(validateOptions)); - assertTrue(-32768 == shDoc.xgetShortElt().getShortValue()); + assertEquals(-32768, shDoc.xgetShortElt().getShortValue()); //largest short is 32767. Don't use set--it would wrap around shDoc = ShortEltDocument.Factory.parse("<ShortElt " + " xmlns=\"http://xbean/scomp/contentType/builtIn/Number\"" + @@ -230,7 +227,7 @@ public class BuiltInType extends BaseCas NonPosIntEltDocument.Factory.parse("<NonPosIntElt " + " xmlns=\"http://xbean/scomp/contentType/builtIn/Number\"" + ">-0000000</NonPosIntElt>"); - assertTrue(0 == nonposIntDoc.getNonPosIntElt().intValue()); + assertEquals(0, nonposIntDoc.getNonPosIntElt().intValue()); assertTrue(nonposIntDoc.validate(validateOptions)); //should be valid but javac complains is setter is called nonposIntDoc = @@ -277,6 +274,7 @@ public class BuiltInType extends BaseCas } + @Test public void testDateTime() throws Throwable { DateEltDocument date = DateEltDocument.Factory.newInstance(); Modified: xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/ListType.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/ListType.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/ListType.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/ListType.java Fri Jan 18 23:08:44 2019 @@ -15,24 +15,21 @@ package scomp.contentType.simple.detailed; +import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlSimpleList; +import org.apache.xmlbeans.impl.values.XmlValueNotSupportedException; +import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.contentType.list.*; -import java.util.List; -import java.util.LinkedList; import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; -import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException; -import org.apache.xmlbeans.impl.values.XmlValueNotSupportedException; -import org.apache.xmlbeans.XmlSimpleList; -import org.apache.xmlbeans.XmlErrorCodes; +import static org.junit.Assert.*; -/** - * - * - * - */ public class ListType extends BaseCase { + @Test public void testListTypeAnonymous() throws Throwable { ListEltTokenDocument doc = ListEltTokenDocument.Factory.newInstance(); @@ -67,6 +64,7 @@ public class ListType extends BaseCase { } + @Test public void testListTypeGlobal() throws Throwable { String input = "<ListEltInt xmlns=\"http://xbean/scomp/contentType/List\"" + @@ -100,6 +98,7 @@ public class ListType extends BaseCase { } } + @Test public void testListofLists() { //also,a list of union that contains a list is not OK fail("Compile Time eror"); @@ -108,6 +107,7 @@ public class ListType extends BaseCase { /** * values should be in [small,medium,large,1-3,-3,-2,-1] */ + @Test public void testListofUnions() throws Throwable { ListUnionDocument doc = ListUnionDocument.Factory.newInstance(); @@ -127,6 +127,7 @@ public class ListType extends BaseCase { } } + @Test public void testListofUnionsIllegal() throws Throwable { String input = "<ListUnion xmlns=\"http://xbean/scomp/contentType/List\"" + @@ -145,6 +146,7 @@ public class ListType extends BaseCase { } + @Test public void testListofUnions2() throws Throwable { ListUnion2Document doc = ListUnion2Document.Factory.newInstance(); Modified: xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/SimpleType.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/SimpleType.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/SimpleType.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/SimpleType.java Fri Jan 18 23:08:44 2019 @@ -14,16 +14,15 @@ */ package scomp.contentType.simple.detailed; +import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.contentType.simpleType.PantSizeEltDocument; import org.apache.xmlbeans.XmlErrorCodes; -/** - * - * - * - */ +import static org.junit.Assert.assertTrue; + public class SimpleType extends BaseCase { + @Test public void testPattern() throws Throwable { PantSizeEltDocument size = PantSizeEltDocument.Factory.newInstance(); size.setPantSizeElt(16); Modified: xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/UnionType.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/UnionType.java?rev=1851656&r1=1851655&r2=1851656&view=diff ============================================================================== --- xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/UnionType.java (original) +++ xmlbeans/trunk/test/src/scomp/contentType/simple/detailed/UnionType.java Fri Jan 18 23:08:44 2019 @@ -15,28 +15,30 @@ package scomp.contentType.simple.detailed; +import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlOptions; +import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException; +import org.junit.Test; import scomp.common.BaseCase; -import xbean.scomp.contentType.union.*; +import xbean.scomp.contentType.union.UnionEltDocument; +import xbean.scomp.contentType.union.UnionOfListsDocument; +import xbean.scomp.contentType.union.UnionOfUnionsDocument; +import xbean.scomp.contentType.union.UnionOfUnionsT; -import java.util.List; import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; -import org.apache.xmlbeans.XmlErrorCodes; -import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException; -/** - * - * - * - */ public class UnionType extends BaseCase { /** * should be a bunch of negative cases at compile time */ + @Test public void testUnionType() throws Throwable { UnionEltDocument doc = UnionEltDocument.Factory.newInstance(); - assertEquals(null, doc.getUnionElt()); + assertNull(doc.getUnionElt()); doc.setUnionElt("small"); try { assertTrue(doc.validate(validateOptions)); @@ -45,7 +47,7 @@ public class UnionType extends BaseCase showErrors(); throw t; } - doc.setUnionElt(new Integer(2)); + doc.setUnionElt(2); try { assertTrue(doc.validate(validateOptions)); } @@ -53,7 +55,7 @@ public class UnionType extends BaseCase showErrors(); throw t; } - doc.setUnionElt(new Integer(-2)); + doc.setUnionElt(-2); try { assertTrue(doc.validate(validateOptions)); } @@ -61,7 +63,7 @@ public class UnionType extends BaseCase showErrors(); throw t; } - doc.setUnionElt(new Integer(5)); + doc.setUnionElt(5); assertTrue(!doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ @@ -72,9 +74,8 @@ public class UnionType extends BaseCase /** * valid instance w/ xsi:type hint - * - * @throws Throwable */ + @Test public void testParseInstanceValid() throws Throwable { String input = "<UnionElt xmlns=\"http://xbean/scomp/contentType/Union\"" + @@ -94,9 +95,8 @@ public class UnionType extends BaseCase /** * invalid instance w/ xsi:type hint - * - * @throws Throwable */ + @Test public void testParseInstanceInvalid() throws Throwable { String input = "<UnionElt xmlns=\"http://xbean/scomp/contentType/Union\"" + @@ -117,6 +117,7 @@ public class UnionType extends BaseCase * Specifiying value for a union that is not part of the consitituent types. The constituent types in this schema * are enumerations and not basic XmlSchema types and hence get translated into enum types in the XmlObjects */ + @Test public void testUnionOfUnions() throws Throwable { UnionOfUnionsDocument doc = UnionOfUnionsDocument.Factory.newInstance(); doc.setUnionOfUnions("large"); @@ -128,7 +129,7 @@ public class UnionType extends BaseCase throw t; } UnionOfUnionsT elt = UnionOfUnionsT.Factory.newInstance(); - elt.setObjectValue(new Integer(-3)); + elt.setObjectValue(-3); doc.xsetUnionOfUnions(elt); try { assertTrue(doc.validate(validateOptions)); @@ -192,6 +193,7 @@ public class UnionType extends BaseCase // for the above test (testUnionOfUnions), if the value set for the union type is AnyType (in the schema) // but the Java type defined as say Integer or Date then an Exception should be thrown only if // validateOnSet XmlOption is set and not otherwise. + @Test public void UnionOfUnions2() { UnionOfUnionsDocument doc = UnionOfUnionsDocument.Factory.newInstance(); @@ -222,19 +224,19 @@ public class UnionType extends BaseCase } } - /** + /** * values allolwed here are either a list of (small, med, large, 1-3,-1,-2,-3} * or (lstsmall, lstmed, lstlarge) */ - + @Test public void testUnionOfLists() throws Throwable { UnionOfListsDocument doc = UnionOfListsDocument.Factory.newInstance(); List vals = new ArrayList(); vals.add("small"); - vals.add(new Integer(-1)); - vals.add(new Integer(-2)); - vals.add(new Integer(-3)); - vals.add(new Integer(3)); + vals.add(-1); + vals.add(-2); + vals.add(-3); + vals.add(3); vals.add("medium"); doc.setUnionOfLists(vals); try { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
