and the end is here...
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
Index: ParserTest.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe2/src/net/sf/jaxme/junit/ParserTest.java,v
retrieving revision 1.12
diff -d -u -r1.12 ParserTest.java
--- ParserTest.java 16 Feb 2003 16:54:40 -0000 1.12
+++ ParserTest.java 20 Feb 2003 01:21:01 -0000
@@ -34,6 +34,9 @@
import net.sf.jaxme.generator.types.SchemaType;
import net.sf.jaxme.generator.types.SimpleContentType;
import net.sf.jaxme.generator.types.UnionType;
+import net.sf.jaxme.generator.types.impl.NegativeIntegerType;
+import net.sf.jaxme.generator.types.impl.NonPositiveIntegerType;
+import net.sf.jaxme.generator.types.impl.IntegerType;
import net.sf.jaxme.generator.util.QNameComparator;
import net.sf.jaxme.javasource.JavaQName;
import net.sf.jaxme.javasource.JavaQNameImpl;
@@ -850,6 +853,7 @@
assertEquals("PurchaseOrderType", purchaseOrder.getSchemaType().getLocalName());
}
+ /** A test case to trigger a previous parser bug. */
public void testRestrictionMaxExclusive() throws Exception {
final String mName = "testRestrictionMaxExclusive";
log.debug(mName + ": ->");
@@ -869,6 +873,135 @@
isource.setSystemId("testRestrictionMaxExclusive.xsd");
JAXBSchema jschema = (JAXBSchema) r.parse(isource);
+ log.debug(mName + ": <-");
+ }
+
+ /** Test some basic functionality of the builtin datatype nonPositiveInteger. */
+ public void testNonPositiveInteger() throws Exception {
+ final String mName = "testNonPositiveInteger";
+ log.debug(mName + ": ->");
+ final String schema =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> \n" +
+ " <xsd:element name='non-positive-integer' type='xsd:nonPositiveInteger'/> \n"
++
+ "</xsd:schema> \n";
+
+ JAXBSchemaReader r = new JAXBSchemaReader();
+ InputSource isource = new InputSource(new StringReader(schema));
+ isource.setSystemId("testNonPositiveInteger.xsd");
+ JAXBSchema jschema = (JAXBSchema) r.parse(isource);
+
+ // simple, atomic, with restriction and maxInclusive
+ SchemaType npi = jschema.getSchemaElements()[0].getSchemaType();
+ assertTrue(npi.getQName().getLocalPart().equals("nonPositiveInteger"));
+ assertTrue(!npi.isComplex());
+ SchemaSimpleType npis = (SchemaSimpleType) npi;
+ assertTrue(npis.isAtomic());
+ assertTrue(!npis.isList());
+ assertTrue(!npis.isUnion());
+ AtomicType npia = (AtomicType) npis;
+ assertEquals(0, npia.getFractionDigits().intValue());
+ assertEquals(0, npia.getMaxInclusive().intValue());
+ assertEquals(1, npia.getMaxExclusive().intValue());
+ log.debug(mName + ": <-");
+
+ // check facet value setters for allowable limits
+ NonPositiveIntegerType npit = new NonPositiveIntegerType();
+ boolean didThrow = false;
+ try {
+ npit.setMaxInclusive(new Integer(1));
+ } catch (IllegalArgumentException e) {
+ didThrow = true;
+ }
+ assertTrue(didThrow);
+ didThrow = false;
+ try {
+ npit.setMaxExclusive(new Integer(2));
+ } catch (IllegalArgumentException e) {
+ didThrow = true;
+ }
+ assertTrue(didThrow);
+ }
+
+ /** Test some basic functionality of the builtin datatype negativeInteger. */
+ public void testNegativeInteger() throws Exception {
+ final String mName = "testNegativeInteger";
+ log.debug(mName + ": ->");
+ final String schema =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> \n" +
+ " <xsd:element name='negative-integer' type='xsd:negativeInteger'/> \n" +
+ "</xsd:schema> \n";
+
+ JAXBSchemaReader r = new JAXBSchemaReader();
+ InputSource isource = new InputSource(new StringReader(schema));
+ isource.setSystemId("testNegativeInteger.xsd");
+ JAXBSchema jschema = (JAXBSchema) r.parse(isource);
+
+ // simple, atomic, with restrictions on and maxInclusive
+ SchemaType ni = jschema.getSchemaElements()[0].getSchemaType();
+ assertTrue(ni.getQName().getLocalPart().equals("negativeInteger"));
+ assertTrue(!ni.isComplex());
+ SchemaSimpleType nis = (SchemaSimpleType) ni;
+ assertTrue(nis.isAtomic());
+ assertTrue(!nis.isList());
+ assertTrue(!nis.isUnion());
+ AtomicType nia = (AtomicType) nis;
+ assertEquals(0, nia.getFractionDigits().intValue());
+ assertEquals(-1, nia.getMaxInclusive().intValue());
+ assertEquals(0, nia.getMaxExclusive().intValue());
+
+ // check setters that should throw range exceptions
+ NegativeIntegerType nit = new NegativeIntegerType();
+ boolean didThrow = false;
+ try {
+ nit.setMaxInclusive(new Integer(0));
+ } catch (IllegalArgumentException e) {
+ didThrow = true;
+ }
+ assertTrue(didThrow);
+ didThrow = false;
+ try {
+ nit.setMaxExclusive(new Integer(1));
+ } catch (IllegalArgumentException e) {
+ didThrow = true;
+ }
+ assertTrue(didThrow);
+ log.debug(mName + ": <-");
+ }
+
+ /** Test some basic functionality of the builtin datatype integer. */
+ public void testIntegerType() throws Exception {
+ final String mName = "testIntegerType";
+ log.debug(mName + ": ->");
+ final String schema =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> \n" +
+ " <xsd:element name='integer' type='xsd:integer'/> \n" +
+ "</xsd:schema> \n";
+
+ JAXBSchemaReader r = new JAXBSchemaReader();
+ InputSource isource = new InputSource(new StringReader(schema));
+ isource.setSystemId("testIntegerType.xsd");
+ JAXBSchema jschema = (JAXBSchema) r.parse(isource);
+
+ // simple, atomic, with restriction on fractionDigits
+ SchemaType i = jschema.getSchemaElements()[0].getSchemaType();
+ assertTrue(i.getQName().getLocalPart().equals("integer"));
+ assertTrue(!i.isComplex());
+ SchemaSimpleType is = (SchemaSimpleType) i;
+ assertTrue(is.isAtomic());
+ assertTrue(!is.isList());
+ assertTrue(!is.isUnion());
+ AtomicType ia = (AtomicType) is;
+ assertEquals(0, ia.getFractionDigits().intValue());
+
+ // Check facet setter that has range check
+ IntegerType it = new IntegerType();
+ boolean didThrow = false;
+ try {
+ it.setFractionDigits(new Integer(1));
+ } catch (IllegalArgumentException e) {
+ didThrow = true;
+ }
+ assertTrue(didThrow);
log.debug(mName + ": <-");
}
}