summaryrefslogtreecommitdiffstats
path: root/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java')
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java863
1 files changed, 863 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java
new file mode 100644
index 0000000000..ad1b446c3a
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java
@@ -0,0 +1,863 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package test.sdo21.tests.xsd;
+
+import java.util.List;
+import java.io.IOException;
+
+import commonj.sdo.Type;
+import commonj.sdo.Property;
+import commonj.sdo.DataObject;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class XSDComplexTypeTest extends XSDBaseTestCase {
+
+ /**
+ * <complexType> containing other elements.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testTC128ComplexTypeWithElement() throws Exception {
+
+ // parse the schema
+ List types = define("/complexType/cT_01.xsd");
+
+ Type type = (Type) types.get(0);
+ assertFalse(type.isSequenced());
+ assertFalse(type.isOpen());
+ assertFalse(type.isDataType());
+ assertFalse(type.isAbstract());
+ assertEquals("cT_01", type.getName());
+
+ assertPropertyExists(type, "id", "Int", false, false);
+ assertPropertyExists(type, "name", "String", false, false);
+ }
+
+ /**
+ * <complexType> with abstract="true".
+ *
+ * @throws Exception
+ */
+ @Test public void testTC129ComplexTypeAbstractTrue() throws Exception {
+
+ List types = define("/complexType/cT_02.xsd");
+
+ Type type = (Type) types.get(0);
+ assertFalse(type.isSequenced());
+ assertEquals("cT_02", type.getName());
+ assertTrue(type.isAbstract());
+
+ assertPropertyExists(type, "id", "Int", false, false);
+ assertFalse(type.getProperty("id").isReadOnly() );
+ assertPropertyExists(type, "name", "String", false, false);
+ assertFalse(type.getProperty("name").isReadOnly() );
+ }
+
+ /**
+ * <complexType> extending another <complexType>.
+ *
+ * @throws Exception
+ */
+ @Test public void testTC130ComplexTypeExtendingComplexType() throws Exception {
+
+ List types = define("/complexType/cT_03.xsd");
+ assertTrue(types.size() >= 2);
+
+ // parent
+ Type parentType = getType(types, "cT_03_parent");
+
+ List properties = parentType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+
+ Property p1 = (Property) properties.get(0);
+
+ assertEquals("id", p1.getName());
+ assertEquals("Int", p1.getType().getName());
+
+ // child
+ Type childType = getType(types, "cT_03_child");
+
+ List baseTypes = childType.getBaseTypes();
+ assertEquals(1, baseTypes.size());
+ Type baseType = (Type) baseTypes.get(0);
+ assertEquals("cT_03_parent", baseType.getName());
+
+ properties = childType.getProperties();
+ assertEquals(2, properties.size());
+ assertEquals(1, childType.getDeclaredProperties().size() );
+
+ //verify name and type of Properties
+ // base properties appear first, derived properties are appended
+ Property childTypeProp1 = (Property) properties.get(0);
+ assertEquals("id", childTypeProp1.getName());
+ assertEquals("Int", childTypeProp1.getType().getName());
+
+ Property childTypeProp2 = (Property) properties.get(1);
+ assertEquals("name", childTypeProp2.getName());
+ assertEquals("String", childTypeProp2.getType().getName());
+ }
+
+ /**
+ * <complexType> derived from <complexType> with block="#all" (should not affect SDO Types generated).
+ *
+ * @throws Exception
+ */
+ @Test public void testTC131ComplexTypeBlockAll() throws Exception {
+ List types = define("/complexType/cT_04.xsd");
+ assertTrue(types.size() >= 2);
+
+ // parent
+ Type parentType = getType(types, "cT_04_parent");
+
+ List properties = parentType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+
+ Property p1 = (Property) properties.get(0);
+
+ assertEquals("id", p1.getName());
+ assertEquals("Int", p1.getType().getName());
+
+ // child
+ Type childType = getType(types, "cT_04_child");
+
+ List baseTypes = childType.getBaseTypes();
+ assertEquals(1, baseTypes.size());
+ Type baseType = (Type) baseTypes.get(0);
+ assertEquals("cT_04_parent", baseType.getName());
+
+ properties = childType.getProperties();
+ assertEquals(2, properties.size());
+ assertEquals(1, childType.getDeclaredProperties().size() );
+
+ //verify name and type of Properties
+ // base properties appear first, derived properties are appended
+ Property childTypeProp1 = (Property) properties.get(0);
+ assertEquals("id", childTypeProp1.getName());
+ assertEquals("Int", childTypeProp1.getType().getName());
+
+ Property childTypeProp2 = (Property) properties.get(1);
+ assertEquals("name", childTypeProp2.getName());
+ assertEquals("String", childTypeProp2.getType().getName());
+ }
+
+ /**
+ * <complexType> containing <group> containing <sequence>.
+ *
+ * @throws Exception
+ */
+ @Test public void testTC132ComplexTypeGroupWithSequence() throws Exception {
+ List types = define("/complexType/cT_05.xsd");
+
+ Type type = (Type) types.get(0);
+ assertEquals("cT_05", type.getName());
+ assertFalse(type.isAbstract());
+
+ assertPropertyExists(type, "id", "Int", false, false);
+ assertFalse(type.getProperty("id").isReadOnly());
+ assertPropertyExists(type, "name", "String", false, false);
+ assertFalse(type.getProperty("name").isReadOnly());
+ }
+
+ /**
+ * <element> name="cT_06" containing anonymous <complexType>.
+ *
+ * @throws Exception
+ */
+ @Test public void testTC133ComplexTypeAnonymous() throws Exception {
+ List types = define("/complexType/cT_06.xsd");
+
+ // The spec maps the name of anonymous types to the name
+ // of their enclosing element. This is a broken method however,
+ // as it can conflict with same named types and other same
+ // named elements with anonymous types. So currently we are
+ // intentially non-compliant. using unique names for
+ // anonymous types
+
+ Property property = typeHelper.getOpenContentProperty( "http://www.example.com/xsd/6/",
+ "cT_06" );
+ Type type = property.getType();
+ assertFalse(type.isAbstract());
+ assertFalse(type.isSequenced());
+
+ assertPropertyExists(type, "id", "Int", false, false);
+ assertFalse(type.getProperty("id").isReadOnly());
+ assertPropertyExists(type, "name", "String", false, false);
+ assertFalse(type.getProperty("name").isReadOnly());
+ }
+
+ /**
+ * <complexType> with name.
+ *
+ * @throws Exception
+ */
+ @Test public void testTC134ComplexTypeNamed() throws Exception {
+ List types = define("/complexType/cT_07.xsd");
+
+ Type type = (Type) types.get(0);
+ assertEquals("cT_07", type.getName());
+ assertFalse(type.isAbstract());
+ assertFalse(type.isSequenced());
+
+ assertPropertyExists(type, "id", "Int", false, false);
+ assertFalse(type.getProperty("id").isReadOnly());
+ assertPropertyExists(type, "name", "String", false, false);
+ assertFalse(type.getProperty("name").isReadOnly());
+ }
+
+ /**
+ * <complexType> with final="true" containing <complexContent> containing <extension> of a <complexType> with abstract="true".
+ *
+ * @throws Exception
+ */
+ @Test public void testTC136ComplexTypeExtendAbstractTrue() throws Exception {
+ List types = define("/complexType/cT_09.xsd");
+ assertTrue(types.size() >= 2);
+
+ // parent
+ Type parentType = typeHelper.getType("http://www.example.com/xsd/9/", "cT_09_parent");
+
+ List properties = parentType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+
+ Property p1 = (Property) properties.get(0);
+
+ assertEquals("id", p1.getName());
+ assertEquals("Int", p1.getType().getName());
+
+ // child
+ Type childType = typeHelper.getType("http://www.example.com/xsd/9/", "cT_09_child");
+
+ List baseTypes = childType.getBaseTypes();
+ assertEquals(1, baseTypes.size());
+ Type baseType = (Type) baseTypes.get(0);
+ assertEquals("cT_09_parent", baseType.getName());
+
+ properties = childType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+ assertEquals(2, childType.getProperties().size() );
+
+ Property p2 = (Property) properties.get(0);
+
+ assertEquals("name", p2.getName());
+ assertEquals("String", p2.getType().getName());
+ }
+
+ /**
+ * <complexType> containing <complexContent> containing <restriction> of a <complexType> with abstract="true".
+ *
+ * @throws Exception
+ */
+ @Test public void testTC137ComplexTypeExtendWithRestriction() throws Exception {
+ List types = define("/complexType/cT_10.xsd");
+ assertTrue(types.size() >= 2);
+
+ // parent
+ Type parentType = getType(types, "cT_10_parent");
+
+ List properties = parentType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+
+ Property p1 = (Property) properties.get(0);
+ assertEquals("id", p1.getName());
+ assertEquals("Int", p1.getType().getName());
+
+ // child
+ Type childType = getType(types, "cT_10_child");
+
+ List baseTypes = childType.getBaseTypes();
+ assertEquals(1, baseTypes.size());
+ Type baseType = (Type) baseTypes.get(0);
+ assertEquals("cT_10_parent", baseType.getName());
+
+ properties = childType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+
+ Property p2 = (Property) properties.get(0);
+ assertEquals("name", p2.getName());
+ assertEquals("String", p2.getType().getName());
+ }
+
+ /**
+ * <complexType> containing <complexContent> containing <extension> of a <complexType> with abstract="true".
+ *
+ * @throws Exception
+ */
+ @Test public void testTC138ComplexTypeExtend() throws Exception {
+ List types = define("/complexType/cT_11.xsd");
+ assertTrue(types.size() >= 2);
+
+ // parent
+ Type parentType = getType(types, "cT_11_parent");
+
+ List properties = parentType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+
+ Property p1 = (Property) properties.get(0);
+
+ assertEquals("id", p1.getName());
+ assertEquals("Int", p1.getType().getName());
+
+ // child
+ Type childType = getType(types, "cT_11_child");
+
+ List baseTypes = childType.getBaseTypes();
+ assertEquals(1, baseTypes.size());
+ Type baseType = (Type) baseTypes.get(0);
+ assertEquals("cT_11_parent", baseType.getName());
+
+ properties = childType.getDeclaredProperties();
+ assertEquals(1, properties.size());
+
+ Property p2 = (Property) properties.get(0);
+
+ assertEquals("name", p2.getName());
+ assertEquals("String", p2.getType().getName());
+ }
+
+ /**
+ * <complexType> containing <simpleContent> containing <extension>.
+ *
+ * @throws Exception
+ */
+ @Test public void testTC143ComplexTypeSimpleContent() throws Exception {
+ List types = define("/complexType/cT_18.xsd");
+
+ Type type = typeHelper.getType("http://www.example.com/xsd/18/", "cT_18");
+
+ // 10.8. Corner cases
+ // ...
+ // 5. In some cases it is not possible to maintain an SDO base
+ // relationship when one exists in schema. This can happen for
+ // example when complex types extend simple types
+ //
+ // So a complexType extending a simple type doesn't have an SDO
+ // base type set
+
+ List baseTypes = type.getBaseTypes();
+ assertEquals(0, baseTypes.size());
+
+ // however complex types with simple content get a special
+ // property named "value" to represent their content
+ // p100, box 3 of the latest C++ 2.1 draft
+ // Complex Type extending a SimpleType
+ // <complexType name=[NAME]>
+ // <simpleContent>
+ // <extension
+ // base=[BASE]/>
+ // </simpleContent>
+ // </complexType>
+ //
+ // Type name=[NAME]
+ // uri=[URI]
+ // Property:
+ // name="value" type=[BASE]
+ // Properties are created for attribute
+ // declarations.
+
+ Property valueProperty = type.getProperty("value");
+ Type valueType = valueProperty.getType();
+ assertEquals("String", valueType.getName());
+ assertEquals("commonj.sdo", valueType.getURI());
+ }
+
+ /**
+ * <complexType> containing <simpleContent> containing <extension> containing <attribute>.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_19() throws Exception {
+ List types = define("/complexType/cT_19.xsd");
+
+ // parent
+ Type type = getType(types, "cT_19");
+
+ // 10.8. Corner cases
+ // ...
+ // 5. In some cases it is not possible to maintain an SDO base
+ // relationship when one exists in schema. This can happen for
+ // example when complex types extend simple types
+ //
+ // So a complexType extending a simple type doesn't have an SDO
+ // base type set
+
+ List baseTypes = type.getBaseTypes();
+ assertEquals(0, baseTypes.size());
+
+ List properties = type.getDeclaredProperties();
+ assertEquals(2, properties.size());
+
+ Property p1 = type.getProperty( "lang" );
+ assertEquals("String", p1.getType().getName());
+
+ // however complex types with simple content get a special
+ // property named "value" to represent their content
+ // p100, box 3 of the latest C++ 2.1 draft
+ // Complex Type extending a SimpleType
+ // <complexType name=[NAME]>
+ // <simpleContent>
+ // <extension
+ // base=[BASE]/>
+ // </simpleContent>
+ // </complexType>
+ //
+ // Type name=[NAME]
+ // uri=[URI]
+ // Property:
+ // name="value" type=[BASE]
+ // Properties are created for attribute
+ // declarations.
+
+ Property valueProperty = type.getProperty("value");
+ Type valueType = valueProperty.getType();
+ assertEquals("String", valueType.getName());
+ assertEquals("commonj.sdo", valueType.getURI());
+ }
+
+ /**
+ * <complexType> containing <simpleContent> containing <extension> containing <attribute>.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_22() throws Exception {
+ List types = define("/complexType/cT_22.xsd");
+
+ Type type = getType(types, "cT_22");
+ assertFalse(type.isSequenced());
+
+ // 10.8. Corner cases
+ // ...
+ // 5. In some cases it is not possible to maintain an SDO base
+ // relationship when one exists in schema. This can happen for
+ // example when complex types extend simple types
+ //
+ // So a complexType extending a simple type doesn't have an SDO
+ // base type set
+
+ List baseTypes = type.getBaseTypes();
+ assertEquals(0, baseTypes.size());
+
+ List properties = type.getDeclaredProperties();
+ assertEquals(2, properties.size());
+
+ Property p1 = type.getProperty( "lang" );
+ assertEquals("String", p1.getType().getName());
+
+ // however complex types with simple content get a special
+ // property named "value" to represent their content
+ // p100, box 3 of the latest C++ 2.1 draft
+ // Complex Type extending a SimpleType
+ // <complexType name=[NAME]>
+ // <simpleContent>
+ // <extension
+ // base=[BASE]/>
+ // </simpleContent>
+ // </complexType>
+ //
+ // Type name=[NAME]
+ // uri=[URI]
+ // Property:
+ // name="value" type=[BASE]
+ // Properties are created for attribute
+ // declarations.
+
+ Property valueProperty = type.getProperty("value");
+ Type valueType = valueProperty.getType();
+ assertEquals("String", valueType.getName());
+ assertEquals("commonj.sdo", valueType.getURI());
+ }
+
+ /**
+ * <complexType> containing <simpleContent> containing <extension> containing <attribute>
+ * containing <simpleType> containing <restriction>.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_23() throws Exception {
+ List types = define("/complexType/cT_23.xsd");
+ // two types are output the one for the complex type
+ // and the simple type
+ assertTrue(types.size() >= 2);
+ Type type = getType(types, "cT_23");
+ assertFalse(type.isSequenced());
+
+ // 10.8. Corner cases
+ // ...
+ // 5. In some cases it is not possible to maintain an SDO base
+ // relationship when one exists in schema. This can happen for
+ // example when complex types extend simple types
+ //
+ // So a complexType extending a simple type doesn't have an SDO
+ // base type set
+
+ List baseTypes = type.getBaseTypes();
+ assertEquals(0, baseTypes.size());
+
+ List properties = type.getDeclaredProperties();
+ assertEquals(2, properties.size());
+
+ Property p1 = type.getProperty( "lang" );
+ assertNotNull( p1 );
+
+ // the actual type here for the lang attribute will be
+ // the anonymous simple type, which as it's base will
+ // be commonj.sdo#String
+ Type langBaseType = (Type)p1.getType().getBaseTypes().get(0);
+ assertEquals("String", langBaseType.getName());
+
+ // however complex types with simple content get a special
+ // property named "value" to represent their content
+ // p100, box 3 of the latest C++ 2.1 draft
+ // Complex Type extending a SimpleType
+ // <complexType name=[NAME]>
+ // <simpleContent>
+ // <extension
+ // base=[BASE]/>
+ // </simpleContent>
+ // </complexType>
+ //
+ // Type name=[NAME]
+ // uri=[URI]
+ // Property:
+ // name="value" type=[BASE]
+ // Properties are created for attribute
+ // declarations.
+
+ Property valueProperty = type.getProperty("value");
+ Type valueType = valueProperty.getType();
+ assertEquals("String", valueType.getName());
+ assertEquals("commonj.sdo", valueType.getURI());
+ }
+
+ /**
+ * <complexType> containing <all> containing <element> with minOccurs="1", maxOccurs="1".
+ *
+ * @throws Exception
+ */
+ @Test public void testTC300ComplexTypeContainingAllGroupWithElements() throws Exception {
+ List types = define("/complexType/cT_24.xsd");
+ Type type = getType(types, "cT_24");
+ assertPropertyExists(type, "p1", "String", false, false);
+ }
+
+ /**
+ * <complexType> containing <sequence> containing <element> with minOccurs="1", maxOccurs="1".
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_25() throws Exception {
+ List types = define("/complexType/cT_25.xsd");
+ Type type = getType(types, "cT_25");
+ assertPropertyExists(type, "p1", "String", false, false);
+ }
+
+ /**
+ * <complexType> containing <sequence> containing <element> with minOccurs="0", maxOccurs="unbounded".
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_26() throws Exception {
+ List types = define("/complexType/cT_26.xsd");
+ Type type = getType(types, "cT_26");
+ assertPropertyExists(type, "p1", "String", false, true);
+ }
+
+ /**
+ * <complexType> containing <sequence> containing <element> with minOccurs="1", maxOccurs="unbounded".
+ *
+ * @throws Exception
+ */
+ @Test public void testTC299ComplexTypeContainingUnboundedElement() throws Exception {
+ List types = define("/complexType/cT_27.xsd");
+ Type type = typeHelper.getType("http://www.example.com/xsd/27/", "cT_27");
+ assertPropertyExists(type, "p1", "String", false, true);
+ }
+
+ /**
+ * <complexType> containing an <element> for each XSD type supported by SDO.
+ *
+ * @throws Exception
+ */
+ @Test public void testTC297ComplexTypeContainingElementsOfAllTypes() throws Exception {
+ List types = define("/complexType/cT_28.xsd");
+
+ Type type = getType(types, "cT_28");
+ assertFalse(type.isSequenced());
+ assertEquals( 44, type.getProperties().size() );
+ assertPropertyExists(type, "type_date", "YearMonthDay", false, false);
+ assertPropertyExists(type, "type_dateTime", "DateTime", false, false);
+ assertPropertyExists(type, "type_decimal", "Decimal", false, false);
+ assertPropertyExists(type, "type_double", "Double", false, false);
+ assertPropertyExists(type, "type_duration", "Duration", false, false);
+ assertPropertyExists(type, "type_float", "Float", false, false);
+ assertPropertyExists(type, "type_gDay", "Day", false, false);
+ assertPropertyExists(type, "type_gMonth", "Month", false, false);
+ assertPropertyExists(type, "type_gMonthDay", "MonthDay", false, false);
+ assertPropertyExists(type, "type_gYear", "Year", false, false);
+ assertPropertyExists(type, "type_gYearMonth", "YearMonth", false, false);
+ assertPropertyExists(type, "type_int", "Int", false, false);
+ assertPropertyExists(type, "type_integer", "Integer", false, false);
+ assertPropertyExists(type, "type_long", "Long", false, false);
+ assertPropertyExists(type, "type_negativeInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_nonNegativeInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_nonPositiveInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_positiveInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_short", "Short", false, false);
+ assertPropertyExists(type, "type_string", "String", false, false);
+ assertPropertyExists(type, "type_time", "Time", false, false);
+ assertPropertyExists(type, "type_unsignedByte", "Short", false, false);
+ assertPropertyExists(type, "type_unsignedInt", "Long", false, false);
+ assertPropertyExists(type, "type_unsignedLong", "Integer", false, false);
+ assertPropertyExists(type, "type_unsignedShort", "Int", false, false);
+ assertPropertyExists(type, "type_anyType", "DataObject", true, false);
+ assertPropertyExists(type, "type_anyURI", "URI", false, false);
+ assertPropertyExists(type, "type_base64Binary", "Bytes", false, false);
+ assertPropertyExists(type, "type_byte", "Byte", false, false);
+ assertPropertyExists(type, "type_ENTITY", "String", false, false);
+ assertPropertyExists(type, "type_hexBinary", "Bytes", false, false);
+ assertPropertyExists(type, "type_ID", "String", false, false);
+ assertPropertyExists(type, "type_IDREF", "String", false, false);
+ assertPropertyExists(type, "type_language", "String", false, false);
+ assertPropertyExists(type, "type_Name", "String", false, false);
+ assertPropertyExists(type, "type_NCName", "String", false, false);
+ assertPropertyExists(type, "type_QName", "URI", false, false);
+ assertPropertyExists(type, "type_token", "String", false, false);
+ assertPropertyExists(type, "type_NMTOKEN", "String", false, false);
+ assertPropertyExists(type, "type_NMTOKENS", "Strings", false, false);
+ assertPropertyExists(type, "type_IDREFS", "Strings", false, false);
+ assertPropertyExists(type, "type_ENTITIES", "Strings", false, false);
+ assertPropertyExists(type, "type_anySimpleType", "Object", false, false);
+ }
+
+ /**
+ * <complexType> containing an <attribute> for each XSD type supported by SDO.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_29() throws Exception {
+ List types = define("/complexType/cT_29.xsd");
+
+ Type type = getType(types, "cT_29");
+ assertFalse(type.isSequenced());
+ assertPropertyExists(type, "type_date", "YearMonthDay", false, false);
+ assertPropertyExists(type, "type_dateTime", "DateTime", false, false);
+ assertPropertyExists(type, "type_decimal", "Decimal", false, false);
+ assertPropertyExists(type, "type_double", "Double", false, false);
+ assertPropertyExists(type, "type_duration", "Duration", false, false);
+ assertPropertyExists(type, "type_float", "Float", false, false);
+ assertPropertyExists(type, "type_gDay", "Day", false, false);
+ assertPropertyExists(type, "type_gMonth", "Month", false, false);
+ assertPropertyExists(type, "type_gMonthDay", "MonthDay", false, false);
+ assertPropertyExists(type, "type_gYear", "Year", false, false);
+ assertPropertyExists(type, "type_gYearMonth", "YearMonth", false, false);
+ assertPropertyExists(type, "type_int", "Int", false, false);
+ assertPropertyExists(type, "type_integer", "Integer", false, false);
+ assertPropertyExists(type, "type_long", "Long", false, false);
+ assertPropertyExists(type, "type_negativeInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_nonNegativeInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_nonPositiveInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_positiveInteger", "Integer", false, false);
+ assertPropertyExists(type, "type_short", "Short", false, false);
+ assertPropertyExists(type, "type_string", "String", false, false);
+ assertPropertyExists(type, "type_time", "Time", false, false);
+ assertPropertyExists(type, "type_unsignedByte", "Short", false, false);
+ assertPropertyExists(type, "type_unsignedInt", "Long", false, false);
+ assertPropertyExists(type, "type_unsignedLong", "Integer", false, false);
+ assertPropertyExists(type, "type_unsignedShort", "Int", false, false);
+ assertPropertyExists(type, "type_anyURI", "URI", false, false);
+ assertPropertyExists(type, "type_base64Binary", "Bytes", false, false);
+ assertPropertyExists(type, "type_byte", "Byte", false, false);
+ assertPropertyExists(type, "type_ENTITIES", "Strings", false, false);
+ assertPropertyExists(type, "type_ENTITY", "String", false, false);
+ assertPropertyExists(type, "type_hexBinary", "Bytes", false, false);
+ assertPropertyExists(type, "type_ID", "String", false, false);
+ assertPropertyExists(type, "type_IDREF", "String", false, false);
+ assertPropertyExists(type, "type_IDREFS", "Strings", false, false);
+ assertPropertyExists(type, "type_language", "String", false, false);
+ assertPropertyExists(type, "type_Name", "String", false, false);
+ assertPropertyExists(type, "type_NMTOKEN", "String", false, false);
+ assertPropertyExists(type, "type_NMTOKENS", "Strings", false, false);
+ assertPropertyExists(type, "type_QName", "URI", false, false);
+ assertPropertyExists(type, "type_token", "String", false, false);
+ assertPropertyExists(type, "type_NCName", "String", false, false);
+ assertPropertyExists(type, "type_anySimpleType", "Object", false, false);
+ }
+
+ /**
+ * <complexType> containing a <sequence> which contains a <group> reference and an <element>. The <group>
+ * also contains a <sequence>.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_30() throws Exception {
+ List types = define("/complexType/cT_30.xsd");
+
+ Type type = getType(types, "cT_30");
+ assertFalse(type.isSequenced());
+ assertPropertyExists(type, "p1", "String", false, false);
+ assertPropertyExists(type, "p2", "String", false, false);
+ assertPropertyExists(type, "p3", "Int", false, false);
+ }
+
+ /**
+ * <complexContent> using <extension> to extend another <complexContent>. The derived <complexContent>
+ * references a <group> which contains a <sequence>.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_31() throws Exception {
+ List types = define("/complexType/cT_31.xsd");
+ assertTrue(types.size() >= 2);
+
+ Type type = getType(types, "cT_31");
+ assertFalse(type.isSequenced());
+ assertPropertyExists(type, "p1", "String", false, false);
+ assertPropertyExists(type, "p2", "String", false, false);
+ assertPropertyExists(type, "p3", "Int", false, false);
+ assertPropertyExists(type, "p4", "String", false, false);
+ assertPropertyExists(type, "p5", "String", false, false);
+ }
+
+ /**
+ * <complexType> with mixed="true". Must create SDO Type with sequenced="true".
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_42() throws Exception {
+ List types = define("/complexType/cT_42.xsd");
+
+ Type type = getType(types, "cT_42");
+ assertTrue(type.isSequenced());
+ assertPropertyExists(type, "id", "Int", false, false);
+ assertPropertyExists(type, "name", "String", false, false);
+ }
+
+
+ /**
+ * <complexType> containing <any> with maxOccurs="unbounded". Should map to SDO Type with
+ * sequenced="true" and no declared properties.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_43() throws Exception {
+ List types = define("/complexType/cT_43.xsd");
+
+ Type type = getType(types, "cT_43");
+ assertTrue(type.isOpen());
+ assertEquals(0, type.getProperties().size());
+ }
+
+ /**
+ * <complexType> containing <any> with maxOccurs="1". Should map to SDO Type with
+ * sequenced="false" and no declared properties.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_44() throws Exception {
+ List types = define("/complexType/cT_44.xsd");
+
+ Type type = getType(types, "cT_44");
+ assertTrue(type.isOpen());
+ assertFalse(type.isSequenced());
+ assertEquals(0, type.getProperties().size());
+ }
+
+ /**
+ * <complexType> containing <anyAttribute> . Should map to SDO Type with
+ * no declared properties.
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_45() throws Exception {
+ List types = define("/complexType/cT_45.xsd");
+
+ Type type = getType(types, "cT_45");
+ assertTrue(type.isOpen());
+ assertFalse(type.isSequenced());
+ assertEquals(0, type.getProperties().size());
+ }
+
+ /**
+ * <complexType> containing element with nillable="true"
+ *
+ * @throws Exception
+ */
+ @Test public void test_cT_46() throws Exception {
+
+ List types = define("/complexType/cT_46.xsd");
+
+ Type type = (Type) types.get(0);
+ assertFalse(type.isSequenced());
+ assertFalse(type.isOpen());
+ assertFalse(type.isDataType());
+ assertFalse(type.isAbstract());
+ assertEquals("cT_46", type.getName());
+
+ assertPropertyExists(type, "id", "Int", false, false);
+ assertPropertyExists(type, "name", "String", false, false);
+
+ assertEquals( false, type.getProperty("id").isNullable() );
+ assertEquals( true, type.getProperty("name").isNullable() );
+ }
+
+ /**
+ * <complexType> containing an anySimpletype element
+ *
+ * @throws Exception
+ */
+ @Test public void testTC298ComplexTypeSetAnySimpleTypeWithStringValue() throws Exception {
+ List types = define("/complexType/cT_47.xsd");
+
+ DataObject dobj = getScope().getDataFactory().create( "http://www.example.com/xsd/47/", "cT_47" );
+ Property p = dobj.getProperty( "type_anySimpleType" );
+ assertNotNull( p );
+
+ assertEquals( "commonj.sdo", p.getType().getURI() );
+ assertEquals( "Object", p.getType().getName() );
+
+ dobj.set( "type_anySimpleType", "foo" );
+ assertEquals( "foo", dobj.get( "type_anySimpleType") );
+ }
+
+ @Test public void test_cT_48() throws IOException {
+ List types = define("/complexType/cT_48.xsd");
+ assertTrue(types.size() >= 4);
+
+ Type t1 = getType(types, "complextype1");
+ Property p1 = t1.getProperty("person");
+ assertNotNull(p1);
+
+ Type t2 = getType(types, "complextype2");
+ Property p2 = t2.getProperty("person");
+ assertNotNull(p2);
+
+ // although the 2.1 spec says that the name of the anonymous types should be the same as the name of the
+ // enclosing element or attribute, this would result in a name clash so we need to ensure that the type
+ // names are not the same
+ String typeName1 = p1.getType().getName();
+ String typeName2 = p2.getType().getName();
+ assertFalse( typeName1.equals(typeName2) );
+ }
+
+}
+
+