diff options
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDChoiceTest.java')
-rw-r--r-- | sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDChoiceTest.java | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDChoiceTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDChoiceTest.java new file mode 100644 index 0000000000..3f30fe590a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDChoiceTest.java @@ -0,0 +1,173 @@ +/* + * 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 commonj.sdo.Type; +import org.junit.Test; +import static org.junit.Assert.*; + +public class XSDChoiceTest extends XSDBaseTestCase { + + /** + * @throws Exception if an exception occurs + */ + @Test + public void testTC224_Choice() throws Exception + { + // load the schema and obtain TypeList + List typeList = define( "/choice/TC224.xsd" ); + + // assert that the correct number of SDO Types were created + assertTrue( typeList.size() > 0 ); + + Type choiceType = typeHelper.getType("http://www.example.com/TC224","choiceType"); + assertNotNull( choiceType ); + + // make assertion on the SDO Type + assertEquals( "choiceType", choiceType.getName() ); + assertFalse( choiceType.isDataType() ); + assertFalse( choiceType.isOpen() ); + assertFalse( choiceType.isSequenced() ); + + List propList = choiceType.getProperties(); + assertEquals( 3, propList.size() ); + + // assert SDO Properties were created with correct type ... + assertPropertyExists( choiceType, "red", "DataObject", true, false ); + assertFalse( choiceType.getProperty("red").isReadOnly() ); + + assertPropertyExists( choiceType, "green", "DataObject", true, false ); + assertFalse( choiceType.getProperty("green").isReadOnly() ); + + assertPropertyExists( choiceType, "blue", "DataObject", true, false ); + assertFalse( choiceType.getProperty("blue").isReadOnly() ); + } + + /** + * @throws Exception if an exception occurs + */ + @Test + public void testTC225_Choice() throws Exception + { + // load the schema and obtain TypeList + List typeList = define( "/choice/TC225.xsd" ); + + // assert that the correct number of SDO Types were created + assertTrue( typeList.size() > 0 ); + + Type choiceType = typeHelper.getType("http://www.example.com/TC225","choiceType"); + assertNotNull( choiceType ); + + // make assertion on the SDO Type + assertEquals( "choiceType", choiceType.getName() ); + assertFalse( choiceType.isDataType() ); + assertFalse( choiceType.isOpen() ); + + // this type should have sequenced=true because the choice is unbounded + assertTrue( choiceType.isSequenced() ); + + List propList = choiceType.getProperties(); + assertEquals( 3, propList.size() ); + + // assert SDO Properties were created with correct type ... + assertPropertyExists( choiceType, "red", "DataObject", true, true ); + assertFalse( choiceType.getProperty("red").isReadOnly() ); + + assertPropertyExists( choiceType, "green", "DataObject", true, true ); + assertFalse( choiceType.getProperty("green").isReadOnly() ); + + assertPropertyExists( choiceType, "blue", "DataObject", true, true ); + assertFalse( choiceType.getProperty("blue").isReadOnly() ); + } + + /** + * @throws Exception if an exception occurs + */ + @Test + public void testTC226_Choice() throws Exception + { + // load the schema and obtain TypeList + List typeList = define( "/choice/TC226.xsd" ); + + // assert that the correct number of SDO Types were created + assertTrue( typeList.size() > 0 ); + + Type choiceType = typeHelper.getType("http://www.example.com/TC226","choiceType"); + assertNotNull( choiceType ); + + // make assertion on the SDO Type + assertEquals( "choiceType", choiceType.getName() ); + assertFalse( choiceType.isDataType() ); + assertFalse( choiceType.isOpen() ); + assertFalse( choiceType.isSequenced() ); + + List propList = choiceType.getProperties(); + assertEquals( 3, propList.size() ); + + // assert SDO Properties were created with correct type ... + assertPropertyExists( choiceType, "red", "String", false, false ); + assertFalse( choiceType.getProperty("red").isReadOnly() ); + + assertPropertyExists( choiceType, "green", "DataObject", true, false ); + assertFalse( choiceType.getProperty("green").isReadOnly() ); + + assertPropertyExists( choiceType, "blue", "DataObject", true, false ); + assertFalse( choiceType.getProperty("blue").isReadOnly() ); + } + + /** + * @throws Exception if an exception occurs + */ + @Test + public void testTC227_Choice() throws Exception + { + // load the schema and obtain TypeList + List typeList = define( "/choice/TC227.xsd" ); + + // assert that the correct number of SDO Types were created + assertTrue( typeList.size() > 0 ); + + Type choiceType = typeHelper.getType("http://www.example.com/TC227","choiceType"); + assertNotNull( choiceType ); + + // make assertion on the SDO Type + assertEquals( "choiceType", choiceType.getName() ); + assertFalse( choiceType.isDataType() ); + assertFalse( choiceType.isOpen() ); + + // the choice has maxOccurs > 1 so this type should be sequenced + assertTrue( choiceType.isSequenced() ); + + List propList = choiceType.getProperties(); + assertEquals( 3, propList.size() ); + + // assert SDO Properties were created with correct type ... + assertPropertyExists( choiceType, "red", "DataObject", true, true ); + assertFalse( choiceType.getProperty("red").isReadOnly() ); + + assertPropertyExists( choiceType, "green", "DataObject", true, true ); + assertFalse( choiceType.getProperty("green").isReadOnly() ); + + assertPropertyExists( choiceType, "blue", "DataObject", true, true ); + assertFalse( choiceType.getProperty("blue").isReadOnly() ); + } +} |