diff options
Diffstat (limited to 'java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java')
-rw-r--r-- | java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java | 354 |
1 files changed, 0 insertions, 354 deletions
diff --git a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java b/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java deleted file mode 100644 index 5f5c23ad5f..0000000000 --- a/java/sdo-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * 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. - * - * $Rev$ $Date$ - */ -package test.sdo21.tests.api; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import test.sdo21.tests.TestData.StandardDynamicFactory; -import test.sdo21.tests.TestData.StandardFactory; -import test.sdo21.tests.TestData.StandardXSDFactory; -import test.sdo21.tests.TestData.TestDataFactory; - -import commonj.sdo.Property; -import commonj.sdo.Type; - - -public abstract class TypeTest extends CTSConsistencyBase { - public TypeTest() { - } - - public static class DynamicMetadata extends TypeTest { - public DynamicMetadata() { - - } - public TestDataFactory createTestDataFactory() { - - return new StandardDynamicFactory(); - } - } - - public static class XSDMetadata extends TypeTest { - - public XSDMetadata() { - } - - public TestDataFactory createTestDataFactory() { - - return new StandardXSDFactory(); - } - } - - - @Before - public void setUp () throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Verify the value returned by Type.getName() - */ - @Test - public void typeGetName() { - Type type = testDO.getType(); - assertEquals("Type.getName() returned an unexpected value.", StandardFactory.API_TYPE, type.getName()); - } - - /** - * Verify the value returned by Type.getURI() - */ - @Test - public void typeGetURI() { - Type type = testDO.getType(); - assertEquals("Type.getURI() returned an unexpected value.", StandardFactory.TEST_NAMESPACE, type.getURI()); - } - - - /** - * Verify the value returned by Type.isInstance() == true - */ - @Test - public void typeIsInstanceTrue() { - Type type = testDO.getType(); - - assertTrue("Type.getInstance() returned an unexpected value.", type.isInstance(testDO)); - } - - /** - * Verify the value returned by Type.isInstance() == false - */ - @Test - public void typeIsInstanceFalse() { - Type booleanType = testDO.getInstanceProperty("booleanVal").getType(); - Type type = testDO.getType(); - - assertFalse("Type.getInstance() returned an unexpected value.", type.isInstance(booleanType)); - } - - /** - * Verify the value returned by Type.isDataType() == true - */ - @Test - public void typeIsDataTypeTrue() { - Type booleanType = testDO.getInstanceProperty("booleanVal").getType(); - - assertTrue("Type.isDataType() returned an unexpected value.", booleanType.isDataType()); - } - - /** - * Verify the value returned by Type.isDataType() == False - */ - @Test - public void typeIsDataTypeFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isDataType() returned an unexpected value.", type.isDataType()); - } - - /** - * Verify the value returned by Type.isSequenced() == true - */ - @Test - public void typeIsSequencedTrue() { - Type sequencedType = testDO.getInstanceProperty("sequencedElem").getType(); - - assertTrue("Type.isSequenced() returned an unexpected value.", sequencedType.isSequenced()); - } - - /** - * Verify the value returned by Type.isSequenced() == False - */ - @Test - public void typeIsSequencedFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isSequenced() returned an unexpected value.", type.isSequenced()); - } - - /** - * Verify the value returned by Type.isOpen() == true - */ - @Test - public void typeIsOpenTrue() { - Type type = testDO.getInstanceProperty("openElem").getType(); - assertTrue("Type.isOpen() returned an unexpected value.", type.isOpen()); - } - - /** - * Verify the value returned by Type.isOpen() == False - */ - @Test - public void typeIsOpenFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isOpen() returned an unexpected value.", type.isOpen()); - } - - /** - * Verify the value returned by Type.isAbstract() == true - */ - @Test - public void typeIsAbstractTrue() { - Type abstractType = - getScope().getTypeHelper().getType(StandardFactory.TEST_NAMESPACE, StandardFactory.ABSTRACT_TYPE); - - assertTrue("Type.isAbstract() returned an unexpected value.", abstractType.isAbstract()); - } - - /** - * Verify the value returned by Type.isAbstract() == False - */ - @Test - public void typeIsAbstractFalse() { - Type type = testDO.getType(); - - assertFalse("Type.isAbstract() returned an unexpected value.", type.isAbstract()); - } - - /** - * Verify the value returned by Type.getBaseTypes() when there are no base - * types - */ - @Test - public void typeGetBaseTypesNone() { - Type type = testDO.getType(); - - assertEquals("Type.getBaseTypes() returned a List of unexpected size.", 0, type.getBaseTypes().size()); - } - - /** - * Verify the value returned by Type.getBaseTypes() when there are base - * Types to return - */ - @Test - public void typeGetBaseTypes() { - Type extendedType = testDO.getInstanceProperty("extendedElem").getType(); - - assertNotSame("Type.getBaseTypes() did not return the expected base type.", 0, extendedType.getBaseTypes() - .size()); - } - - /** - * Verify the value returned by Type.getAliasNames() when there are no alias - * names - */ - @Test - public void typeGetAliasNamesNone() { - Type type = testDO.getType(); - - assertEquals("Type.getAliasNames() returned a List of unexpected size.", 0, type.getAliasNames().size()); - } - - /** - * Verify the List returned by Type.getProperties() - */ - @Test - public void typeGetProperties() { - Type type = testDO.getType(); - - assertTrue("Type.getProperties() did not return the expected List.", verifyPropertyList(type.getProperties())); - } - - /** - * Verify the List returned by Type.getDeclaredProperties() - */ - @Test - public void typeGetDeclaredProperties() { - Type type = testDO.getType(); - - assertTrue("Type.getProperties() did not return the expected List.", verifyPropertyList(type - .getDeclaredProperties())); - } - - /** - * Verify the value returned by Type.getProperty() - */ - @Test - public void typeGetProperty() { - Type type = testDO.getType(); - - assertEquals("Type.getProperty() returned an unexpected Property.", "booleanVal", type - .getProperty("booleanVal").getName()); - } - - /** - * Verify the handling of an inaccurate name by Type.getProperty() - */ - @Test - public void typeGetPropertyInvalidString() { - Type type = testDO.getType(); - - assertNull("Type.getProperty() returned an unexpected Property.", type.getProperty("madeUpName")); - } - - /** - * verifyPropertyList is a private method used to ensure that all expected - * Properties are contained in the input List - * - * @param properties - * @return - */ - private static boolean verifyPropertyList(List properties) { - boolean stringValFound = false, booleanValFound = false, booleanVal2Found = false, byteValFound = false; - boolean stringVal2Found = false, decimalValFound = false, decimalVal2Found = false, intValFound = false; - boolean floatValFound = false, doubleValFound = false, dateValFound = false, shortValFound = false, longValFound = - false; - boolean containManyFound = false, bytesValFound = false, integerValFound = false, charValFound = false, sequencedElemFound = - false; - - Property currProperty; - for (int i = 0; i < properties.size(); i++) { - currProperty = (Property)properties.get(i); - - if (!stringValFound && currProperty.getName().equals("stringVal")) - stringValFound = true; - else if (!booleanValFound && currProperty.getName().equals("booleanVal")) - booleanValFound = true; - else if (!booleanVal2Found && currProperty.getName().equals("booleanVal2")) - booleanVal2Found = true; - else if (!byteValFound && currProperty.getName().equals("byteVal")) - byteValFound = true; - else if (!stringVal2Found && currProperty.getName().equals("stringVal2")) - stringVal2Found = true; - else if (!decimalValFound && currProperty.getName().equals("decimalVal")) - decimalValFound = true; - else if (!decimalVal2Found && currProperty.getName().equals("decimalVal2")) - decimalVal2Found = true; - else if (!intValFound && currProperty.getName().equals("intVal")) - intValFound = true; - else if (!floatValFound && currProperty.getName().equals("floatVal")) - floatValFound = true; - else if (!doubleValFound && currProperty.getName().equals("doubleVal")) - doubleValFound = true; - else if (!dateValFound && currProperty.getName().equals("dateVal")) - dateValFound = true; - else if (!shortValFound && currProperty.getName().equals("shortVal")) - shortValFound = true; - else if (!longValFound && currProperty.getName().equals("longVal")) - longValFound = true; - else if (!containManyFound && currProperty.getName().equals("containMany")) - containManyFound = true; - else if (!bytesValFound && currProperty.getName().equals("bytesVal")) - bytesValFound = true; - else if (!integerValFound && currProperty.getName().equals("integerVal")) - integerValFound = true; - else if (!charValFound && currProperty.getName().equals("charVal")) - charValFound = true; - else if (!sequencedElemFound && currProperty.getName().equals("sequencedElem")) - sequencedElemFound = true; - } - - if (stringValFound && booleanValFound - && booleanVal2Found - && byteValFound - && stringVal2Found - && decimalValFound - && decimalVal2Found - && intValFound - && floatValFound - && doubleValFound - && dateValFound - && shortValFound - && longValFound - && containManyFound - && bytesValFound - && integerValFound - && charValFound - && sequencedElemFound) - return true; - else - return false; - } -} |