summaryrefslogtreecommitdiffstats
path: root/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework
diff options
context:
space:
mode:
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework')
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java78
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/DataObjectFactory.java71
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/TestHelper.java190
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java62
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/package.html25
5 files changed, 426 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java
new file mode 100644
index 0000000000..4fd3e71541
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java
@@ -0,0 +1,78 @@
+/*
+ * 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.framework;
+
+import junit.framework.TestCase;
+import commonj.sdo.helper.HelperContext;
+
+/**
+ * A superclass for tests classes. It creates a HelperContext per test case invocation
+ * and provides initialization/access to the implementation sepcific test helper.
+ * See also the {@link test.sdo21.framework.junit3_8.CTSTestCase} Junit 3.8 variant of this
+ * class which inherits from {@link TestCase} in the junit 3.8 style of testing,
+ * but delegates to this class for much of its CTS function.
+ */
+public class CTSTestCase {
+
+ private static TestHelper testHelper = null;
+ private HelperContext scope = null;
+ public static final String SDO_CTS_TESTHELPER_CLASS = "CTS_TEST_HELPER";
+
+ private static void initTestHelper() throws Exception {
+ String helperClassName = System.getenv(SDO_CTS_TESTHELPER_CLASS);
+
+ if ((helperClassName == null) || (helperClassName.equals(""))) {
+ System.out.println(SDO_CTS_TESTHELPER_CLASS + " was not set - attempting Tuscany implementation : "
+ + helperClassName);
+ helperClassName = "test.sdo21.vendor.tuscany.testHelper.TuscanyTestHelper";
+ }
+
+ testHelper = (TestHelper)Class.forName(helperClassName).newInstance();
+ System.out.println("Loaded " + helperClassName);
+ // initialize SDO implementation
+ testHelper.init();
+ }
+
+
+ public void setUp() throws Exception {
+ scope = getTestHelper().createHelperContext();
+ }
+
+
+ public void tearDown() throws Exception {
+ scope = null;
+ }
+
+ public HelperContext getScope() {
+ return scope;
+ }
+
+ public static TestHelper getTestHelper() {
+ if(testHelper == null) {
+ try {
+ initTestHelper();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return testHelper;
+ }
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/DataObjectFactory.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/DataObjectFactory.java
new file mode 100644
index 0000000000..35feecce79
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/DataObjectFactory.java
@@ -0,0 +1,71 @@
+/*
+ * 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.framework;
+
+import test.sdo21.tests.ConsistencyTestTemplate;
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+import test.sdo21.tests.api.CTSConsistencyBase;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+
+/**
+ * Vendors can provide an implementation of this interface to provide
+ * DataObjects in the appropriate manner for the test scenario.
+ * @deprecated
+ * @see TestDataFactory
+ * @see CTSConsistencyBase
+ * @see StandardFactory
+ * @see ConsistencyTestTemplate
+ */
+public interface DataObjectFactory {
+
+ /**
+ * Returns the scoped used for this DataObjectFactory
+ * @return
+ */
+ public HelperContext getHelperContext();
+
+ /**
+ * Returns the name of the static package used for this DataObjectFactory.
+ * Returns null in the case of dynamic.
+ * @return
+ */
+ public String getPackage();
+
+ /**
+ * Creates and returns a DataObject of Type 'APITest'
+ * @return
+ */
+ public DataObject createTestAPIObject();
+
+ /**
+ * Creates and returns a DataObject of Type 'Sequenced'
+ * @return
+ */
+ public DataObject createSequencedObject();
+
+ /**
+ * Creates and returns a DataObject of Type 'Extended'
+ * @return
+ */
+ public DataObject createExtendedObject();
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/TestHelper.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/TestHelper.java
new file mode 100644
index 0000000000..7bbe7ee11d
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/TestHelper.java
@@ -0,0 +1,190 @@
+/*
+ * 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.framework;
+
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+
+import test.sdo21.tests.ConsistencyTestTemplate;
+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 test.sdo21.tests.util.CTSUtil;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+
+/**
+ * Vendors can provide an implementation of this interface to bootstrap their
+ * SDO implementation.
+ */
+public interface TestHelper {
+
+ public static final String INCOMPLETE_TEST_CASE_FAILURE = "The following test case is incomplete";
+
+ /**
+ * Initialize the SDO implementation being tests.
+ */
+ public void init();
+
+ /**
+ * Returns collection containing DataObject, String pairs to be used as
+ * arguments to paramatized test cases. DataObjects should adhere to
+ * api_test.xsd and should be populated. The String should be a description
+ * of the mechanism used to create and populate the DataObject.
+ *
+ * @deprecated @see {@link ConsistencyTestTemplate}
+ */
+ public Collection getParamatizedDataObject();
+
+ /**
+ * Convenience method for creating a type definition.
+ *
+ * @param uri
+ * @param name
+ * @param helperContext
+ * @return
+ * @deprecated
+ * @see CTSUtil
+ */
+ public DataObject createTypeDef(String uri, String name, boolean open, HelperContext helperContext);
+
+ /**
+ * Convenience method for creating a property definition
+ *
+ * @param typeDef The type definition that this property should be added to
+ * @param name The name for the property
+ * @param type The type to assign to the property
+ * @param isMany
+ * @param isContainment
+ * @return
+ * @deprecated
+ * @see CTSUtil
+ */
+ public DataObject createPropertyDef(DataObject typeDef,
+ String name,
+ Type type,
+ boolean isMany,
+ boolean isContainment);
+
+ /**
+ * Convenience method for creating a property definition
+ *
+ * @param typeDef The type definition that this property should be added to
+ * @param name The name for the property
+ * @param type The type to assign to the property e.g.
+ * "commonj.sdo#DataObject"
+ * @param isMany
+ * @param isContainment
+ * @param helperContext
+ * @return
+ *
+ * @deprecated
+ * @see CTSUtil
+
+ */
+ public DataObject createPropertyDef(DataObject typeDef,
+ String name,
+ String type,
+ boolean isMany,
+ boolean isContainment,
+ HelperContext helperContext);
+
+ /**
+ * Convenience method for creating a unique name that can be used for a
+ * property or type.
+ *
+ * @return String containing a unique name
+ *
+ * @deprecated
+ * @see CTSUtil
+
+ */
+ public String createUniqueName();
+
+ /**
+ * Create an empty data graph.
+ *
+ * @return the new data graph instance.
+ */
+ public DataGraph createDataGraph();
+
+ /**
+ * Create a new HelperContext, a new scope
+ *
+ * @return the new HelperContext instance.
+ */
+ public HelperContext createHelperContext();
+
+ /**
+ * Create a new DataObjectFactory
+ *
+ * @return the new DataObjectFactory instance.
+ * @deprecated
+ * @see TestDataFactory
+ * @see StandardFactory
+ * @see StandardDynamicFactory
+ * @see StandardXSDFactory
+ *
+ */
+ public DataObjectFactory createDataObjectFactory(String factory,
+ HelperContext helperContext);
+
+ /**
+ * @return Static SDO that adhere's to simple.xsd
+
+ public DataObject getSimpleSDO();
+ */
+ /**
+ * @return Static Quote SDO from simple.xsd defintion.
+
+ public DataObject getSimpleQuoteSDO();
+ */
+
+ /**
+ * Create a new ObjectOutputStream
+ *
+ * @return the new ObjectOutputStream instance.
+ */
+ public ObjectOutputStream createObjectOutputStream(OutputStream os,
+ HelperContext helperContext);
+
+ /**
+ * Create a new ObjectInutStream
+ *
+ * @return the new ObjectInputStream instance.
+ */
+ public ObjectInputStream createObjectInputStream(InputStream is,
+ HelperContext helperContext);
+
+ /**
+ * Serialize a DataObject using an XMLStreamHelper
+ */
+// public void serializeViaXMLStreamHelper(TypeHelper typeHelper,
+// DataObject dataObject,
+// XMLStreamWriter serializer);
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java
new file mode 100644
index 0000000000..c7d202b6b0
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * 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.framework.junit3_8;
+
+import test.sdo21.framework.TestHelper;
+import commonj.sdo.helper.HelperContext;
+
+import junit.framework.TestCase;
+
+public class CTSTestCase extends TestCase {
+
+ /*
+ * The CTS is designed to be invoked by arbitrary test harnesses but has affinity to junit.
+ * Some test classes are written in the junit 3.8 style where they must inherit from TestCase.
+ * Others are written in the 4.1 style. The pair of CTSTestCase superclasses support both these
+ * approaches. This class minimises duplication by delegating much function to the 4.1 style class.
+ */
+ test.sdo21.framework.CTSTestCase delegate;
+
+ public CTSTestCase(String title) {
+ super(title);
+ delegate = new test.sdo21.framework.CTSTestCase();
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ delegate.setUp();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ delegate.tearDown();
+ super.tearDown();
+ }
+
+ public HelperContext getScope() {
+ return delegate.getScope();
+ }
+
+ public static TestHelper getTestHelper() {
+ return test.sdo21.framework.CTSTestCase.getTestHelper();
+ }
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/package.html b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/package.html
new file mode 100644
index 0000000000..2f776d9b3f
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/package.html
@@ -0,0 +1,25 @@
+<html>
+<!--
+ 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$
+-->
+<body>
+Contains framework of this test suite.
+</body>
+</html>