You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by da...@apache.org on 2004/08/25 19:36:28 UTC
cvs commit: xml-xmlbeans/v2/test/src/tools/inst2xsd/detailed Inst2XsdDetailedAttrTest.java Inst2XsdDetailedTest.java
daveremy 2004/08/25 10:36:28
Modified: v2/test/src/tools/inst2xsd/checkin Inst2XsdAttrTest.java
v2/test/src/tools/inst2xsd/common Inst2XsdTestBase.java
v2/test/src/tools/inst2xsd/detailed
Inst2XsdDetailedAttrTest.java
Inst2XsdDetailedTest.java
Log:
Contributed by: Jacob Danner, modifications to attribute inst2xsd tests to work around a restriction base type issue
Revision Changes Path
1.4 +0 -94 xml-xmlbeans/v2/test/src/tools/inst2xsd/checkin/Inst2XsdAttrTest.java
Index: Inst2XsdAttrTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/tools/inst2xsd/checkin/Inst2XsdAttrTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Inst2XsdAttrTest.java 24 Aug 2004 18:19:51 -0000 1.3
+++ Inst2XsdAttrTest.java 25 Aug 2004 17:36:27 -0000 1.4
@@ -26,100 +26,6 @@
runAttrTypeChecking(getAttrTypeXml("a b c\n hello\t from\n\txmlbeans"), "string");
}
- public void test_attrshort() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("-129"), "short");
- runAttrTypeChecking(getAttrTypeXml("128"), "short");
- runAttrTypeChecking(getAttrTypeXml("3000"), "short");
- runAttrTypeChecking(getAttrTypeXml("-3000"), "short");
- runAttrTypeChecking(getAttrTypeXml("-32768"), "short");
- runAttrTypeChecking(getAttrTypeXml("32767"), "short");
- }
-
- public void test_attrint() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("39000"), "int");
- runAttrTypeChecking(getAttrTypeXml("32768"), "int");
- runAttrTypeChecking(getAttrTypeXml("-32769"), "int");
- runAttrTypeChecking(getAttrTypeXml("-39000"), "int");
- runAttrTypeChecking(getAttrTypeXml("126789675"), "int");
- runAttrTypeChecking(getAttrTypeXml("2147483647"), "int");
- runAttrTypeChecking(getAttrTypeXml("-2147483648"), "int");
- }
-
- public void test_attrlong() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("2147483648"), "long");
- runAttrTypeChecking(getAttrTypeXml("-2147483649"), "long");
- runAttrTypeChecking(getAttrTypeXml("-2150000000"), "long");
- runAttrTypeChecking(getAttrTypeXml("2150000000"), "long");
- runAttrTypeChecking(getAttrTypeXml("-9223372036854775808"), "long");
- runAttrTypeChecking(getAttrTypeXml("9223372036854775807"), "long");
- }
-
- public void test_attrinteger() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("9300000000000000000"), "integer");
- runAttrTypeChecking(getAttrTypeXml("-9300000000000000000"), "integer");
- runAttrTypeChecking(getAttrTypeXml("-9223372036854775809"), "integer");
- runAttrTypeChecking(getAttrTypeXml("9223372036854775808"), "integer");
- }
-
- public void test_attrfloat() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("12.78e-2"), "float");
- runAttrTypeChecking(getAttrTypeXml("1267.43233E12"), "float");
- runAttrTypeChecking(getAttrTypeXml("-1E4"), "float");
- runAttrTypeChecking(getAttrTypeXml("INF"), "float");
- runAttrTypeChecking(getAttrTypeXml("-INF"), "float");
- runAttrTypeChecking(getAttrTypeXml("NaN"), "float");
- runAttrTypeChecking(getAttrTypeXml("-1.23"), "float");
- runAttrTypeChecking(getAttrTypeXml("12678967.543233"), "float");
- runAttrTypeChecking(getAttrTypeXml("+100000.00"), "float");
- }
-
- //TODO: NOT COMPLETELY SURE HOW TO GET THESE WITHOUT
- //CAUSING AN Number EXCEPTION
- //public void test_attrdouble() throws Exception {
- // runAttrTypeChecking(getAttrTypeXml(""), "double");
- //}
-
- //public void test_attrdecimal() throws Exception {
- // runAttrTypeChecking(getAttrTypeXml(""), "decimal");
- //}
- //Value will become number
- // public void test_attrgYear() throws Exception {
- //runAttrTypeChecking(getAttrTypeXml("1999"), "gYear");
- //}
-
-
- public void test_attrdate() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("1999-05-31"), "date");
- }
-
- public void test_attrdateTime() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("1999-05-31T13:20:00-05:00"), "dateTime");
- runAttrTypeChecking(getAttrTypeXml("2000-03-04T20:00:00Z"), "dateTime");
- runAttrTypeChecking(getAttrTypeXml("2000-03-04T23:00:00+03:00"), "dateTime");
- }
- public void test_attrtime() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("13:20:00-05:00"), "time");
- runAttrTypeChecking(getAttrTypeXml("00:00:00"), "time");
- runAttrTypeChecking(getAttrTypeXml("13:20:00Z"), "time");
- }
-
- public void test_attrQName() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("xsd:string"), "QName");
- runAttrTypeChecking(getAttrTypeXml("xsi:int"), "QName");
- runAttrTypeChecking(getAttrTypeXml("foo:baz"), "QName");
- }
-
- public void test_attrCDATA() throws Exception {
- runAttrTypeChecking(getAttrTypeXml("<![CDATA[ " +
- "function matchwo(a, b) {" +
- "if (a < b && a < 0) " +
- " then { " +
- " return 1 " +
- " } else { " +
- " return 0 " +
- " } " +
- "} ]]>"), "string");
- }
//public void test_attr() throws Exception {
// runAttrTypeChecking(getAttrTypeXml(""), "");
1.2 +70 -15 xml-xmlbeans/v2/test/src/tools/inst2xsd/common/Inst2XsdTestBase.java
Index: Inst2XsdTestBase.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/tools/inst2xsd/common/Inst2XsdTestBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Inst2XsdTestBase.java 23 Aug 2004 22:02:51 -0000 1.1
+++ Inst2XsdTestBase.java 25 Aug 2004 17:36:27 -0000 1.2
@@ -25,36 +25,36 @@
public static tools.inst2xsd.common.Inst2XsdCommon common;
public static boolean _verbose = true;
- public static File fwroot = getRootFile();
- public static File caseroot = new File(fwroot, "test" + P + "cases" + P + "xbean");
+ public static final String fwroot = System.getProperty("xbean.rootdir");
+ public static String caseroot = fwroot + P + "test" + P + "cases" + P + "xbean";
//location of files under "cases folder"
- public static String miscDir = new File(caseroot, "tools").getAbsolutePath();
+ public static String miscDir = caseroot + P + "tools";
public static String inst2xsdDir = miscDir + P + "inst2xsd" + P;
public static String OPTION_CASES_DIR = inst2xsdDir + P + "options" + P;
public static String SCHEMA_CASES_DIR = inst2xsdDir + P + "schema" + P;
public static String VALIDATION_CASES_DIR = inst2xsdDir + P + "validation" + P;
- public static File outputroot = new File(fwroot, "build" + P + "test" + P + "output" + P + "inst2xsd");
+ private static String base_start = "<a xmlns=\"typeTests\">";
+ private static String base_end = "</a>";
- private String base_start = "<a xmlns=\"typeTests\">";
- private String base_end = "</a>";
-
- private String attr_base_start = "<a xmlns=\"attrTests\" a=\"";
- private String attr_base_end = "\" />";
+ private static String attr_base_start = "<a xmlns=\"attrTests\" a=\"";
+ private static String attr_base_end = "\" />";
public Inst2XsdTestBase(String name) {
super(name);
}
- public static File getRootFile() throws IllegalStateException {
- try {
- return new File(System.getProperty("xbean.rootdir")).getCanonicalFile();
- } catch (IOException e) {
- throw new IllegalStateException(e.toString());
- }
+ public static final String test_getRootFilePath() throws IllegalStateException {
+ String root = System.getProperty("xbean.rootdir");
+ log("xbean.rootdir: "+root);
+ if (root == null)
+ throw new IllegalStateException("xbean.rootdir system property not found");
+
+ return root;
}
+
public XmlObject getTypeXml(String val) throws Exception {
return XmlObject.Factory.parse(setTypeVal(val));
}
@@ -80,6 +80,20 @@
"</xs:schema>";
}
+
+
+ public String getAttrTypeXmlVenetian(String primType, String derType) {
+ return "<schema attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " +
+ "targetNamespace=\"attrTests\" xmlns=\"http://www.w3.org/2001/XMLSchema\">" +
+ "<element name=\"a\" type=\"att:aType\" xmlns:att=\"attrTests\"/>" +
+ "<complexType name=\"aType\">" +
+ "<simpleContent>" +
+ "<extension base=\"xs:" + primType + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
+ "<attribute type=\"xs:" + derType + "\" name=\"a\"/>" +
+ "</extension>" +
+ "</simpleContent></complexType></schema>";
+ }
+
public String getAttrTypeXmlVenetian(String type) {
return "<schema attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " +
"targetNamespace=\"attrTests\" xmlns=\"http://www.w3.org/2001/XMLSchema\">" +
@@ -92,6 +106,18 @@
"</simpleContent></complexType></schema>";
}
+ public String getAttrTypeXmlRDandSS(String primType, String derType ) {
+ return "<schema attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " +
+ "targetNamespace=\"attrTests\" xmlns=\"http://www.w3.org/2001/XMLSchema\">" +
+ "<element name=\"a\">" +
+ "<complexType>" +
+ "<simpleContent>" +
+ "<extension base=\"xs:" + primType + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
+ "<attribute type=\"xs:" + derType + "\" name=\"a\"/>" +
+ "</extension>" +
+ "</simpleContent>" +
+ "</complexType></element></schema>";
+ }
public String getAttrTypeXmlRDandSS(String type) {
return "<schema attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " +
"targetNamespace=\"attrTests\" xmlns=\"http://www.w3.org/2001/XMLSchema\">" +
@@ -106,6 +132,7 @@
}
public void runAttrTypeChecking(XmlObject act, String expType) throws Exception {
+
log("=== Venetian options ===");
runAttrTypeChecking(act, expType, common.getVenetianOptions());
log("=== Russian options ===");
@@ -114,6 +141,34 @@
runAttrTypeChecking(act, expType, common.getSalamiOptions());
log("=== Default options ===");
runAttrTypeChecking(act, expType, common.getDefaultInstOptions());
+ }
+
+ public void runAttrTypeChecking(XmlObject act, String primType, String derType) throws Exception {
+
+ log("=== Venetian options ===");
+ runAttrTypeChecking(act, primType, derType, common.getVenetianOptions());
+ log("=== Russian options ===");
+ runAttrTypeChecking(act, primType, derType, common.getRussianOptions());
+ log("=== Salami options ===");
+ runAttrTypeChecking(act, primType, derType, common.getSalamiOptions());
+ log("=== Default options ===");
+ runAttrTypeChecking(act, primType, derType, common.getDefaultInstOptions());
+ }
+
+ private void runAttrTypeChecking(XmlObject act, String primType, String derType, Inst2XsdOptions opt) throws Exception {
+ SchemaDocument[] venetian = (SchemaDocument[]) runInst2Xsd(act, opt);
+ checkLength(venetian, 1);
+
+ if (opt.getDesign() == Inst2XsdOptions.DESIGN_RUSSIAN_DOLL ||
+ opt.getDesign() == Inst2XsdOptions.DESIGN_SALAMI_SLICE)
+ compare(venetian[0], XmlObject.Factory.parse(getAttrTypeXmlRDandSS(primType,derType)));
+ else if (opt.getDesign() == Inst2XsdOptions.DESIGN_VENETIAN_BLIND)
+ compare(venetian[0], XmlObject.Factory.parse(getAttrTypeXmlVenetian(primType, derType)));
+ else
+ throw new Exception("Design style was not found");
+
+ checkInstance(venetian, new XmlObject[]{act});
+
}
private void runAttrTypeChecking(XmlObject act, String expType, Inst2XsdOptions opt) throws Exception {
1.3 +99 -1 xml-xmlbeans/v2/test/src/tools/inst2xsd/detailed/Inst2XsdDetailedAttrTest.java
Index: Inst2XsdDetailedAttrTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/tools/inst2xsd/detailed/Inst2XsdDetailedAttrTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Inst2XsdDetailedAttrTest.java 24 Aug 2004 18:19:51 -0000 1.2
+++ Inst2XsdDetailedAttrTest.java 25 Aug 2004 17:36:28 -0000 1.3
@@ -1,3 +1,4 @@
+package tools.inst2xsd.detailed;
import tools.inst2xsd.common.Inst2XsdTestBase;
@@ -39,7 +40,8 @@
public void test_attrgMonth() throws Exception {
runAttrTypeChecking(getAttrTypeXml("--02--"), "gMonth");
}
-
+
+ //todo: move to checkin once restriction issue gets fixed
public void test_attrbyte() throws Exception {
runAttrTypeChecking(getAttrTypeXml("123"), "byte");
runAttrTypeChecking(getAttrTypeXml("+100"), "byte");
@@ -78,6 +80,102 @@
public void test_attrboolean() throws Exception {
runAttrTypeChecking(getAttrTypeXml("true"), "boolean");
runAttrTypeChecking(getAttrTypeXml("false"), "boolean");
+ }
+
+ public void test_attrshort() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("-129"), "short");
+ runAttrTypeChecking(getAttrTypeXml("128"), "short");
+ runAttrTypeChecking(getAttrTypeXml("3000"), "short");
+ runAttrTypeChecking(getAttrTypeXml("-3000"), "short");
+ runAttrTypeChecking(getAttrTypeXml("-32768"), "short");
+ runAttrTypeChecking(getAttrTypeXml("32767"), "short");
+ }
+
+ public void test_attrint() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("39000"), "int");
+ runAttrTypeChecking(getAttrTypeXml("32768"), "int");
+ runAttrTypeChecking(getAttrTypeXml("-32769"), "int");
+ runAttrTypeChecking(getAttrTypeXml("-39000"), "int");
+ runAttrTypeChecking(getAttrTypeXml("126789675"), "int");
+ runAttrTypeChecking(getAttrTypeXml("2147483647"), "int");
+ runAttrTypeChecking(getAttrTypeXml("-2147483648"), "int");
+ }
+
+ public void test_attrlong() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("2147483648"), "long");
+ runAttrTypeChecking(getAttrTypeXml("-2147483649"), "long");
+ runAttrTypeChecking(getAttrTypeXml("-2150000000"), "long");
+ runAttrTypeChecking(getAttrTypeXml("2150000000"), "long");
+ runAttrTypeChecking(getAttrTypeXml("-9223372036854775808"), "long");
+ runAttrTypeChecking(getAttrTypeXml("9223372036854775807"), "long");
+ }
+
+ public void test_attrinteger() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("9300000000000000000"), "integer");
+ runAttrTypeChecking(getAttrTypeXml("-9300000000000000000"), "integer");
+ runAttrTypeChecking(getAttrTypeXml("-9223372036854775809"), "integer");
+ runAttrTypeChecking(getAttrTypeXml("9223372036854775808"), "integer");
+ }
+
+ public void test_attrfloat() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("12.78e-2"), "float");
+ runAttrTypeChecking(getAttrTypeXml("1267.43233E12"), "float");
+ runAttrTypeChecking(getAttrTypeXml("-1E4"), "float");
+ runAttrTypeChecking(getAttrTypeXml("INF"), "float");
+ runAttrTypeChecking(getAttrTypeXml("-INF"), "float");
+ runAttrTypeChecking(getAttrTypeXml("NaN"), "float");
+ runAttrTypeChecking(getAttrTypeXml("-1.23"), "float");
+ runAttrTypeChecking(getAttrTypeXml("12678967.543233"), "float");
+ runAttrTypeChecking(getAttrTypeXml("+100000.00"), "float");
+ }
+
+ //TODO: NOT COMPLETELY SURE HOW TO GET THESE WITHOUT
+ //CAUSING AN Number EXCEPTION
+ //public void test_attrdouble() throws Exception {
+ // runAttrTypeChecking(getAttrTypeXml(""), "double");
+ //}
+
+ //public void test_attrdecimal() throws Exception {
+ // runAttrTypeChecking(getAttrTypeXml(""), "decimal");
+ //}
+ //Value will become number
+ // public void test_attrgYear() throws Exception {
+ //runAttrTypeChecking(getAttrTypeXml("1999"), "gYear");
+ //}
+
+
+ public void test_attrdate() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("1999-05-31"), "date");
+ }
+
+ public void test_attrdateTime() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("1999-05-31T13:20:00-05:00"), "dateTime");
+ runAttrTypeChecking(getAttrTypeXml("2000-03-04T20:00:00Z"), "dateTime");
+ runAttrTypeChecking(getAttrTypeXml("2000-03-04T23:00:00+03:00"), "dateTime");
+ }
+
+ public void test_attrtime() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("13:20:00-05:00"), "time");
+ runAttrTypeChecking(getAttrTypeXml("00:00:00"), "time");
+ runAttrTypeChecking(getAttrTypeXml("13:20:00Z"), "time");
+ }
+
+ public void test_attrQName() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("xsd:string"), "QName");
+ runAttrTypeChecking(getAttrTypeXml("xsi:int"), "QName");
+ runAttrTypeChecking(getAttrTypeXml("foo:baz"), "QName");
+ }
+
+ public void test_attrCDATA() throws Exception {
+ runAttrTypeChecking(getAttrTypeXml("<![CDATA[ " +
+ "function matchwo(a, b) {" +
+ "if (a < b && a < 0) " +
+ " then { " +
+ " return 1 " +
+ " } else { " +
+ " return 0 " +
+ " } " +
+ "} ]]>"), "string");
}
}
1.2 +1 -0 xml-xmlbeans/v2/test/src/tools/inst2xsd/detailed/Inst2XsdDetailedTest.java
Index: Inst2XsdDetailedTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/tools/inst2xsd/detailed/Inst2XsdDetailedTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Inst2XsdDetailedTest.java 23 Aug 2004 22:02:51 -0000 1.1
+++ Inst2XsdDetailedTest.java 25 Aug 2004 17:36:28 -0000 1.2
@@ -1,3 +1,4 @@
+package tools.inst2xsd.detailed;
import tools.inst2xsd.common.Inst2XsdTestBase;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org