diff options
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java')
4 files changed, 260 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/dataObjectFactory/package.html b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/dataObjectFactory/package.html new file mode 100644 index 0000000000..414d58e830 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/dataObjectFactory/package.html @@ -0,0 +1,5 @@ +<html> +<body> +Contains implementation of DataObject Factory from Tuscany. +</body> +</html> diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/testHelper/TuscanyTestHelper.java b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/testHelper/TuscanyTestHelper.java new file mode 100644 index 0000000000..24e29704ed --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/testHelper/TuscanyTestHelper.java @@ -0,0 +1,148 @@ +/** + * + * 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.vendor.tuscany.testHelper; + +import static org.junit.Assert.fail; + +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.Collection; +import java.util.List; +import java.util.logging.Logger; + +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import test.sdo21.framework.DataObjectFactory; +import test.sdo21.framework.TestHelper; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; + +/** + * Implementation of TestHelper for Tuscany. + */ +public class TuscanyTestHelper implements TestHelper { + + private static List staticArtifacts = null; + private static final Logger logger = Logger.getLogger(TuscanyTestHelper.class.getName()); + + public void init() { + } + + public DataObject createTypeDef(String uri, String name, boolean open, HelperContext helperContext) { + throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); + } + + public DataObject createPropertyDef(DataObject typeDef, + String propertyName, + Type type, + boolean isMany, + boolean isContainment) { + throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); + } + + public DataObject createPropertyDef(DataObject typeDef, + String propertyName, + String typeName, + boolean isMany, + boolean isContainment, + HelperContext helperContext) { + throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); + } + + public String createUniqueName() { + return "name-" + System.currentTimeMillis() + "-" + ((int)(1000 * Math.random())); + } + + + + /** + * Create an empty data graph. + * + * @return the new data graph instance. + */ + public DataGraph createDataGraph() { + return SDOUtil.createDataGraph(); + } + + /** + * Create a new HelperContext, a new scope + * @return the new HelperContext instance. + */ + public HelperContext createHelperContext() { + return SDOUtil.createHelperContext(); + } + + + /** + * Create a new ObjectOutputStream + * + * @return the new ObjectOutputStream instance. + */ + public ObjectOutputStream createObjectOutputStream(OutputStream os, HelperContext helperContext) { + try { + return SDOUtil.createObjectOutputStream(os, helperContext); + } catch (java.io.IOException e) { + fail("IOException during createObjectOutputStream."); + return null; + } + } + + /** + * Create a new ObjectInputStream + * + * @return the new ObjectInputStream instance. + */ + public ObjectInputStream createObjectInputStream(InputStream is, HelperContext helperContext) { + try { + return SDOUtil.createObjectInputStream(is, helperContext); + } catch (java.io.IOException e) { + fail("IOException during createObjectOutputStream."); + return null; + } + } + + /** + * Serialize a DataObject using an XMLStreamHelper + */ + public void serializeViaXMLStreamHelper(TypeHelper typeHelper, DataObject dataObject, XMLStreamWriter serializer) { + try { + SDOUtil.createXMLStreamHelper(typeHelper).saveObject(dataObject, serializer); + } catch (javax.xml.stream.XMLStreamException e) { + fail("XMLStreamException during saveObject."); + } + } + + public DataObjectFactory createDataObjectFactory(String factory, HelperContext helperContext) { + throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); + } + + public Collection getParamatizedDataObject() { + throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); + } + +} diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/testHelper/package.html b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/testHelper/package.html new file mode 100644 index 0000000000..71f356ab14 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/test/sdo21/vendor/tuscany/testHelper/package.html @@ -0,0 +1,5 @@ +<html> +<body> +Contains implementation of test helpers from Tuscany. +</body> +</html> diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/tests/sdo21/vendor/tuscany/api/TypeTest.java b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/tests/sdo21/vendor/tuscany/api/TypeTest.java new file mode 100644 index 0000000000..1558a6341e --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/src/main/java/tests/sdo21/vendor/tuscany/api/TypeTest.java @@ -0,0 +1,102 @@ +/*
+ * 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: 537885 $ $Date: 2007-05-14 16:39:47 +0100 (Mon, 14 May 2007) $
+ */
+package tests.sdo21.vendor.tuscany.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.Ignore;
+import org.junit.Test;
+
+import test.sdo21.framework.CTSTestCase;
+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.api.CTSConsistencyBase;
+
+import commonj.sdo.DataObject;
+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.getAliasNames() when there are alias
+ * names to return
+ */
+ @Ignore("typeGetAliasNames test case is suppressed until SDOUtil.addAliasName is implemented.")
+ @Test
+ public void typeGetAliasNames() {
+ Type sequencedType = testDO.getInstanceProperty("sequencedElem").getType();
+ List aliases = sequencedType.getAliasNames();
+
+ assertEquals("The List returned by Type.getAliasNames was not of the expected size.", 1, aliases.size());
+
+ String aliasName = (String)aliases.get(1);
+ assertEquals("The alias returned by Type.getAliasNames was not the expected name.", "Seq2", aliasName);
+ }
+
+}
|