summaryrefslogtreecommitdiffstats
path: root/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java')
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java139
1 files changed, 139 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java
new file mode 100644
index 0000000000..cc32e6a0cb
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyBase.java
@@ -0,0 +1,139 @@
+/*
+ * 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: 537762 $ $Date: 2007-05-14 10:38:19 +0100 (Mon, 14 May 2007) $
+ */
+package test.sdo21.tests.api.DataFactory;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.api.CTSConsistencyBase;
+import test.sdo21.tests.util.CTSUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+
+public abstract class DataFactoryConsistencyBase extends CTSConsistencyBase {
+
+
+ @Before
+ public void setUp () throws Exception {
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Verify the proper operation of DataFactory.create(Type).
+ */
+ @Test
+ public void testDataFactoryCreateByType() {
+ Type type = testDO.getType();
+
+ DataObject typeDO = getScope().getDataFactory().create(type);
+
+ assertNotNull("DataFactory.create(Type) did not return a DataObject as expected", typeDO);
+
+ assertTrue("DataFactory.create(Type) did not return a DataObject of the expected Type.", CTSUtil.areEqualTypes(typeDO.getType(), type));
+ }
+
+ /**
+ * Verify the proper operation of DataFactory.create(URI, Name).
+ */
+ @Test
+ public void testDataFactoryCreateByURI() {
+ Type type = testDO.getType();
+
+ DataObject uriDO = getScope().getDataFactory().create(type.getURI(), type.getName());
+
+ assertNotNull("DataFactory.create(URI, Name) did not return a DataObject as expected.", uriDO);
+
+ assertTrue("DataFactory.create(URI, Name) did not return a DataObject of the expected Type.",
+ CTSUtil.areEqualTypes(uriDO.getType(), type));
+ }
+
+ /**
+ * Verify the proper operation of DataFactory.create(Class).
+ */
+ @Test
+ public void testDataFactoryCreateByClass() {
+ Type type = testDO.getType();
+
+ if (type.getInstanceClass() != null) {
+ DataObject classDO = getScope().getDataFactory().create(type.getInstanceClass());
+
+ assertNotNull("DataFactory.create(Class) did not return a DataObject as expected.", classDO);
+
+ assertTrue("DataFactory.create(Class) did not return a DataObject of the expected Type.",
+ CTSUtil.areEqualTypes(classDO.getType(), type));
+ }
+ }
+
+ /**
+ * Verify that DataFactory.create with DataType results in
+ * IllegalArgumentException
+ */
+ @Test
+ public void testDataFactoryCreateDataTypeException() {
+ try {
+ Type dataType = getScope().getTypeHelper().getType("commonj.sdo", "Int");
+ assertTrue("Could not test DataFactory.create(dataType) because dataType.isDataType = false", dataType
+ .isDataType());
+ getScope().getDataFactory().create(dataType);
+ fail("DataFactory.create(dataType) did not throw an Exception.");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ } catch (Exception e) {
+ fail("DataFactory.create(dataType) did not throw the expected IllegalArgumentException Exception.");
+ }
+ }
+
+ /**
+ * Verify that DataFactory.create with Abstract Type results in
+ * IllegalArgumentException.
+ */
+ @Test
+ public void testDataFactoryCreateAbstractException() {
+ try {
+ Type abstractType =
+ getScope().getTypeHelper().getType(StandardFactory.TEST_NAMESPACE, "Abstract");
+
+ assertTrue("Could not test DataFactory.create(abstractType) because abstractType.isAbstract = false",
+ abstractType.isAbstract());
+ getScope().getDataFactory().create(abstractType);
+ fail("DataFactory.create(abstractType) did not throw an Exception.");
+
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ } catch (Exception e) {
+ fail("DataFactory.create(abstractType) did not throw the expected IllegalArgumentException Exception.");
+ }
+ }
+
+
+}