diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 21:17:39 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 21:17:39 +0000 |
commit | eb11fd83f7908876fe6041086d6025c9468de672 (patch) | |
tree | 7475c93a5adceca4829d5c7bf6631d4b09749f4b /sdo-java | |
parent | 39a3e278e786438a92428fe13646d09f3441d2e6 (diff) |
Moving SDO CTS
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834672 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sdo-java')
151 files changed, 21658 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/pom.xml b/sdo-java/trunk-cts/pom.xml new file mode 100644 index 0000000000..65aeb92fb0 --- /dev/null +++ b/sdo-java/trunk-cts/pom.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<project> + <parent> + <groupId>org.apache.tuscany</groupId> + <artifactId>parent</artifactId> + <version>3-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.tuscany</groupId> + <artifactId>tuscany-sdo-cts</artifactId> + <name>Community Test Suite</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <!-- definition of repositories where the parent pom can be found --> + <repositories> + <repository> + <id>apache.incubator</id> + <name>Apache Incubator Repository</name> + <url>http://people.apache.org/repo/m2-incubating-repository/</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + <!-- Apache SNAPSHOT repository for unreleased artifacts --> + <repository> + <id>apache.snapshots</id> + <name>Apache SNAPSHOT Repository</name> + <url>http://people.apache.org/repo/m2-snapshot-repository</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + + <build> + <defaultGoal>install</defaultGoal> + </build> + <modules> + <module>sdo2.1</module> + <module>sdo2.1-tuscany</module> + </modules> +</project> diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/pom.xml b/sdo-java/trunk-cts/sdo2.1-tuscany/pom.xml new file mode 100644 index 0000000000..283d3fbdac --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/pom.xml @@ -0,0 +1,81 @@ +<?xml version="1.0"?><project> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>tuscany-sdo-cts</artifactId> + <groupId>org.apache.tuscany</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + + <groupId>org.apache.tuscany.cts</groupId> + <artifactId>tuscany-sdo-cts-tuscany</artifactId> + <name>Tuscany SDO 2.1 CTS</name> + <version>1.0-SNAPSHOT</version> + + <properties> + <specVersion>2.1</specVersion> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>**/AdoptedCtsTestSuite.java</include> + </includes> + <excludes> + <exclude>**/OptionalCtsTestSuite.java</exclude> + </excludes> + </configuration> + </plugin> + + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.1</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sdo</groupId> + <artifactId>tuscany-sdo-api-r${specVersion}</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.cts</groupId> + <artifactId>tuscany-sdo-cts-standard</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sdo</groupId> + <artifactId>tuscany-sdo-impl</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + <version>1.0.1</version> + <scope>provided</scope> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + <version>3.2.0</version> + <scope>runtime</scope> + </dependency> + </dependencies> + +</project> 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);
+ }
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/AdoptedCtsTestSuite.java b/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/AdoptedCtsTestSuite.java new file mode 100644 index 0000000000..52f4f783e9 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/AdoptedCtsTestSuite.java @@ -0,0 +1,42 @@ +/* + * 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.vendor.tuscany.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + + +/** + * <P> + * Provided to execute the SDO CTS for tuscany environment. + * </P><P> + * {@link test.sdo21.CTSSuite} contains all adopted test cases for the CTS. + * New test cases, or test cases that do not have consencus by the community + * should be placed in the {@link test.sdo21.UnderReviewSuite} suite. + * </P> + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( {test.sdo21.CTSSuite.class}) +public class AdoptedCtsTestSuite { + + +} diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/OptionalCtsTestSuite.java b/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/OptionalCtsTestSuite.java new file mode 100644 index 0000000000..ea98f5f37f --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/OptionalCtsTestSuite.java @@ -0,0 +1,36 @@ +/* + * 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.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Provided to execute the non adopted test cases in the SDO CTS within tuscany + * environment using the maven plugin. The {@link test.sdo21.CTSSuite} suite contains + * test cases that have been 'adopted' by the community, {@link test.sdo21.UnderReviewSuite} + * contains new test cases under review for inclusion. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( {test.sdo21.UnderReviewSuite.class, + test.sdo21.vendor.tuscany.tests.TuscanyOptionalTestSuite.class}) +public class OptionalCtsTestSuite { + +} diff --git a/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/TuscanyOptionalTestSuite.java b/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/TuscanyOptionalTestSuite.java new file mode 100644 index 0000000000..0704643b4c --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1-tuscany/src/test/java/test/sdo21/vendor/tuscany/tests/TuscanyOptionalTestSuite.java @@ -0,0 +1,36 @@ +/*
+ * 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.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Provided to execute the non adopted test cases in the SDO CTS within tuscany
+ * environment using the maven plugin. The {@link test.sdo21.CTSSuite} suite contains
+ * test cases that have been 'adopted' by the community, {@link test.sdo21.UnderReviewSuite}
+ * contains new test cases under review for inclusion.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {tests.sdo21.vendor.tuscany.api.TypeTest.DynamicMetadata.class,
+ tests.sdo21.vendor.tuscany.api.TypeTest.XSDMetadata.class})
+public class TuscanyOptionalTestSuite {
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/BUILDING.txt b/sdo-java/trunk-cts/sdo2.1/BUILDING.txt new file mode 100644 index 0000000000..d80e5346a7 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/BUILDING.txt @@ -0,0 +1,22 @@ +Building the SDO 2.1 Community Test Suite +========================================================================= + + +Initial Setup +------------- +1) Install J2SE JDK 1.4.2 or above +2) Install Maven: +Download Maven 2.0.4 (download from http://maven.apache.org/download.html). + + + +Building +-------- + +1) Edit the pom.xml to enable a specific implementation to be tested (?) +2) Execute: mvn + + +Note: Depending on the load being experienced by remote Maven 2.0 repositories you may have to execute mvn several times + until required dependencies are all located in your local maven repository. After you have completed a full successful + build you can use "mvn -o" which is much faster. diff --git a/sdo-java/trunk-cts/sdo2.1/LICENSE.txt b/sdo-java/trunk-cts/sdo2.1/LICENSE.txt new file mode 100644 index 0000000000..6b0b1270ff --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + diff --git a/sdo-java/trunk-cts/sdo2.1/pom.xml b/sdo-java/trunk-cts/sdo2.1/pom.xml new file mode 100644 index 0000000000..06116554f2 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/pom.xml @@ -0,0 +1,50 @@ +<?xml version="1.0"?><project> + <parent> + <artifactId>tuscany-sdo-cts</artifactId> + <groupId>org.apache.tuscany</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.tuscany.cts</groupId> + <artifactId>tuscany-sdo-cts-standard</artifactId> + <name>Community Test Suite for SDO 2.1</name> + <version>1.0-SNAPSHOT</version> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.1</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sdo</groupId> + <artifactId>tuscany-sdo-api-r${specVersion}</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.ws.commons.schema</groupId> + <artifactId>XmlSchema</artifactId> + <version>1.2</version> + </dependency> + </dependencies> + <properties> + <specVersion>2.1</specVersion> + </properties> +</project> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/CTSSuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/CTSSuite.java new file mode 100644 index 0000000000..21f4129a32 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/CTSSuite.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; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * The main "root" CTS test suite which includes execution of the following + * sub-categorized CTS within Junit 4.1 environment: + * <ul> + * <li>{@link test.sdo21.paramatizedTests.CTSParamatizedSuite}: has been + * removed due to errors when executing.</li> + * <li>{@link test.sdo21.tests.CTSGeneralSuite}</li> + * </ul> + * In general vendors will simply execute their junit 4.1 harness with this + * class in order to run the CTS. They can optionally include the individual + * test cases that they wish to use. New test cases, or test cases that do not + * have consencus by the community should be placed in the + * {@link test.sdo21.UnderReviewSuite} suite. + */ + +@RunWith(Suite.class) +@Suite.SuiteClasses( {test.sdo21.tests.CTSGeneralSuite.class}) +public class CTSSuite { + + /** + * Name of environment variable for vendor specific implementation for + * implementation of {@link test.sdo21.framework.TestHelper} + */ + public static final String SDO_CTS_TESTHELPER_CLASS = "CTS_TEST_HELPER"; + + + /** + * Main method allows tests to be run directly from command-line. + * + * @param args + */ + // TODO: add some usefull paramaters here such as helper class or junit + // runner + public static void main(String[] args) { + try { + // TODO: provide vender specific initialization + org.junit.runner.JUnitCore.runClasses(Class.forName("test.sdo21.CTSSuite")); + } catch (ClassNotFoundException e) { + System.out.println("Exception " + e.toString()); + e.printStackTrace(); + } + } + + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/ProposedForAdoptionSuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/ProposedForAdoptionSuite.java new file mode 100644 index 0000000000..73355b0b3a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/ProposedForAdoptionSuite.java @@ -0,0 +1,43 @@ +/*
+ * 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: 538933 $ $Date: 2007-05-17 15:11:43 +0100 (Thu, 17 May 2007) $
+ */
+package test.sdo21;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import test.sdo21.tests.CTSGeneralSuite;
+import test.sdo21.tests.api.TypeTest;
+import test.sdo21.tests.api.DataFactory.DataFactoryConsistencySuite;
+import test.sdo21.tests.api.DataGraph.DataGraphConsistencySuite;
+import test.sdo21.tests.api.XMLHelper.QNameTestCase;
+
+/**
+ * This suite of tests is for test cases which have been reviewed, by
+ * a member of the community and proposed on the mailing list as suitable for adoption.
+ * After mailing list discussion or in the absence of any contention, lazy consensus
+ * the tests can be moved to the appropriate place, i.e. the {@link CTSGeneralSuite} or back to
+ * the {@link UnderReviewSuite} suite.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {QNameTestCase.class})
+public class ProposedForAdoptionSuite {
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java new file mode 100644 index 0000000000..5ac65e7d7f --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java @@ -0,0 +1,68 @@ +/* + * 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; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +import test.sdo21.tests.api.ChangeSummaryTest; +import test.sdo21.tests.api.ContainmentCyclePreventionTest; +import test.sdo21.tests.api.ContainmentCycleSerializationTest; +import test.sdo21.tests.api.PropertyTest; +import test.sdo21.tests.api.XMLWithoutSchemaTest; +import test.sdo21.tests.api.TypeHelper.TypeHelperTest; +import test.sdo21.tests.api.CopyHelper.CopyEqualityTest; +import test.sdo21.tests.api.Sequence.SequenceConsistencySuite; +import test.sdo21.tests.api.Sequence.SequenceTest; +import test.sdo21.tests.api.XMLHelper.XMLHelperConsistencySuite; +import test.sdo21.tests.conversion.StringConversionTest; +import test.sdo21.tests.conversion.TypeConversionTest2; + +/** + * This suite of tests is for new test cases, or test cases that are currently + * under review by the community. Once a test has been adopted it can be moved + * into {@link test.sdo21.tests.CTSGeneralSuite} for inclusion into + * the CTS. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( {ProposedForAdoptionSuite.class, + + StringConversionTest.class, + XMLWithoutSchemaTest.class, + SequenceConsistencySuite.class, + TypeHelperTest.class, + XMLHelperConsistencySuite.class, + ContainmentCyclePreventionTest.DynamicMetadata.class, + ContainmentCyclePreventionTest.XSDMetadata.class, + ContainmentCycleSerializationTest.DynamicMetadata.class, + ContainmentCycleSerializationTest.XSDMetadata.class, + CopyEqualityTest.DynamicMetadata.class, + CopyEqualityTest.XSDMetadata.class, + PropertyTest.class, + TypeConversionTest2.class, + ChangeSummaryTest.class, + + SequenceTest.class + + }) +public class UnderReviewSuite { + +} 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> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/package.html b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/package.html new file mode 100644 index 0000000000..f842ec817c --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/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 main CTS test file. +</body> +</html> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java new file mode 100644 index 0000000000..5d517feb58 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java @@ -0,0 +1,77 @@ +/* + * 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; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +import test.sdo21.tests.api.DynamicTypesFromSchemaTestCase; +import test.sdo21.tests.api.SequenceAddOpenTest; +import test.sdo21.tests.api.SequenceAddTypedTest; +import test.sdo21.tests.api.TypeTest; +import test.sdo21.tests.api.DataFactory.DataFactoryConsistencySuite; +import test.sdo21.tests.api.DataGraph.DataGraphConsistencySuite; +import test.sdo21.tests.api.DataObject.DataObjectConsistencySuite; +import test.sdo21.tests.api.DataObject.DataObjectTest; +import test.sdo21.tests.conversion.DateConversionTest; +import test.sdo21.tests.conversion.TypeConversionTest; +import test.sdo21.tests.general.XMLHelperTest; +import test.sdo21.tests.general.XSDHelperTest; +import test.sdo21.tests.scenarios.DataObjectListTest; +import test.sdo21.tests.xsd.XSDChoiceTest; +import test.sdo21.tests.xsd.XSDComplexTypeTest; +import test.sdo21.tests.xsd.XSDSimpleTypeTest; + +/** + * Declares general test classes to be run within Junit 4.1 Suite for SDO CTS + * which includes the following classes:<br> + * <ul> + * <li>{@link test.sdo21.tests.api.DataObject.DataObjectTest}</li> + * <li>{@link test.sdo21.tests.conversion.DateConversionTest}</li> + * <li>{@link test.sdo21.tests.general.XSDHelperTest}</li> + * <li>{@link test.sdo21.tests.api.DynamicTypesFromSchemaTestCase}</li> + * </ul> + * New test cases, or test cases that do not have consencus by the community + * should be placed in the {@link test.sdo21.UnderReviewSuite} suite. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( {DateConversionTest.class, + XSDHelperTest.class, + XMLHelperTest.class, + DataObjectTest.class, + DynamicTypesFromSchemaTestCase.class, + XSDChoiceTest.class, + XSDComplexTypeTest.class, + DataObjectListTest.class, + TypeConversionTest.class, + XSDSimpleTypeTest.class, + SequenceAddOpenTest.class, + SequenceAddTypedTest.class, + DataObjectConsistencySuite.class, + DataGraphConsistencySuite.class, + DataFactoryConsistencySuite.class, + + TypeTest.DynamicMetadata.class, + TypeTest.XSDMetadata.class + }) +public class CTSGeneralSuite { + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/ConsistencyTestTemplate.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/ConsistencyTestTemplate.java new file mode 100644 index 0000000000..d37686a4bf --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/ConsistencyTestTemplate.java @@ -0,0 +1,195 @@ +/* + * 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; + +// static imports simply allow you to call assertTrue rather than +// Assert.assertTrue +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import test.sdo21.tests.TestData.StandardDynamicFactory; +import test.sdo21.tests.TestData.StandardXSDFactory; +import test.sdo21.tests.TestData.TestDataFactory; +import test.sdo21.tests.api.CTSConsistencyBase; + +import commonj.sdo.DataObject; + +/** + * Example test class to be used as a template for SDO test cases which apply + * the same set of tests to a number of data sets of the same shape, but backed + * by metadata created in different ways, e.g. from and xsd, using the dynamic API, + * or, in the case of vendor specific tests, using statically generated classes. + * + * This class extends {@link CTSConsistencyBase} + * which requires a concrete derived class to provide a factory which will be used to + * populate a DataObject called testSDO. The concrete test can be written to conform + * to the expected shape of test data created by the factory it chooses to instantiate <br> + * <br> + * The test case can be run using Junit within eclipse, from normal command line + * junit, or within a WebSphere build environment by adding an target such as + * sampleTestTarget that is contained within the build.xml file of the + * WAS.soa.sdo.cts component. <br> + * <br> + * Once a test case has been completed and reviewed it can be added into the + * appropiate CTS Suite.<br> + * <br> + * Tests class must only use methods that are defined + * within the current SDO Specification. If utility methods are required they + * should be added to {@link test.sdo21.framework.TestHelper}. <br> + * <br> + * Please Document the overall intention of the test case and provide detailed + * javadoc for each test method. Please create modular test methods rather than + * single large test methods. Please use provide links back to the Main class under test + * and to the page in the specification as demonstrated below<br> + * <br> + * Resources: + * <UL> + * <LI><a href="http://www.junit.org/">Junit Foundation</a> + * </UL> + * + * @see DataObject + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=45">2.1 spec section 3.11</a> + */ +public abstract class ConsistencyTestTemplate extends CTSConsistencyBase { + + public ConsistencyTestTemplate() { + } + + + /** + * A concrete class which provides a factory that creates appropriate metadata for the + * test case using the SDO dynamic API. This can be referenced as a class to be tested + * from within a junit suite declaration. Additional derived classes creating alternative + * factories may be supplied ellsewhere and referenced by other junit suite declarations, + * for example, in a vendor specific extension that uses statically generated classes. + */ + public static class DynamicMetadata extends ConsistencyTestTemplate { + public DynamicMetadata() { + + } + public TestDataFactory createTestDataFactory() { + + return new StandardDynamicFactory(); + } + } + + /** + * A concrete class which provides a factory that creates appropriate metadata for the + * test case using an XML schema. This can be referenced as a class to be tested + * from within a junit suite declaration. Additional derived classes creating alternative + * factories may be supplied ellsewhere and referenced by other junit suite declarations, + * for example, in a vendor specific extension that uses statically generated classes. + */ + public static class XSDMetadata extends ConsistencyTestTemplate { + + public XSDMetadata() { + } + + public TestDataFactory createTestDataFactory() { + + return new StandardXSDFactory(); + } + } + + + @Before + public void setUp () throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + /** + * Example test method. Please provide good description of the test case in + * javadoc including the intention, reference to the specification, etc. + */ + @Test + public void myTestMethod() { + + String expected = new String("bla bla bla"); + String actual = new String("bla bla bla"); + assertEquals("Your Message", expected, actual); + } + + /** + * Sometimes you want to temporarily disable a test. Methods annotated with + * {@link org.junit.Test} that are also annotated with <code>@Ignore</code> will not be executed as tests. Native JUnit 4 test + * runners should report the number of ignored tests along with the + * number of tests that ran and the number of tests that failed. + * <code>@Ignore</code> takes an optional default parameter if you want to record + * why a test is being ignored:<br> + */ + @Test + @Ignore("Function Foo is not clearly defined within the SDO 2.1 specification and is currently being defined as a part of the x.x specification.") + public void exampleIngoredTestCase() { + // test method here + } + + /** + * Sometimes you may not have the resources to implement a test case. If is + * very very valuable to create method signatures in the appropiate classes + * for test cases that are currently not covered. In cases such as these + * please define and checkin method signatures with the following ignore + * message. <br> + * <br> + * In this case you should ensure that the class that contains the test + * method is added to a testSuite such as + * {@link test.sdo21.UnderReviewSuite} so that it will + * be completed, or open a defect/JIRA to complete the test case. + */ + @Test + @Ignore("This test method requires implementation") + public void exampleUnimplementedTestCase() { + } + + /** + * When writing tests, it is common to find that several tests need similar + * objects created before they can run. Annotating a + * <code>public void</code> method with <code>@Before</code> causes that method to be run before the + * {@link org.junit.Test} method. The <code>@Before</code> methods of superclasses will be run before those of the + * current class. There is also an <code>@After</code> annotation + */ + @Before + public void testCaseInit() { + // initMethod + } + + /** + * Sometimes several tests need to share computationally expensive setup + * (like logging into a database). While this can compromise the + * independence of tests, sometimes it is a necessary optimization. + * Annotating a <code>public static void</code> no-arg method with + * <code>@BeforeClass</code> causes it to be run once before any of the test + * methods in the class. The <code>@BeforeClass</code> methods of superclasses will be run before those the + * current class. + */ + @BeforeClass + public static void init() { + // init + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardDynamicFactory.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardDynamicFactory.java new file mode 100644 index 0000000000..872325b059 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardDynamicFactory.java @@ -0,0 +1,226 @@ +package test.sdo21.tests.TestData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+public class StandardDynamicFactory extends StandardFactory {
+
+ public void defineMetaData(HelperContext hc) {
+ TypeHelper types = hc.getTypeHelper();
+
+ Type t = types.getType(TEST_NAMESPACE, "Abstract");
+ if (t != null) {
+ // the test types have already been defined in this HelperContext (this will happen when the
+ // implementation being tested does not support multiple contexts, which is not a 2.1 requirement).
+ return;
+ }
+
+ Type stringType = types.getType("commonj.sdo", "String");
+ Type intType = types.getType("commonj.sdo", "Int");
+ Type booleanType = types.getType("commonj.sdo", "Boolean");
+ Type byteType = types.getType("commonj.sdo", "Byte");
+ Type decimalType = types.getType("commonj.sdo", "Decimal");
+ Type floatType = types.getType("commonj.sdo", "Float");
+ Type doubleType = types.getType("commonj.sdo", "Double");
+ Type dateType = types.getType("commonj.sdo", "Date");
+ Type shortType = types.getType("commonj.sdo", "Short");
+ Type longType = types.getType("commonj.sdo", "Long");
+ Type bytesType = types.getType("commonj.sdo", "Bytes");
+ Type integerType = types.getType("commonj.sdo", "Integer");
+ Type charType = types.getType("commonj.sdo", "Character");
+
+ DataObject abstractTypeDO = hc.getDataFactory().create("commonj.sdo", "Type");
+ abstractTypeDO.set("uri", TEST_NAMESPACE);
+ abstractTypeDO.set("name", "Abstract");
+ abstractTypeDO.setBoolean("abstract", true);
+
+ DataObject firstProperty = abstractTypeDO.createDataObject("property");
+ firstProperty.set("name", "firstName");
+ firstProperty.set("type", stringType);
+
+ DataObject lastProperty = abstractTypeDO.createDataObject("property");
+ lastProperty.set("name", "lastName");
+ lastProperty.set("type", stringType);
+
+ Type abstractType = types.define(abstractTypeDO);
+
+ DataObject extendedTypeDO = hc.getDataFactory().create("commonj.sdo", "Type");
+ extendedTypeDO.set("uri", TEST_NAMESPACE);
+ extendedTypeDO.set("name", EXT_TYPE);
+
+ List baseTypes = new ArrayList();
+ baseTypes.add(abstractType);
+ extendedTypeDO.setList("baseType", baseTypes);
+
+ DataObject middleName = extendedTypeDO.createDataObject("property");
+ middleName.set("name", "middleName");
+ middleName.set("type", stringType);
+
+ DataObject nickName = extendedTypeDO.createDataObject("property");
+ nickName.set("name", "nickName");
+ nickName.set("type", stringType);
+
+ Type extendedType = types.define(extendedTypeDO);
+
+ DataObject sequenceTypeDO = hc.getDataFactory().create("commonj.sdo", "Type");
+ sequenceTypeDO.set("uri", TEST_NAMESPACE);
+ sequenceTypeDO.set("name", SEQ_TYPE);
+ sequenceTypeDO.setBoolean("sequenced", true);
+
+ // TODO: Uncomment the following when SDOUtil.addAliasName is
+ // implemented
+ /*
+ * aliases.clear(); aliases.add("Seq2"); sequenceTypeDO.set("aliasName",
+ * aliases);
+ */
+
+ DataObject Letters = sequenceTypeDO.createDataObject("property");
+ Letters.set("name", "Letters");
+ Letters.set("type", stringType);
+ Letters.setBoolean("many", true);
+
+ DataObject Numbers = sequenceTypeDO.createDataObject("property");
+ Numbers.set("name", "Numbers");
+ Numbers.set("type", intType);
+ Numbers.setBoolean("many", true);
+
+ DataObject containManySeq = sequenceTypeDO.createDataObject("property");
+ containManySeq.set("name", "containMany");
+ containManySeq.set("type", sequenceTypeDO);
+ containManySeq.setBoolean("many", true);
+ containManySeq.setBoolean("containment", true);
+
+ DataObject containSeq = sequenceTypeDO.createDataObject("property");
+ containSeq.set("name", "contain");
+ containSeq.set("type", sequenceTypeDO);
+ containSeq.setBoolean("containment", true);
+
+ Type sequenceType = types.define(sequenceTypeDO);
+
+ DataObject openTypeDO = hc.getDataFactory().create("commonj.sdo", "Type");
+ openTypeDO.set("uri", TEST_NAMESPACE);
+ openTypeDO.set("name", "Open");
+ openTypeDO.setBoolean("open", true);
+
+ DataObject definedElem = openTypeDO.createDataObject("property");
+ definedElem.set("name", "defined");
+ definedElem.set("type", stringType);
+
+ Type openType = types.define(openTypeDO);
+
+ DataObject testType = hc.getDataFactory().create("commonj.sdo", "Type");
+ testType.set("uri", TEST_NAMESPACE);
+ testType.set("name", API_TYPE);
+
+ DataObject stringProperty = testType.createDataObject("property");
+ stringProperty.set("name", "stringVal");
+ stringProperty.set("type", stringType);
+
+ DataObject booleanProperty = testType.createDataObject("property");
+ booleanProperty.set("name", "booleanVal");
+ booleanProperty.set("type", booleanType);
+
+ DataObject boolean2Property = testType.createDataObject("property");
+ boolean2Property.set("name", "booleanVal2");
+ boolean2Property.set("type", booleanType);
+
+ DataObject byteProperty = testType.createDataObject("property");
+ byteProperty.set("name", "byteVal");
+ byteProperty.set("type", byteType);
+
+ DataObject string2Property = testType.createDataObject("property");
+ string2Property.set("name", "stringVal2");
+ string2Property.set("type", stringType);
+
+ DataObject decimalProperty = testType.createDataObject("property");
+ decimalProperty.set("name", "decimalVal");
+ decimalProperty.set("type", decimalType);
+
+ DataObject decimal2Property = testType.createDataObject("property");
+ decimal2Property.set("name", "decimalVal2");
+ decimal2Property.set("type", decimalType);
+
+ // TODO: Uncomment the following when SDOUtil.addAliasName is
+ // implemented
+ /*
+ * aliases.clear(); aliases.add("Dec2");
+ * decimal2Property.set("aliasName", aliases);
+ */
+ DataObject intProperty = testType.createDataObject("property");
+ intProperty.set("name", "intVal");
+ intProperty.set("type", intType);
+
+ DataObject floatProperty = testType.createDataObject("property");
+ floatProperty.set("name", "floatVal");
+ floatProperty.set("type", floatType);
+
+ DataObject doubleProperty = testType.createDataObject("property");
+ doubleProperty.set("name", "doubleVal");
+ doubleProperty.set("type", doubleType);
+
+ DataObject dateProperty = testType.createDataObject("property");
+ dateProperty.set("name", "dateVal");
+ dateProperty.set("type", dateType);
+
+ DataObject shortProperty = testType.createDataObject("property");
+ shortProperty.set("name", "shortVal");
+ shortProperty.set("type", shortType);
+
+ DataObject longProperty = testType.createDataObject("property");
+ longProperty.set("name", "longVal");
+ longProperty.set("type", longType);
+
+ DataObject containManyProperty = testType.createDataObject("property");
+ containManyProperty.set("name", "containMany");
+ containManyProperty.setBoolean("many", true);
+ containManyProperty.setBoolean("containment", true);
+ containManyProperty.set("type", testType);
+
+ DataObject bytesProperty = testType.createDataObject("property");
+ bytesProperty.set("name", "bytesVal");
+ bytesProperty.set("type", bytesType);
+
+ DataObject integerProperty = testType.createDataObject("property");
+ integerProperty.set("name", "integerVal");
+ integerProperty.set("type", integerType);
+
+ DataObject charProperty = testType.createDataObject("property");
+ charProperty.set("name", "charVal");
+ charProperty.set("type", charType);
+
+ DataObject readOnlyProperty = testType.createDataObject("property");
+ readOnlyProperty.set("name", "readOnlyVal");
+ readOnlyProperty.set("type", stringType);
+ readOnlyProperty.setBoolean("readOnly", true);
+
+ DataObject sequenceProperty = testType.createDataObject("property");
+ sequenceProperty.set("name", "sequencedElem");
+ sequenceProperty.set("type", sequenceType);
+ sequenceProperty.setBoolean("containment", true);
+
+ DataObject extendProperty = testType.createDataObject("property");
+ extendProperty.set("name", "extendedElem");
+ extendProperty.set("type", extendedType);
+ extendProperty.setBoolean("containment", true);
+
+ DataObject openProperty = testType.createDataObject("property");
+ openProperty.set("name", "openElem");
+ openProperty.set("type", openType);
+ openProperty.setBoolean("containment", true);
+
+ DataObject containProperty = testType.createDataObject("property");
+ containProperty.set("name", "contain");
+ containProperty.setBoolean("containment", true);
+ containProperty.set("type", testType);
+
+ types.define(testType);
+
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardFactory.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardFactory.java new file mode 100644 index 0000000000..eee92ee366 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardFactory.java @@ -0,0 +1,72 @@ +package test.sdo21.tests.TestData;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import test.sdo21.framework.DataObjectFactory;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+
+/**
+ * Abstract base class for creating tests data of an specific nature.
+ * Concrete specializations of this class may create the metadata by various means,
+ * e.g. the SDO Dynamic API or XSD to SDO conversion, or some other implementation
+ * specific means, e.g. generation of static classes.
+ *
+ * All derived classes must create equivalent metatdata by whatever means is chosen.
+ *
+ */
+public abstract class StandardFactory implements TestDataFactory {
+
+ public static final String TEST_NAMESPACE = "http://www.example.com/api_test";
+ public static final String API_TYPE = "APITest";
+ public final static String SEQ_TYPE = "Sequenced";
+ public final static String EXT_TYPE = "Extended";
+ public static final String ABSTRACT_TYPE = "Abstract";
+
+ /**
+ * this factory currently simple makes the assumption that the variant string is the
+ * name of a type for which an empty instance is required
+ */
+ public DataObject createTestData(HelperContext scope, String variantString) throws Exception {
+ return scope.getDataFactory().create(TEST_NAMESPACE, variantString);
+ }
+
+ /**
+ * populateFields uses set<Type> to set each of the fields in the
+ * DataObject. It is used to ensure a known set of expected values that are
+ * not other than the default values for the various fields.
+ *
+ * @param testDO
+ * @param helperContext
+ * @throws ExpectedConditionError
+ */
+ public void populateFields(DataObject testDO, HelperContext scope) throws Exception {
+ testDO.setString("stringVal", "String 1");
+ testDO.setBoolean("booleanVal", true);
+ testDO.setBoolean("booleanVal2", false);
+ testDO.setByte("byteVal", (byte)-127);
+ testDO.setString("stringVal2", "Second string!");
+ testDO.setBigDecimal("decimalVal", new BigDecimal(-3.00003));
+ testDO.setBigDecimal("decimalVal2", new BigDecimal(18883.999999));
+ testDO.setInt("intVal", (int)33333);
+ testDO.setFloat("floatVal", (float)0.88881);
+ testDO.setDouble("doubleVal", (double)119.13813);
+ testDO.setDate("dateVal", new Date(System.currentTimeMillis()));
+ testDO.setShort("shortVal", (short)-800);
+ testDO.setLong("longVal", (long)88881113);
+ testDO.setBytes("bytesVal", new byte[] {120, 80, -40});
+ testDO.setBigInteger("integerVal", new BigInteger("88819313"));
+ testDO.setChar("charVal", '*');
+ testDO.setDataObject("sequencedElem", createTestData(scope, SEQ_TYPE));
+ testDO.setDataObject("extendedElem", createTestData(scope, EXT_TYPE));
+ testDO.setDataObject("contain", createTestData(scope, API_TYPE));
+ List containMany = new ArrayList();
+ containMany.add(createTestData(scope, API_TYPE));
+ testDO.setList("containMany", containMany);
+ }
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardXSDFactory.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardXSDFactory.java new file mode 100644 index 0000000000..828b0117e6 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardXSDFactory.java @@ -0,0 +1,39 @@ +package test.sdo21.tests.TestData;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.Type;
+
+/**
+ *
+ * Concrete specialization of the StandardFactory test data creation factory
+ * which uses an XSD to create the required metadata.
+ *
+ */
+public class StandardXSDFactory extends StandardFactory {
+
+ public final static String TEST_MODEL = "/api_test.xsd";
+
+
+ public void defineMetaData(HelperContext hc) throws IOException {
+
+ Type t = hc.getTypeHelper().getType(TEST_NAMESPACE, "Abstract");
+ if (t != null) {
+ // the test types have already been defined in this HelperContext (this will happen when the
+ // implementation being tested does not support multiple contexts, which is not a 2.1 requirement).
+ return;
+ }
+
+ // Populate the meta data for the test model (APITest)
+ URL url = this.getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/TestDataFactory.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/TestDataFactory.java new file mode 100644 index 0000000000..bb84374784 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/TestDataFactory.java @@ -0,0 +1,9 @@ +package test.sdo21.tests.TestData;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+
+public interface TestDataFactory {
+ public void defineMetaData(HelperContext scope) throws Exception;
+ public DataObject createTestData(HelperContext scope, String variant) throws Exception;
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestTemplate.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestTemplate.java new file mode 100644 index 0000000000..5c25d43e97 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestTemplate.java @@ -0,0 +1,138 @@ +/* + * 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; + +// static imports simply allow you to call assertTrue rather than +// Assert.assertTrue +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import test.sdo21.framework.CTSTestCase; + +/** + * Example test class to be used as a template SDO test cases. + * <br> + * The test case can be run using Junit within eclipse, from normal command line + * junit, or within a WebSphere build environment by adding an target such as + * sampleTestTarget that is contained within the build.xml file of the + * WAS.soa.sdo.cts component. <br> + * <br> + * Once a test case has been completed and reviewed it can be added into the + * appropiate CTS Suite.<br> + * <br> + * This test class should make every effort to only use methods that are defined + * within the current SDO Specification. If utility methods are required they + * should be added to {@link test.sdo21.framework.TestHelper} <br> + * <br> + * Please Document the overall intention of the test case and provide detailed + * javadoc for each test method. Please create modular test methods rather than + * single large test methods<br> + * <br> + * Resources: + * <UL> + * <LI><a href="http://www.junit.org/">Junit Fondation</a> + * Change History: + * <UL> + * <LI>Initial implementation + * </UL> + */ +public class TestTemplate extends CTSTestCase { + + + /** + * Example test method. Please provide good description of the test case in + * javadoc including the intention, reference to the specification, etc. + */ + @Test + public void myTestMethod() { + + String expected = new String("bla bla bla"); + String actual = new String("bla bla bla"); + assertEquals("Your Message", expected, actual); + } + + /** + * Sometimes you want to temporarily disable a test. Methods annotated with + * {@link org.junit.Test} that are also annotated with <code>@Ignore</code> will not be executed as tests. Native JUnit 4 test + * runners should report the number of ignored tests along with the + * number of tests that ran and the number of tests that failed. + * <code>@Ignore</code> takes an optional default parameter if you want to record + * why a test is being ignored:<br> + */ + @Test + @Ignore("Function Foo is not clearly defined within the SDO 2.1 specification and is currently being defined as a part of the x.x specification.") + public void exampleIngoredTestCase() { + // test method here + } + + /** + * Sometimes you may not have the resources to implement a test case. If is + * very very valuable to create method signatures in the appropiate classes + * for test cases that are currently not covered. In cases such as these + * please define and checkin method signatures<br> + * <br> + * In this case you should ensure that the class that contains the test + * method is added to a testSuite such as + * {@link test.sdo21.UnderReviewSuite} so that it will + * be completed, or open a defect/JIRA to complete the test case. + */ + @Test + @Ignore("This test method requires implementation") + public void exampleUnimplementedTestCase() { + } + + /** + * When writing tests, it is common to find that several tests need similar + * objects created before they can run. Annotating a + * <code>public void</code> method with <code>@Before</code> causes that method to be run before the + * {@link org.junit.Test} method. The <code>@Before</code> methods of superclasses will be run before those of the + * current class. There is also an <code>@After</code> annotation + * @throws Exception + */ + @Before + public void setUp() throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Sometimes several tests need to share computationally expensive setup + * (like logging into a database). While this can compromise the + * independence of tests, sometimes it is a necessary optimization. + * Annotating a <code>public static void</code> no-arg method with + * <code>@BeforeClass</code> causes it to be run once before any of the test + * methods in the class. The <code>@BeforeClass</code> methods of superclasses will be run before those the + * current class. + */ + @BeforeClass + public static void init() { + // init + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CTSConsistencyBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CTSConsistencyBase.java new file mode 100644 index 0000000000..2c5a4d6754 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CTSConsistencyBase.java @@ -0,0 +1,57 @@ +/*
+ * 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;
+
+import org.junit.After;
+import org.junit.Before;
+
+import test.sdo21.framework.CTSTestCase;
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+import commonj.sdo.DataObject;
+
+/**
+ * A class which supports the set of test classes which test for consistent behaviour of
+ * the APIs when the metadata in use has been created by various means.
+ *
+ */
+public abstract class CTSConsistencyBase extends CTSTestCase {
+ protected DataObject testDO;
+ protected TestDataFactory factory;
+ public abstract TestDataFactory createTestDataFactory();
+
+ public CTSConsistencyBase() {
+ factory = createTestDataFactory();
+ }
+
+ @Before
+ public void setUp () throws Exception {
+ super.setUp();
+ factory.defineMetaData(getScope());
+ testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ChangeSummaryTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ChangeSummaryTest.java new file mode 100644 index 0000000000..9e31955d64 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ChangeSummaryTest.java @@ -0,0 +1,122 @@ +/*
+ * 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: 538928 $ $Date: 2007-05-17 15:00:54 +0100 (Thu, 17 May 2007) $
+ */
+package test.sdo21.tests.api;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import test.sdo21.framework.CTSTestCase;
+import test.sdo21.tests.TestData.StandardDynamicFactory;
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ */
+public class ChangeSummaryTest extends CTSTestCase {
+ private DataObject testDO;
+ TestDataFactory factory;
+
+ public ChangeSummaryTest() {
+ factory = new StandardDynamicFactory();
+ }
+
+ @Before
+ public void setUp () throws Exception {
+ super.setUp();
+ factory.defineMetaData(getScope());
+ testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * testGetChangeSummary performs some verification on the ChangeSummary
+ * returned by DataGraph.getChangeSummary()
+ */
+ private void runChangeSummaryTests(DataGraph generatingDG) {
+ ChangeSummary generatedCS = generatingDG.getChangeSummary();
+
+ assertNotNull("DataGraph.getChangeSummary() returned a null ChangeSummary.", generatedCS);
+
+ assertEquals("The ChangeSummary returned by DataGraph.getChangeSummary() did not return refer to the generating DataGraph.",
+ generatedCS.getDataGraph(),
+ generatingDG);
+
+ assertEquals("The ChangeSummary returned by DataGraph.getChangeSummary() and the DataGraph have different root Objects. ",
+ generatedCS.getRootObject(),
+ generatingDG.getRootObject());
+ }
+
+ /**
+ * Verify the proper function of DataGraph.getChangeSummary() when the
+ * DataGraph RootObject was created by Type
+ */
+ @Test
+ public void testDataGraphGetChangeSummaryType() {
+ Type testType = testDO.getType();
+
+ DataGraph dataGraph = getTestHelper().createDataGraph();
+ dataGraph.createRootObject(testType);
+
+ runChangeSummaryTests(dataGraph);
+ }
+
+ /**
+ * Verify the proper function of DataGraph.getChangeSummary() when the
+ * DataGraph RootObject was created by URI
+ * @throws Exception
+ */
+ @Test
+ public void testDataGraphGetChangeSummaryURI() throws Exception {
+ // we are constrained to work with the default helper context for these APIs
+ // so lets override the default behaviour of the test framework for this method
+
+ HelperContext globalScope = HelperProvider.getDefaultContext();
+ factory.defineMetaData(globalScope);
+ testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
+
+ Type testType = testDO.getType();
+
+ DataGraph dataGraph = getTestHelper().createDataGraph();
+ dataGraph.createRootObject(testType.getURI(), testType.getName());
+
+ runChangeSummaryTests(dataGraph);
+ }
+
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCyclePreventionTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCyclePreventionTest.java new file mode 100644 index 0000000000..85ad78e7ba --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCyclePreventionTest.java @@ -0,0 +1,481 @@ +/* + * 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.api; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Enclosed; +import org.junit.runners.Suite; + +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.DataObject; +import commonj.sdo.Sequence; + +/** + * Tests prevdention of containment cycles. Each test passes if the method call that + * would result in a containment cycle throws an IllegalArgumentException and does + * not allow the formation of containment cycle. There is a test case for + * each of the various mechanisms through which a containment cycle may be created. + */ +public abstract class ContainmentCyclePreventionTest extends CTSConsistencyBase { + + public ContainmentCyclePreventionTest() { + } + + public static class DynamicMetadata extends ContainmentCyclePreventionTest { + public DynamicMetadata() { + + } + public TestDataFactory createTestDataFactory() { + + return new StandardDynamicFactory(); + } + } + + public static class XSDMetadata extends ContainmentCyclePreventionTest { + + public XSDMetadata() { + } + + public TestDataFactory createTestDataFactory() { + + return new StandardXSDFactory(); + } + } + + + @Before + public void setUp () throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of the method. + * @throws Exception + */ + @Test + public void oneMemberSingleValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + setSingleValueOneMember(dataObj1); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of the method. + * @throws Exception + */ + @Test + public void nMemberSingleValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + setSingleValueNMember(dataObj1, dataObj2, dataObj3); + } + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of the method. + * @throws Exception + */ + @Test + public void oneMemberMultiValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + setMultiValueOneMember(dataObj1, dataObj2, dataObj3); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of the method. + * @throws Exception + */ + @Test + public void nMemberMultiValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + setManyValueNMember(dataObj1, dataObj2, dataObj3); + } + + /** + * Attempt to create a 1-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of the method. This is the static version + * of this test case. + * @throws Exception + */ + @Test + public void oneMemberReturnedList() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + returnedListOneMember(dataObj1); + } + + /** + * Attempt to create an n-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of the method. This is the static version + * of this test case. + * @throws Exception + */ + @Test + public void nMemberReturnedList() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + returnedListNMember(dataObj1, dataObj2, dataObj3); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * the method. + * @throws Exception + */ + @Test + public void oneMemberSingleValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + + sequenceSingleValueOneMember(dataObj1); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * the method. + * @throws Exception + */ + @Test + public void nMemberSingleValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + + sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * the method. + * @throws Exception + */ + @Test + public void oneMemberMultiValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + + sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * the method. + * @throws Exception + */ + @Test + public void nMemberMultiValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);; + + sequenceManyValueNMember(dataObj1, dataObj2, dataObj3); + } + + /** + * Returns true if input DataObject root is part of a containment cycle, + * false otherwise. + * @param root + * @return + */ + private static boolean containmentCycleExists (DataObject root) + { + DataObject curr = root.getContainer(); + + while (curr != null) + { + if (curr == root) + return true; + + curr = curr.getContainer(); + } + return false; + } + + /** + * Use setDataObject to create a one member containment cycle. + * @param dataObj1 + */ + private void setSingleValueOneMember(DataObject dataObj1) { + try { + dataObj1.setDataObject("contain", dataObj1); + + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Use setDataObject to create an N-member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataobj3 + */ + private void setSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + dataObj1.setDataObject("contain", dataObj2); + dataObj2.setDataObject("contain", dataObj3); + + try { + dataObj3.setDataObject("contain", dataObj1); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Use setList to create a one member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void setMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + List addList = new ArrayList(); + addList.add(dataObj2); + addList.add(dataObj1); + addList.add(dataObj3); + + try { + dataObj1.setList("containMany", addList); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Use setList to create an N-member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void setManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + List addList = new ArrayList(); + + dataObj1.setDataObject("contain", dataObj2); + dataObj2.setDataObject("contain", dataObj3); + addList.add(dataObj1); + + try { + dataObj3.setList("containMany", addList); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create a 1-member containment cycle by making updates to a returned List. + * @param dataObj1 + */ + private void returnedListOneMember(DataObject dataObj1) { + List returnedList = dataObj1.getList("containMany"); + + try { + returnedList.add(dataObj1); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create an n-member containment cycle by making updates to a returned List. + * @param dataObj1 + * @param dataObj2 + * @param dataobj3 + */ + private void returnedListNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + dataObj1.setDataObject("contain", dataObj2); + dataObj2.setDataObject("contain", dataObj3); + + List returnedList = dataObj3.getList("containMany"); + + try { + returnedList.add(dataObj1); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create a 1-member containment cycle by making updates to a Sequence. + * The data member in this case is single valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceSingleValueOneMember(DataObject dataObj1) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + Sequence sequence = dataObj1.getSequence(); + + try { + sequence.add("contain", dataObj1); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + + } + + /** + * Create an n-member containment cycle by making updates to a Sequence. + * The data member in this case is single valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + Sequence sequence1 = dataObj1.getSequence(); + Sequence sequence2 = dataObj2.getSequence(); + Sequence sequence3 = dataObj3.getSequence(); + + sequence1.add("contain", (Object) dataObj2); + sequence2.add("contain", (Object) dataObj3); + + + try { + sequence3.add("contain", (Object) dataObj1); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create a 1-member containment cycle by making updates to a Sequence. + * The data member in this case is many valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + Sequence sequence = dataObj1.getSequence(); + + sequence.add("containMany", dataObj2); + sequence.add("containMany", dataObj3); + + try { + sequence.add("containMany", dataObj1); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create an n-member containment cycle by making updates to a Sequence. + * The data member in this case is many valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + List addList = new ArrayList(); + + addList.add(dataObj2); + dataObj1.setList("containMany", addList); + + addList.clear(); + addList.add(dataObj3); + dataObj2.setList("containMany", addList); + + Sequence sequence = dataObj3.getSequence(); + + try { + sequence.add("containMany", dataObj1); + if (containmentCycleExists(dataObj1)) + fail("Attempting to create a containment cycle should result in an Exception."); + else + fail("Containment cycle was neither created nor prevented."); + } catch (Exception e) { + // do nothing - success + } + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCycleSerializationTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCycleSerializationTest.java new file mode 100644 index 0000000000..47900402bf --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/ContainmentCycleSerializationTest.java @@ -0,0 +1,495 @@ +/* + * 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.api; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +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 test.sdo21.tests.util.CTSUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Sequence; +import commonj.sdo.helper.HelperContext; + +/** + * Tests serialization of containment cycles. Each test passes if the serialization does + * not generate output representing the containment cycle. There is a test case for + * each of the various mechanisms through which a containment cycle may be created and serialized. + * + * Note also that Java serialization of a containment cycle should result in an IllegalStateException, + * while XMLHelper and XMLStreamHelper serialization should successfully serialize the DataObject + * absent the containment cycle. + */ +public abstract class ContainmentCycleSerializationTest extends CTSConsistencyBase { + + + public ContainmentCycleSerializationTest() { + } + + public static class DynamicMetadata extends ContainmentCycleSerializationTest { + public DynamicMetadata() { + + } + public TestDataFactory createTestDataFactory() { + + return new StandardDynamicFactory(); + } + } + + public static class XSDMetadata extends ContainmentCycleSerializationTest { + + public XSDMetadata() { + } + + public TestDataFactory createTestDataFactory() { + + return new StandardXSDFactory(); + } + } + + + @Before + public void setUp () throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. + * @throws Exception + */ + @Test + public void oneMemberSingleValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + setSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. + * @throws Exception + */ + @Test + public void nMemberSingleValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + setSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. + * @throws Exception + */ + @Test + public void oneMemberMultiValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + setMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. + * @throws Exception + */ + @Test + public void nMemberMultiValueSetDataObject() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + setManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create a 1-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the static version + * of this test case. + * @throws Exception + */ + @Test + public void oneMemberReturnedList() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + returnedListOneMember(dataObj1); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create an n-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the static version + * of this test case. + * @throws Exception + */ + @Test + public void nMemberReturnedList() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + returnedListNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. + * @throws Exception + */ + @Test + public void oneMemberSingleValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + + sequenceSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. + * @throws Exception + */ + @Test + public void nMemberSingleValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + + sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * serialization. + * @throws Exception + */ + @Test + public void oneMemberMultiValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + + sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * serialization. + * @throws Exception + */ + @Test + public void nMemberMultiValueSequence() throws Exception { + DataObject dataObj1 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + DataObject dataObj2 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + DataObject dataObj3 = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + + sequenceManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, getScope()); + } + + /** + * Attempt to serialize the DataObject in via XML, XMLStreamHelper, + * and Java serialization. + * @param dataObj + */ + private void attemptSerialization(DataObject dataObj, HelperContext scope) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + assertTrue("Containment cycle was not established.", + containmentCycleExists(dataObj)); + try { + CTSUtil.serializeDataObjectXML(dataObj, baos, scope); + } catch (Exception e) { + fail("XML serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + "."); + e.printStackTrace(); + } + + assertTrue("Containment cycle was affected by XMLHelper serialization.", + containmentCycleExists(dataObj)); + + try { + CTSUtil.serializeDataObjectJava(getTestHelper(), dataObj, baos, scope); + fail("Java serialization of a containment cycle should result in an IllegalStateException."); + } catch (Exception e) { + // Do nothing. An Exception is expected in this case. + } + + assertTrue("Containment cycle was affected by Java serialization.", + containmentCycleExists(dataObj)); + + // try { + // ParamatizedTestUtil.serializeDataObjectStream(dataObj, baos, scope); + // } catch (Exception e) { + // fail("XMLStreamHelper serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + "."); + // e.printStackTrace(); + // } + + // assertTrue("Containment cycle was affected by XMLStreamHelper serialization.", + // containmentCycleExists(dataObj)); + } + + /** + * Returns true if input DataObject root is part of a containment cycle, + * false otherwise. + * @param root + * @return + */ + private static boolean containmentCycleExists (DataObject root) + { + DataObject curr = root.getContainer(); + + while (curr != null) + { + if (curr == root) + return true; + + curr = curr.getContainer(); + } + return false; + } + + /** + * Use setDataObject to create a one member containment cycle. + * @param dataObj1 + */ + private void setSingleValueOneMember(DataObject dataObj1) { + try { + dataObj1.setDataObject("contain", dataObj1); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Use setDataObject to create an N-member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataobj3 + */ + private void setSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + dataObj1.setDataObject("contain", dataObj2); + dataObj2.setDataObject("contain", dataObj3); + + try { + dataObj3.setDataObject("contain", dataObj1); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Use setList to create a one member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void setMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + List addList = new ArrayList(); + addList.add(dataObj2); + addList.add(dataObj1); + addList.add(dataObj3); + + try { + dataObj1.setList("containMany", addList); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Use setList to create an N-member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void setManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + List addList = new ArrayList(); + + dataObj1.setDataObject("contain", dataObj2); + dataObj2.setDataObject("contain", dataObj3); + addList.add(dataObj1); + + try { + dataObj3.setList("containMany", addList); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create a 1-member containment cycle by making updates to a returned List. + * @param dataObj1 + */ + private void returnedListOneMember(DataObject dataObj1) { + List returnedList = dataObj1.getList("containMany"); + + try { + returnedList.add(dataObj1); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create an n-member containment cycle by making updates to a returned List. + * @param dataObj1 + * @param dataObj2 + * @param dataobj3 + */ + private void returnedListNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + dataObj1.setDataObject("contain", dataObj2); + dataObj2.setDataObject("contain", dataObj3); + + List returnedList = dataObj3.getList("containMany"); + + try { + returnedList.add(dataObj1); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create a 1-member containment cycle by making updates to a Sequence. + * The data member in this case is single valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceSingleValueOneMember(DataObject dataObj1) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + Sequence sequence = dataObj1.getSequence(); + + try { + sequence.add("contain", dataObj1); + } catch (Exception e) { + // do nothing - success + } + + } + + /** + * Create an n-member containment cycle by making updates to a Sequence. + * The data member in this case is single valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + Sequence sequence1 = dataObj1.getSequence(); + Sequence sequence2 = dataObj2.getSequence(); + Sequence sequence3 = dataObj3.getSequence(); + + sequence1.add("contain", (Object) dataObj2); + sequence2.add("contain", (Object) dataObj3); + + + try { + sequence3.add("contain", (Object) dataObj1); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create a 1-member containment cycle by making updates to a Sequence. + * The data member in this case is many valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + Sequence sequence = dataObj1.getSequence(); + + sequence.add("containMany", dataObj2); + sequence.add("containMany", dataObj3); + + try { + sequence.add("containMany", dataObj1); + } catch (Exception e) { + // do nothing - success + } + } + + /** + * Create an n-member containment cycle by making updates to a Sequence. + * The data member in this case is many valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + List addList = new ArrayList(); + + addList.add(dataObj2); + dataObj1.setList("containMany", addList); + + addList.clear(); + addList.add(dataObj3); + dataObj2.setList("containMany", addList); + + Sequence sequence = dataObj3.getSequence(); + + try { + sequence.add("containMany", dataObj1); + } catch (Exception e) { + // do nothing - success + } + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CopyHelper/CopyEqualityTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CopyHelper/CopyEqualityTest.java new file mode 100644 index 0000000000..7c49576557 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/CopyHelper/CopyEqualityTest.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. + * + * $Rev$ $Date$ + */ +package test.sdo21.tests.api.CopyHelper; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +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 test.sdo21.tests.api.CTSConsistencyBase; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.EqualityHelper; + +/** + * TestCase tests shallow and deep copy functions of CopyHelper utilizing the + * EqualityHelper class. Can be used to test dynamic, mixed and static + * DataObjects + * TODO this would be better as a test of CopyHelper alone, having established + * EqualityHelper as a trusted base by independent testing. As it stands it + * does not identify whether issues exist in the copy helper or the equality helper + */ +public abstract class CopyEqualityTest extends CTSConsistencyBase { + private DataObject testDO; + + public CopyEqualityTest() { + } + + public static class DynamicMetadata extends CopyEqualityTest { + public DynamicMetadata() { + + } + public TestDataFactory createTestDataFactory() { + + return new StandardDynamicFactory(); + } + } + + public static class XSDMetadata extends CopyEqualityTest { + + public XSDMetadata() { + } + + public TestDataFactory createTestDataFactory() { + + return new StandardXSDFactory(); + } + } + + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + + @Before + public void setUp () throws Exception { + super.setUp(); + testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE); + ((StandardFactory)factory).populateFields(testDO, getScope()); + } + + /** + * Performs a shallow copy and verifies that shallow equality is true + * between the source and output for the copy. + */ + @Test + public void testShallowCopyShallowEquality() { + assertNotNull("data object not created correctly", testDO); + DataObject shallowCopy = getScope().getCopyHelper().copyShallow(testDO); + + EqualityHelper equalityH = getScope().getEqualityHelper(); + + assertTrue("Shallow copy did not result in shallow equality", equalityH.equalShallow(testDO, shallowCopy)); + } + + /** + * Performs a shallow copy and verifies that deep equality is false + * (assuming passed DO includes a containment reference) between the source + * and output for the copy. + */ + @Test + public void testShallowCopyDeepEquality() { + assertNotNull("data object not created correctly", testDO); + DataObject shallowCopy = getScope().getCopyHelper().copyShallow(testDO); + + EqualityHelper equalityH = getScope().getEqualityHelper(); + + // TODO: Determine why Deep equality results when Type is sequenced. + + assertFalse("Shallow copy should not result in deep equality for this Type.", equalityH.equal(testDO, + shallowCopy)); + } + + /** + * Performs a deep copy and verifies that shallow equality exists between + * the source and output from the copy. + */ + @Test + public void testDeepCopyShallowEquality() { + assertNotNull("data object not created correctly", testDO); + DataObject deepCopy = getScope().getCopyHelper().copy(testDO); + + EqualityHelper equalityH = getScope().getEqualityHelper(); + + assertTrue("Deep copy did not result in shallow equality.", equalityH.equalShallow(testDO, deepCopy)); + } + + /** + * Performs a deep copy and verifies that deep equality exists between the + * source and output from the copy. + */ + @Test + public void testDeepCopyDeepEquality() { + assertNotNull("data object not created correctly", testDO); + DataObject deepCopy = getScope().getCopyHelper().copy(testDO); + + EqualityHelper equalityH = getScope().getEqualityHelper(); + + assertTrue("Deep copy did not result in deep equality.", equalityH.equal(testDO, deepCopy)); + } +} 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.");
+ }
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyDynamic.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyDynamic.java new file mode 100644 index 0000000000..d283d759ec --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyDynamic.java @@ -0,0 +1,34 @@ +/*
+ * 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 test.sdo21.tests.TestData.StandardDynamicFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+public class DataFactoryConsistencyDynamic extends DataFactoryConsistencyBase {
+
+ public TestDataFactory createTestDataFactory() {
+
+ return new StandardDynamicFactory();
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencySuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencySuite.java new file mode 100644 index 0000000000..0bc165b725 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencySuite.java @@ -0,0 +1,31 @@ +/*
+ * 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 org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {DataFactoryConsistencyDynamic.class,
+ DataFactoryConsistencyXSD.class})
+public class DataFactoryConsistencySuite {
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyXSD.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyXSD.java new file mode 100644 index 0000000000..3572d63c68 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataFactory/DataFactoryConsistencyXSD.java @@ -0,0 +1,34 @@ +/*
+ * 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 test.sdo21.tests.TestData.StandardXSDFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+public class DataFactoryConsistencyXSD extends DataFactoryConsistencyBase {
+
+ public TestDataFactory createTestDataFactory() {
+
+ return new StandardXSDFactory();
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyBase.java new file mode 100644 index 0000000000..c5c488e709 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyBase.java @@ -0,0 +1,147 @@ +/*
+ * 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: 536535 $ $Date: 2007-05-09 15:04:49 +0100 (Wed, 09 May 2007) $
+ */
+package test.sdo21.tests.api.DataGraph;
+
+import static org.junit.Assert.assertEquals;
+
+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 commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.impl.HelperProvider;
+
+public abstract class DataGraphConsistencyBase extends CTSConsistencyBase {
+
+
+ @Before
+ public void setUp () throws Exception {
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Verify the proper function of DataGraph.createRootObject(Type).
+ */
+ @Test
+ public void testCreateRootObjectByType() {
+ Type testType = testDO.getType();
+
+ DataGraph dataGraph = getTestHelper().createDataGraph();
+ DataObject rootDO = dataGraph.createRootObject(testType);
+
+ assertEquals("DataObject.getDataGraph() did not return the expected DataGraph.",
+ rootDO.getDataGraph(),
+ dataGraph);
+
+ assertEquals("DataGraph.getRootObject() did not return the expected DataObject.",
+ dataGraph.getRootObject(),
+ rootDO);
+ }
+
+ /**
+ * Verify the proper function of DataGraph.createRootObject(URI,Name).
+ * @throws Exception
+ */
+ @Test
+ public void testCreateRootObjectByURI() throws Exception {
+ // we are constrained to work with the default helper context for these APIs
+ // so lets override the default behaviour of the test framework for this method
+
+ HelperContext globalScope = HelperProvider.getDefaultContext();
+ factory.defineMetaData(globalScope);
+ testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
+ Type testType = testDO.getType();
+
+ DataGraph dataGraph = getTestHelper().createDataGraph();
+ DataObject rootDO = dataGraph.createRootObject(testType.getURI(), testType.getName());
+
+ assertEquals("DataObject.getDataGraph() did not return the expected DataGraph.",
+ rootDO.getDataGraph(),
+ dataGraph);
+
+ assertEquals("DataGraph.getRootObject() did not return the expected DataObject.",
+ dataGraph.getRootObject(),
+ rootDO);
+ }
+
+
+
+ /**
+ * Verify the proper function of DataGraph.getType(URI, Name) when the
+ * DataGraph RootObject was created by Type
+ * @throws Exception
+ */
+ @Test
+ public void testDataGraphGetType() throws Exception {
+ // we are constrained to work with the default helper context for these APIs
+ // so lets override the default behaviour of the test framework for this method
+
+ HelperContext globalScope = HelperProvider.getDefaultContext();
+ //factory.defineMetaData(globalScope); // Don't need to defineMetaData because already done in the previous test
+ testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
+
+ Type testType = testDO.getType();
+
+ DataGraph dataGraph = getTestHelper().createDataGraph();
+ dataGraph.createRootObject(testType);
+
+ assertEquals("DataGraph.getType() did not return the expected Type.",
+ dataGraph.getType(testType.getURI(), testType.getName()),
+ testType);
+ }
+
+ /**
+ * Verify the proper function of DataGraph.getType(URI, Name) when the
+ * DataGraph RootObject was created by URI
+ * @throws Exception
+ */
+ @Test
+ public void testDataGraphGetURI() throws Exception {
+ // we are constrained to work with the default helper context for these APIs
+ // so lets override the default behaviour of the test framework for this method
+
+ HelperContext globalScope = HelperProvider.getDefaultContext();
+ //factory.defineMetaData(globalScope); // Don't need to defineMetaData because already done in the previous test
+ testDO = factory.createTestData(globalScope, StandardFactory.API_TYPE);
+
+ Type testType = testDO.getType();
+
+ DataGraph dataGraph = getTestHelper().createDataGraph();
+ dataGraph.createRootObject(testType.getURI(), testType.getName());
+
+ assertEquals("DataGraph.getType() did not return the expected Type.",
+ dataGraph.getType(testType.getURI(), testType.getName()),
+ testType);
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyDynamic.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyDynamic.java new file mode 100644 index 0000000000..8d85b2783d --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyDynamic.java @@ -0,0 +1,34 @@ +/*
+ * 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.DataGraph;
+
+import test.sdo21.tests.TestData.StandardDynamicFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+public class DataGraphConsistencyDynamic extends DataGraphConsistencyBase {
+
+ public TestDataFactory createTestDataFactory() {
+
+ return new StandardDynamicFactory();
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencySuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencySuite.java new file mode 100644 index 0000000000..f362fef26a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencySuite.java @@ -0,0 +1,31 @@ +/*
+ * 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.DataGraph;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {DataGraphConsistencyDynamic.class,
+ DataGraphConsistencyXSD.class})
+public class DataGraphConsistencySuite {
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyXSD.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyXSD.java new file mode 100644 index 0000000000..bdbfefcd95 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataGraph/DataGraphConsistencyXSD.java @@ -0,0 +1,34 @@ +/*
+ * 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.DataGraph;
+
+import test.sdo21.tests.TestData.StandardXSDFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+public class DataGraphConsistencyXSD extends DataGraphConsistencyBase {
+
+ public TestDataFactory createTestDataFactory() {
+
+ return new StandardXSDFactory();
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java new file mode 100644 index 0000000000..0654a7dc99 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyBase.java @@ -0,0 +1,739 @@ +/* + * 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.DataObject; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +import test.sdo21.tests.TestData.StandardFactory; +import test.sdo21.tests.api.CTSConsistencyBase; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; + +/** + * Tests for proper updates to DataObject and their value changes due to the + * updates. + */ +public abstract class DataObjectConsistencyBase extends CTSConsistencyBase { + + + /** + * testActiveUpdatingList verifies that updates made to a List returned from + * a DataObject are reflected in the DataObject and vice versa. + * @throws Exception + */ + @Test + public void testActiveUpdatingList() throws Exception { + DataObject root = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject child1 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject child2 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + DataObject child3 = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + List addList = new ArrayList(); + List returnedList; + + addList.add(child1); + + root.setList("containMany", addList); + + // Verify the pre-condition. The List initially has a size of 1. + assertEquals("The List returned by getList was not of the expected size.", 1, root.getList("containMany").size()); + + returnedList = root.getList("containMany"); + + /** + * Add a member to the returned List and verify that it is reflected in + * the DataObject. + */ + + returnedList.add(child2); + + assertEquals("Update to returned List did not affect DataObject correctly. Size of children is not 2", + 2, root.getList("containMany").size()); + assertEquals("Update to returned List did not affect DataObject correctly. child1's container is not equal to root", + root, child1.getContainer()); + assertEquals("Update to returned List did not affect DataObject correctly. child2's container is not equal to root", + root, child2.getContainer()); + + /** + * Delete a child and verify that the returned List is automatically + * affected. + */ + + child1.delete(); + assertEquals("Deleting a DataObject did not affect the returned List.", 1, returnedList.size()); + + /** + * Verify that the DataObject delete did not affect the original List + * used in the DataObject.setList(). + */ + + assertEquals("Deleting a DataObject should not affect a List unassociated with the DataObject.", + 1, + addList.size()); + + /** + * Call DataObject.setList() and verify that the previously returned + * List reflects the new List. + */ + + addList.add(child2); + addList.add(child3); + root.setList("containMany", addList); + + assertEquals("The List returned by DataObject.getList() was not affected by a subsequent DataObject.setList().", + 3, + returnedList.size()); + /** + * Call List.remove() on the returned List and verify that the + * DataObject is affected. + */ + + DataObject child = (DataObject)returnedList.get(1); + + // Verify the precondition. The child should have root as its container. + assertEquals("List.setList() did not cause the expected containment relationship.", root, child.getContainer()); + + returnedList.remove(1); + + assertEquals("List.remove() did not have the expected effect on the DataObject. There are more than 2 children", + 2, root.getList("containMany").size()); + assertNull("List.remove() did not have the expected effect on the DataObject. child container is not null", + child.getContainer()); + + /** + * Call List.clear() and veirfy that the DataObject is affected. + */ + returnedList.clear(); + + assertEquals("List.clear() on the returned List did not have the expected effect on the DataObject. The size of the list of children is not 0", + 0,root.getList("containMany").size()); + assertNull("List.clear() on the returned List did not have the expected effect on the DataObject. child1.getContainer is not null", + child1.getContainer()); + assertNull("List.clear() on the returned List did not have the expected effect on the DataObject. child2.getContainer is not null", + child2.getContainer()); + + } + + /** + * testActiveUpdatingSequence verifies that updates made to a Sequence + * returned from a DataObject are reflected in the DataObject and vice + * versa. + * @throws Exception + */ + @Test + public void testActiveUpdatingSequence() throws Exception { + + DataObject sequenceDO = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE); + Sequence sequence = sequenceDO.getSequence(); + List letterList = sequenceDO.getList("Letters"); + List numberList = sequenceDO.getList("Numbers"); + + assertTrue("The Type of sequencedElem is not sequenced. testActiveUpdatingSequence may not proceed", + sequenceDO.getType().isSequenced()); + + letterList.clear(); + numberList.clear(); + + // Verify the precondition. The Sequence should be empty. + assertEquals("The Sequence should initially be empty.", 0, sequence.size()); + + /** + * Add values to the DataObject and verify that the Sequence is + * affected. + */ + + letterList.add("A"); + letterList.add("B"); + numberList.add(Integer.valueOf(8)); + + // The expected arrangement of sequence is as follows + // {<Letters, "A">, <Letters, "B">, <Numbers, 8>} + + assertEquals("Adding values to the DataObject did not affect the returned Sequence. Sequence size is not 3", + 3, sequence.size()); + assertEquals("Adding values to the DataObject did not affect the returned Sequence. getValue[0] is not A", + "A", sequence.getValue(0)); + assertEquals("Adding values to the DataObject did not affect the returned Sequence. getValue[1] is not B", + "B", sequence.getValue(1) + ); + assertEquals("Adding values to the DataObject did not affect the returned Sequence. getValue[2] is not equal to 8", + sequence.getValue(2), + Integer.valueOf(8)); + + /** + * Remove a value from the DataObject and verify that the Sequence is + * affected. + */ + + letterList.remove(1); + + // The expected arrangement of sequence is as follows: {<Letters, "A">, + // <Numbers, 8>} + assertEquals("Removing a value from the DataObject did not affect the returned Sequence.", sequence.size(), 2); + assertEquals("Removing a value from the DataObject did not affect the returned Sequence.", + "A", sequence.getValue(0) + ); + assertEquals("Removing a value from the DataObject did not affect the returned Sequence.", + Integer.valueOf(8), + sequence.getValue(1)); + + /** + * Remove a value from the Sequence and verify that the DataObject is + * affected. + */ + + sequence.remove(1); + + // The expected arrangement of sequence is as follows: {<Letters, "A">} + + assertEquals("Removing a value from the Sequence did not affect the DataObject. Size of List for numbers is not 0", + 0, sequenceDO.getList("Numbers").size()); + + /** + * Add a value to the Sequence and verify that the DataObject is + * affected. + */ + sequence.add("Numbers", Integer.valueOf(16)); + + // The expected arrangement of sequence is as follows: {<Letters, "A">, + // <Numbers, 16>} + + assertEquals("Adding a value to the Sequence did not have the expected effect on the DataObject.", sequenceDO + .getList("Numbers").size(), 1); + assertEquals("Adding a value to the Sequence did not have the expected effect on the DataObject.", sequenceDO + .getList("Numbers").get(0), Integer.valueOf(16)); + + // Add several values to the Sequence (via the DataObject) to make + // Sequence.move() meaningful. + + letterList.add("C"); + numberList.add(Integer.valueOf(15)); + numberList.add(Integer.valueOf(4)); + letterList.add("K"); + letterList.add("M"); + numberList.add(Integer.valueOf(-10)); + + // The expected arrangement of sequence is as follows + // {<Letters, "A">, <Numbers, 16>, <Letters, "C">, <Numbers, 15>, + // <Numbers, 4>, <Letters, "K">, <Letters, "M">, <Numbers, -10>} + + /** + * Use Sequence.move() and verify that the changes are reflected in the + * DataObject. + */ + + sequence.move(1, 5); + sequence.move(4, 2); + + // The expected arrangement of sequence is as follows + // {<Letters, "A">, <Letters, "K">, <Letters, "C">, <Numbers, 15>, + // <Numbers, 16>, <Numbers, 4>, <Letters, "M">, <Numbers, -10>} + + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + 4, + letterList.size()); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + "A", + letterList.get(0)); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + "K", + letterList.get(1)); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + "C", + letterList.get(2)); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + "M", + letterList.get(3)); + + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + 4, + numberList.size()); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + Integer.valueOf(15), + numberList.get(0)); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + Integer.valueOf(16), + numberList.get(1)); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + Integer.valueOf(4), + numberList.get(2)); + assertEquals("Sequence.move() did not have the expected effect on the DataObject represented by the Sequence.", + Integer.valueOf(-10), + numberList.get(3)); + + // TODO: Add a value to a specific location within the Sequence and + // veirfy the effect on the DataObject. Awaiting Tuscany-931 + } + + /** + * Verfies that the Property being tested throughout these tests is a + * contaiment Property + */ + @Test + public void verifyIsContainment() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + assertTrue("Property.isContainment() returned an unexpected value.", containmentProp.isContainment()); + } + + /** + * Verifies that the initial state after clearContainer is a state in which + * the DataObject does not have a container. + */ + @Test + public void verifyNullContainer() { + assertNull("DataObject.getContainer() returned an unexpected value.", testDO.getContainer()); + } + + /** + * Verfiies that the containerless DataObject returns null for + * getContainmentProperty + */ + @Test + public void verifyNullContainmentProperty() { + assertNull("DataObject.getContainmentProprety() returned an unexpected value.", testDO.getContainmentProperty()); + } + + /** + * Assign both dataObj1 and dataObj2 to testDO container, then verify + * DataObject.getContainer() for dataObj1 and dataObj2 + */ + @Test + public void verifyGetContainer() { + List addList = new ArrayList(); + Type type = testDO.getType(); + Property containmentProp = testDO.getInstanceProperty("containMany"); + + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // Ensure that any previous containment relationships are broken. + + addList.clear(); + testDO.setList("containMany", addList); + testDO.detach(); + addList.clear(); + + addList.add(dataObj1); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + // Verify containment of dataObj1 and dataObj2 by testDO + + assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj1 + .getContainer()); + + assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj2 + .getContainer()); + } + + /** + * Assign both dataObj1 and dataObj2 to testDO container, then verify + * DataObject.getContainmentProperty for dataObj1 and dataObj2 + */ + @Test + public void verifyGetContainmentProperty() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + addList.add(dataObj1); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + assertEquals("DataObject.getContainmentProperty() did not return the appropriate Property.", + containmentProp, + dataObj1.getContainmentProperty()); + + assertEquals("DataObject.getContainmentProperty() did not return the appropriate Property.", + containmentProp, + dataObj2.getContainmentProperty()); + } + + /** + * Assign both dataObj1 and dataObj2 to testDO container, then verify the + * contents of the containing property in testDO + */ + @Test + public void verifyContainmentContents() { + assertNull("testDO container != null", testDO.getContainer()); + assertEquals("testDO.containMany != 0", 0, testDO.getList("containMany").size()); + + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + addList.add(dataObj1); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + List returnedList = testDO.getList(containmentProp); + + assertEquals("DataObject.getList() size is incorrect", 2, returnedList.size()); + assertEquals("DataObject.getList() did not return the List specified in DataObject.setList()", + dataObj1, + returnedList.get(0)); + assertEquals("DataObject.getList() did not return the List specified in DataObject.setList()", + dataObj2, + returnedList.get(1)); + } + + /** + * Assign both dataObj1 and dataObj2 to testDO container, then Assign + * dataObj2 to dataObj1 container. Verify dataObj2 is automatically removed + * from testDO container + */ + @Test + public void verifyAutomaticRemoval() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + addList.add(dataObj1); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + // Verify the precondition + + assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj1 + .getContainer()); + + assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", testDO, dataObj2 + .getContainer()); + + // After the following section, it should be true that: testDO contains + // dataObj1 contains dataObj2 + + addList.clear(); + addList.add(dataObj2); + dataObj1.setList(containmentProp, addList); + + // Verify automatic removal of dataObj2 from testDO container + + List returnedList = testDO.getList(containmentProp); + assertEquals("Once placed in a new container, the DataObject should no longer appear in the former container.", + 1, + returnedList.size()); + assertEquals("Once placed in a new container, the DataObject should no longer appear in the former container.", + dataObj1, + returnedList.get(0)); + } + + /** + * Assign both dataObj1 and dataObj2 to testDO container, then Assign + * dataObj2 to dataObj1 container. Verify dataObj2 is contained by dataObj1 + */ + @Test + public void verifyNewContainer() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + addList.add(dataObj1); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + // After the following section, it should be true that: testDO contains + // dataObj1 contains dataObj2 + + addList.clear(); + addList.add(dataObj2); + dataObj1.setList(containmentProp, addList); + + // Verify that dataObj2 was correctly added to dataObj1 container + + List returnedList = dataObj1.getList(containmentProp); + assertEquals("Once assigned to a new container, the DataObject should appear in the new container.", + 1, + returnedList.size()); + assertEquals("Once assigned to a new container, the DataObject should appear in the new container.", + dataObj2, + returnedList.get(0)); + assertEquals("DataObject.getContainer() did not return the appropriate DataObject.", dataObj1, dataObj2 + .getContainer()); + } + + /** + * Verify that detach() removes the object from its container. + */ + @Test + public void verifyDetachRemoval() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // After the following section, it should be true that: dataObj1 + // contains testDO contains dataObj2 + + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + addList.clear(); + addList.add(testDO); + dataObj1.setList(containmentProp, addList); + + testDO.detach(); + + List returnedList = dataObj1.getList(containmentProp); + assertEquals("Detaching the contained object did not remove it from container", 0, returnedList.size()); + + assertNull("DataObject.getContainer() did not return null as expected for a detached DataObject.", testDO + .getContainer()); + } + + /** + * Verify that DataObject.detach() does not affect objects contained by the + * detached DataObject + */ + @Test + public void verifyDetachContainer() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // After the following section, it should be true that: dataObj1 + // contains testDO contains dataObj2 + + addList.add(testDO); + dataObj1.setList(containmentProp, addList); + addList.clear(); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + testDO.detach(); + + List returnedList = testDO.getList(containmentProp); + + assertEquals("Detaching a DataObject should not detach its contained DataObjects.", 1, returnedList.size()); + assertEquals("Detaching a DataObject should not affect it as a container.", dataObj2, returnedList.get(0)); + } + + /** + * Verify that DataObject.detach() does not affect objects contained by the + * detached DataObject + */ + @Test + public void verifyDetachContainedDOs() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // After the following section, it should be true that: dataObj1 + // contains testDO contains dataObj2 + + addList.add(testDO); + dataObj1.setList(containmentProp, addList); + addList.clear(); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + testDO.detach(); + + assertEquals("Detaching a DataObject should not affect contained DataObjects.", testDO, dataObj2.getContainer()); + } + + /** + * Verify that DataObject.delete() removes the object from its container. + */ + @Test + public void verifyDeleteRemoval() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // After the following section, it should be true that: dataObj1 + // contains testDO contains dataObj2 + + addList.add(testDO); + dataObj1.setList(containmentProp, addList); + addList.clear(); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + testDO.delete(); + + assertEquals("Deleting the DataObject did not remove it from its container.", 0, dataObj1 + .getList(containmentProp).size()); + } + + /** + * Verify that DataObject.delete() removes the containment reflected by the + * deleted DataObject + */ + @Test + public void verifyDeleteResultsOnDeleted() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // After the following section, it should be true that: dataObj1 + // contains testDO contains dataObj2 + + addList.add(testDO); + dataObj1.setList(containmentProp, addList); + addList.clear(); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + testDO.delete(); + + assertNotNull("A deleted DataObject should remain programatically accessible.", testDO); + assertNull("Deleting the DataObject did not affect its view of its container.", testDO.getContainer()); + } + + /** + * Verify that DataObject.delete() removes its contents as a container. + */ + @Test + public void verifyDeleteAsContainer() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // After the following section, it should be true that: dataObj1 + // contains testDO contains dataObj2 + + addList.add(testDO); + dataObj1.setList(containmentProp, addList); + addList.clear(); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + testDO.delete(); + + assertNotNull("A deleted DataObject should remain programatically accessible.", testDO); + assertEquals("Deleting the DataObject did not empty it as a container.", 0, testDO.getList(containmentProp) + .size()); + } + + /** + * Verify that DataObject.delete() affects contained DataObjects. + */ + @Test + public void verifyDeleteAffectOnContained() { + Property containmentProp = testDO.getInstanceProperty("containMany"); + List addList = new ArrayList(); + Type type = testDO.getType(); + DataObject dataObj1 = getScope().getDataFactory().create(type); + DataObject dataObj2 = getScope().getDataFactory().create(type); + + // After the following section, it should be true that: dataObj1 + // contains testDO contains dataObj2 + + addList.add(testDO); + dataObj1.setList(containmentProp, addList); + addList.clear(); + addList.add(dataObj2); + testDO.setList(containmentProp, addList); + + testDO.delete(); + + assertNull("Deleting the containing DataObject was not reflected in the contained DataObject.", dataObj2 + .getContainer()); + } + + /** + * testRecursiveDeletion verifies that when a DataObject is deleted, all + * (recursively) contained DataObjects are also deleted. + */ + @Test + public void testRecursiveDeletion() { + Type type = testDO.getType(); + Property containmentProp = type.getProperty("containMany"); + + assertTrue("Cannot continue with test because Property.isContainment() is false.", containmentProp + .isContainment()); + + DataFactory df = getScope().getDataFactory(); + DataObject child1 = df.create(type); + DataObject child2 = df.create(type); + DataObject child3 = df.create(type); + + List addList = new ArrayList(); + + /** + * Establish a series of containment relationships + */ + + addList.add(child1); + testDO.setList(containmentProp, addList); + + addList.clear(); + addList.add(child2); + child1.setList(containmentProp, addList); + + addList.clear(); + addList.add(child3); + child2.setList(containmentProp, addList); + + /** + * Verify that containment has been established correctly. + */ + + assertEquals("The expected containment relationships were not correctly formed.", child3.getContainer(), child2); + assertEquals("The expected containment relationships were not correctly formed.", child2.getContainer(), child1); + assertEquals("The expected containment relationships were not correctly formed.", child1.getContainer(), testDO); + + /** + * Delete the root DataObject and verify that contained DataObjects are + * recursively affected. + */ + + testDO.delete(); + + assertEquals("DataObject.delete() did not recursively affect contained DataObjects.", testDO + .getList(containmentProp).size(), 0); + assertNull("DataObject.delete() did not recursively affect contained DataObjects.", child1.getContainer()); + assertNull("DataObject.delete() did not recursively affect contained DataObjects.", child2.getContainer()); + assertNull("DataObject.delete() did not recursively affect contained DataObjects.", child3.getContainer()); + + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyDynamic.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyDynamic.java new file mode 100644 index 0000000000..4b1d2fc4a0 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyDynamic.java @@ -0,0 +1,34 @@ +/* + * 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.DataObject; + +import test.sdo21.tests.TestData.StandardDynamicFactory; +import test.sdo21.tests.TestData.TestDataFactory; + +public class DataObjectConsistencyDynamic extends DataObjectConsistencyBase { + + public TestDataFactory createTestDataFactory() { + + return new StandardDynamicFactory(); + } + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencySuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencySuite.java new file mode 100644 index 0000000000..1ef7b0cb3e --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencySuite.java @@ -0,0 +1,31 @@ +/* + * 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.DataObject; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( {DataObjectConsistencyDynamic.class, + DataObjectConsistencyXSD.class}) +public class DataObjectConsistencySuite { + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyXSD.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyXSD.java new file mode 100644 index 0000000000..2ce75bbf37 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectConsistencyXSD.java @@ -0,0 +1,34 @@ +/* + * 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.DataObject; + +import test.sdo21.tests.TestData.StandardXSDFactory; +import test.sdo21.tests.TestData.TestDataFactory; + +public class DataObjectConsistencyXSD extends DataObjectConsistencyBase { + + public TestDataFactory createTestDataFactory() { + + return new StandardXSDFactory(); + } + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java new file mode 100644 index 0000000000..ce40f7b8d3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java @@ -0,0 +1,395 @@ +/* + * 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.DataObject; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +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.util.CTSUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; + +import java.util.List; +import java.util.ArrayList; + +/** + * Set of tests for DataObject APIs. + * Currently limited to a fairly narrow set of tests on the set(Property, value), isSet(), and unSet() + * methods. + * <p/> + * TODO Need to extend the test set or migrate tests from other existing tests as yet unidentified. + */ +public class DataObjectTest extends CTSTestCase { + + private boolean debug = false; + private static int uniqueNumber = 1; + + @Before + public void setUp() throws Exception { + super.setUp(); + } + + + + + /** + * This test checks that getInstanceProperties returns all properties + * defined by the DataObject's type, regardless of whether they are set or + * not. It also checks that open content properties only appear in + * getInstanceProperties if they are set. Related sections in the + * specification are / 3.1.9 / 3.1.11 Related JIRA SDO-179 + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=14">2.1 spec section 3.1.1</a> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=18">2.1 spec section 3.1.9</a> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=20">2.1 spec section 3.1.11</a> + * @see <a href="http://www.xcalia.com/support/browse/SDO-179">SDO Spec JIRA 179</a> + * @throws Exception + */ + @Test + @Ignore("On demand open content property is not yet implemented in Tuscany.") + public void testGetInstancePropertiesSize() throws Exception { + + // define a type with two properties + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + CTSUtil.createPropertyDef(typeDef, "p1", "commonj.sdo#String", false, false, helperContext); + CTSUtil.createPropertyDef(typeDef, "p2", "commonj.sdo#String", false, false, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject dobj = helperContext.getDataFactory().create("", typeName); + + // getInstanceProperties() should return p1, p2 even though they are not + // set + // System.out.println(dobj.getInstanceProperties()); + assertEquals(2, dobj.getInstanceProperties().size()); + + dobj.set("p1", "foo"); + + // getInstanceProperties() should still return p1, p2 + assertEquals(2, dobj.getInstanceProperties().size()); + + dobj.unset("p1"); + + // getInstanceProperties() should still return p1, p2 + assertEquals(2, dobj.getInstanceProperties().size()); + + // set an on-demand open content property + dobj.set("p3", "foo"); + + // getInstanceProperties() should now return p1, p2, p3 + assertEquals(3, dobj.getInstanceProperties().size()); + + // unset the on-demand property + dobj.unset("p3"); + + // the spec says that open content properties only appear in + // getInstancePropeties if + // they are set so we expect the list to be smaller now + assertEquals(2, dobj.getInstanceProperties().size()); + } + + /** + * Tests an isMany=false Boolean type property in an open type for being set to false/unset. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> + * @see commonj.sdo.DataObject#isSet() + * @see commonj.sdo.DataObject#unset() + * @see commonj.sdo.DataObject#set(Property, Boolean) + * @throws Exception + */ + @Test + public void testIsSet_Boolean_false() throws Exception { + + // define a type with two properties + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + CTSUtil.createPropertyDef(typeDef, "b1", "commonj.sdo#Boolean", false, false, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + Property p = testDO.getInstanceProperty("b1"); + testDO.unset(p); + assertFalse("Property was set", testDO.isSet(p)); + testDO.set(p, false); + assertTrue("Property was not set ", testDO.isSet(p)); + } + + /** + * Tests an isMany=false Boolean type property in an open type for being set to true/unset. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> + * @see commonj.sdo.DataObject#getInstanceProperty(String) + * @see commonj.sdo.DataObject#isSet() + * @see commonj.sdo.DataObject#unset() + * @see commonj.sdo.DataObject#set(Property, Boolean) + * @throws Exception + */ + @Test + public void testIsSet_Boolean_true() throws Exception { + + // define a type with two properties + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + CTSUtil.createPropertyDef(typeDef, "b1", "commonj.sdo#Boolean", false, false, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + Property p = testDO.getInstanceProperty("b1"); + testDO.unset(p); + assertFalse("Property was set", testDO.isSet(p)); + testDO.set(p, true); + assertTrue("Property was not set " + testDO.get(p), testDO + .isSet(p)); + } + + /** + * Tests isSet() of Integer property where isMany = false in an open type. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> + * @see commonj.sdo.DataObject#isSet() + * @see commonj.sdo.DataObject#unset() + * @see commonj.sdo.DataObject#set(Property, Integer) + * @throws Exception + */ + @Test + public void testIsSet_Integer_0() throws Exception { + + // define a type with two properties + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + CTSUtil.createPropertyDef(typeDef, "i1", "commonj.sdo#Integer", false, false, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + Property p = testDO.getInstanceProperty("i1"); + testDO.unset(p); + assertFalse("Property was set", testDO.isSet(p)); + testDO.set(p, java.math.BigInteger.valueOf(0)); + assertTrue("Property was not set" + testDO.get(p), testDO.isSet(p)); + } + + /** + * Ensures correct behaviour (returns null) on attempting to get a non existent property in an open type.<br/> + * Tests isSet() after unset() and set() on isMany=false property + * @see commonj.sdo.DataObject#getInstanceProperty(String) + * @see commonj.sdo.DataObject#isSet() + * @see commonj.sdo.DataObject#unset() + * @see commonj.sdo.DataObject#set(Property, Integer) + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> + * @throws Exception + */ + @Test + public void testIsSet_Integer_1() throws Exception { + + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + CTSUtil.createPropertyDef(typeDef, "i1", "commonj.sdo#Integer", false, false, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + try { + Property p = testDO.getInstanceProperty("default"); + assertTrue("non null return for non-existent property in an open type", p==null); + } catch (Exception e) { + assertTrue("getInstanceProperty throws exception for non-existent property "+e, false); + } + + Property p = testDO.getInstanceProperty("i1"); + testDO.unset(p); + assertFalse("Property was set ", testDO.isSet(p)); + + testDO.set(p, java.math.BigInteger.valueOf(1)); + assertTrue("Property was not set ", testDO.isSet(p)); + } + + /** + * Tests isSet() after unset() and set() on isMany=false property of type Int in an open type + * @see commonj.sdo.DataObject#getInstanceProperty(String) + * @see commonj.sdo.DataObject#isSet() + * @see commonj.sdo.DataObject#unset() + * @see commonj.sdo.DataObject#set(Property, Integer) + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=16">2.1 spec section 3.1.5</a> + * @throws Exception + */ + @Test + public void testIsSet_int_1() throws Exception { + + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + Type intType = helperContext.getTypeHelper().getType("commonj.sdo", "Int"); + + CTSUtil.createPropertyDef(typeDef, "i1", intType, false, false); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + Property p = testDO.getInstanceProperty("i1"); + testDO.unset(p); + assertFalse("Property was not unset", testDO.isSet(p)); + + testDO.set(p, 1); + assertTrue("Property was not set " , testDO.isSet(p)); + } + + /** + * Tests an open type + * @throws Exception + */ + @Test + public void testIsSet_int_0() throws Exception { + try { + + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + Type intType = helperContext.getTypeHelper().getType("commonj.sdo", "Int"); + CTSUtil.createPropertyDef(typeDef, "i1", intType, false, false); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + Property p = testDO.getInstanceProperty("i1"); + testDO.unset(p); + assertFalse("Property was set", testDO.isSet(p)); + + testDO.set(p, 0); + if (debug) { + helperContext.getXMLHelper().save(testDO, "http://www.example.com/api_test", "apiTestElem", System.out); + } + assertTrue("Property was not set", testDO.isSet(p)); + + } catch (Exception e) { + assertFalse("No exception expected: received " + e.toString(), true); + } + } + + @Test + public void testOpenTypeBadPropertyReturnsDefault() { + // define an open type with no properties + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + // get() should not throw an exception but return an appropriate default value + assertEquals( null, testDO.get( "foo" ) ); + assertEquals( null, testDO.getDataObject( "foo" ) ); + assertEquals( null, testDO.getList( "foo" ) ); + assertEquals( null, testDO.getString( "foo" ) ); + assertEquals( null, testDO.getBigDecimal( "foo" ) ); + assertEquals( null, testDO.getBigInteger( "foo" ) ); + assertEquals( null, testDO.getDate( "foo" ) ); + assertEquals( null, testDO.getBytes( "foo" ) ); + assertEquals( (byte) 0, testDO.getByte( "foo" ) ); + assertEquals( (short) 0, testDO.getShort( "foo" ) ); + assertEquals( (int) 0, testDO.getInt( "foo" ) ); + assertEquals( (long) 0, testDO.getLong( "foo" ) ); + assertEquals( (double) 0, testDO.getDouble( "foo" ) ); + assertEquals( (float) 0, testDO.getFloat( "foo" ) ); + } + + /** + * Test that getList() returns null for an unset open content property. + * + */ + @Test + public void testGetList() { + + // define an open type with no properties + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + // test that getList() returns null for an unst open content property + assertNull( testDO.getList("foo") ); + testDO.set("foo", new ArrayList()); + assertNotNull( testDO.getList("foo") ); + testDO.unset("foo"); + assertNull( testDO.getList("foo") ); + } + + /** + * Test that it is possible to add a null value to a List retrieved by calling DataObject.getList() + * + */ + @Test + public void testAddNullToList() { + HelperContext helperContext = getScope(); + XMLDocument doc = helperContext.getXMLHelper().load("<catalog2><product2/><product2/></catalog2>"); + List listTest = doc.getRootObject().getList("product2"); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + listTest.add( null ); + assertEquals(3, listTest.size()); + String xml = helperContext.getXMLHelper().save( doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName() ); + assertTrue( xml.indexOf("xsi:nil=\"true\"") > 0 ); + + } + + /** + * Creates a unique type name for each test so that the types won't clash if an implementation + * provides its default HelperContext when running the tests. + * + * @return + */ + private String getTypeName() { + return "DataObjectTestType" + (++uniqueNumber); + } + + @Override + @After + public void tearDown() throws Exception { + super.tearDown(); + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DynamicTypesFromSchemaTestCase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DynamicTypesFromSchemaTestCase.java new file mode 100644 index 0000000000..3fb6c2f310 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/DynamicTypesFromSchemaTestCase.java @@ -0,0 +1,295 @@ +/* + * 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 java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.List; +import java.util.ListIterator; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.fail; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; + +import test.sdo21.framework.CTSTestCase; +import test.sdo21.framework.TestHelper; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * Tests methods of DataGraph except for change summary which is tested elsewhere. + */ +public class DynamicTypesFromSchemaTestCase extends CTSTestCase { + private final String DYNAMIC_ROOT_TYPE_0 = "TestType0"; + + private final String DYNAMIC_ROOT_TYPE_1 = "TestType1"; + + private final String DYNAMIC_ROOT_TYPE_2 = "TestType2"; + + private final String DYNAMIC_TYPES_SCHEMA = "/dynamicTypesFromSchema.xsd"; + + private final String DYNAMIC_TYPES_URI = "http://www.example.com/dynamicTypesFromSchema"; + + private HelperContext hc; + + private final String TEST_XML_DOC_0 = "/dynamicTypesFromSchema0.xml"; + + private final String TEST_XML_DOC_1 = "/dynamicTypesFromSchema1.xml"; + + private final String TEST_XML_DOC_2 = "/dynamicTypesFromSchema2.xml"; + + private List typeList; + + @Before + public void setUp() throws Exception { + TestHelper testHelper = getTestHelper(); + hc = testHelper.createHelperContext(); + + // Populate the meta data for the types defined in schema + URL url = getClass().getResource(DYNAMIC_TYPES_SCHEMA); + InputStream inputStream = url.openStream(); + XSDHelper xsdHelper = hc.getXSDHelper(); + typeList = xsdHelper.define(inputStream, url.toString()); + inputStream.close(); + } + + /** + * test of Schema complex types + */ + @Test + public void testDynamicTypeList() throws IOException { + if (typeList == null) { + fail("typeList unexpectedly null"); + } + + ListIterator li = typeList.listIterator(); + SortedSet<String> typeNameSet = new TreeSet<String>(); + while (li.hasNext()) { + Object obj = li.next(); + if (obj instanceof Type) { + typeNameSet.add(((Type)obj).getName()); + } else { + fail("a type list entry was not a type: " + obj.toString()); + } + } + assertTrue(typeNameSet.contains("Address")); + assertTrue(typeNameSet.contains("Component")); + assertTrue(typeNameSet.contains("TestType0")); + assertTrue(typeNameSet.contains("TestType1")); + assertTrue(typeNameSet.contains("TestType2")); + assertTrue(typeNameSet.contains("evenNumberOfOddOrEvenDigits")); + assertTrue(typeNameSet.contains("evenNumberOfOddOrEvenDigitsObject")); + assertTrue(typeNameSet.contains("month")); + assertTrue(typeNameSet.contains("monthList")); + assertTrue(typeNameSet.contains("monthObject")); + assertTrue(typeNameSet.contains("oddOrEvenDigits")); + assertTrue(typeNameSet.contains("oddOrEvenDigitsObject")); + assertTrue(typeNameSet.contains("smallBigDecimal")); + assertTrue(typeNameSet.contains("smallBigInteger")); + assertTrue(typeNameSet.contains("smallInt")); + assertTrue(typeNameSet.contains("smallIntObject")); + assertTrue(typeNameSet.contains("smallOddNumber")); + assertTrue(typeNameSet.contains("smallOddNumberObject")); + assertTrue(typeNameSet.contains("status")); + assertTrue(typeNameSet.contains("statusOrMonthList")); + } + + /** + * test #0 of Schema primitive datatypes + */ + @Test + public void testDynamicTypesGroup0() throws IOException { + if (hc == null) { + fail("the HelperContext unexpectedly null"); + } + + TypeHelper th = hc.getTypeHelper(); + Type rootType0 = th.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_0); + + assertNotNull(rootType0); + + DataFactory df = hc.getDataFactory(); + DataObject rootObject = df.create(rootType0); + + assertNotNull(rootObject); + + XMLHelper xh = hc.getXMLHelper(); + XMLDocument doc = xh.load(getClass().getResourceAsStream(TEST_XML_DOC_0)); + DataObject rootObject0 = doc.getRootObject(); + + assertNotNull(rootObject0); + List propList = rootObject0.getInstanceProperties(); + SortedSet<String> propNameSet = new TreeSet<String>(); + ListIterator li1 = propList.listIterator(); + while (li1.hasNext()) { + Object obj = li1.next(); + if (obj instanceof Property) { + propNameSet.add(((Property)obj).getName()); + } else { + fail("getInstanceProperties list contained: " + obj.toString()); + } + } + assertTrue("Property name set does not contain 'anyURI'.", propNameSet.contains("anyURI")); + assertTrue("Property name set does not contain 'base64Binary'.", propNameSet.contains("base64Binary")); + assertTrue("Property name set does not contain 'boolean'.", propNameSet.contains("boolean")); + assertTrue("Property name set does not contain 'date'.", propNameSet.contains("date")); + assertTrue("Property name set does not contain 'dateTime'.", propNameSet.contains("dateTime")); + assertTrue("Property name set does not contain 'decimal'.", propNameSet.contains("decimal")); + assertTrue("Property name set does not contain 'double'.", propNameSet.contains("double")); + assertTrue("Property name set does not contain 'duration'.", propNameSet.contains("duration")); + assertTrue("Property name set does not contain 'float'.", propNameSet.contains("float")); + assertTrue("Property name set does not contain 'gDay'.", propNameSet.contains("gDay")); + assertTrue("Property name set does not contain 'gMonth'.", propNameSet.contains("gMonth")); + assertTrue("Property name set does not contain 'gMonthDay'.", propNameSet.contains("gMonthDay")); + assertTrue("Property name set does not contain 'gYear'.", propNameSet.contains("gYear")); + assertTrue("Property name set does not contain 'gYearMonth'.", propNameSet.contains("gYearMonth")); + assertTrue("Property name set does not contain 'hexBinary'.", propNameSet.contains("hexBinary")); + assertTrue("Property name set does not contain 'string'.", propNameSet.contains("string")); + assertTrue("Property name set does not contain 'time'.", propNameSet.contains("time")); + } + + /** + * test #1 of Schema derived datatypes + */ + @Test + public void testDynamicTypesGroup1() throws IOException { + if (hc == null) { + fail("the HelperContext unexpectedly null"); + } + + TypeHelper th = hc.getTypeHelper(); + Type rootType = th.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_1); + + assertNotNull(rootType); + + DataFactory df = hc.getDataFactory(); + DataObject rootObject = df.create(rootType); + + assertNotNull(rootObject); + + XMLHelper xh = hc.getXMLHelper(); + XMLDocument doc = xh.load(getClass().getResourceAsStream(TEST_XML_DOC_1)); + DataObject rootObject1 = doc.getRootObject(); + + assertNotNull(rootObject1); + List propList = rootObject1.getInstanceProperties(); + SortedSet<String> propNameSet = new TreeSet<String>(); + ListIterator li1 = propList.listIterator(); + while (li1.hasNext()) { + Object obj = li1.next(); + if (obj instanceof Property) { + propNameSet.add(((Property)obj).getName()); + } else { + fail("getInstanceProperties list contained: " + obj.toString()); + } + } + assertTrue("Property name set does not contain 'ID'.", propNameSet.contains("ID")); + assertTrue("Property name set does not contain 'IDREF'.", propNameSet.contains("IDREF")); + assertTrue("Property name set does not contain 'IDREFS'.", propNameSet.contains("IDREFS")); + assertTrue("Property name set does not contain 'NCName'.", propNameSet.contains("NCName")); + assertTrue("Property name set does not contain 'NMTOKEN'.", propNameSet.contains("NMTOKEN")); + assertTrue("Property name set does not contain 'NMTOKENS'.", propNameSet.contains("NMTOKENS")); + assertTrue("Property name set does not contain 'Name'.", propNameSet.contains("Name")); + assertTrue("Property name set does not contain 'byte'.", propNameSet.contains("byte")); + assertTrue("Property name set does not contain 'int'.", propNameSet.contains("int")); + assertTrue("Property name set does not contain 'integer'.", propNameSet.contains("integer")); + assertTrue("Property name set does not contain 'language'.", propNameSet.contains("language")); + assertTrue("Property name set does not contain 'long'.", propNameSet.contains("long")); + assertTrue("Property name set does not contain 'negativeInteger'.", propNameSet.contains("negativeInteger")); + assertTrue("Property name set does not contain 'nonNegativeInteger'.", propNameSet.contains("nonNegativeInteger")); + assertTrue("Property name set does not contain 'nonPositiveInteger'.", propNameSet.contains("nonPositiveInteger")); + assertTrue("Property name set does not contain 'normalizedString'.", propNameSet.contains("normalizedString")); + assertTrue("Property name set does not contain 'positiveInteger'.", propNameSet.contains("positiveInteger")); + assertTrue("Property name set does not contain 'short'.", propNameSet.contains("short")); + assertTrue("Property name set does not contain 'token'.", propNameSet.contains("token")); + assertTrue("Property name set does not contain 'unsignedByte'.", propNameSet.contains("unsignedByte")); + assertTrue("Property name set does not contain 'unsignedInt'.", propNameSet.contains("unsignedInt")); + assertTrue("Property name set does not contain 'unsignedLong'.", propNameSet.contains("unsignedLong")); + assertTrue("Property name set does not contain 'unsignedShort'.", propNameSet.contains("unsignedShort")); + } + + /** + * test #2 of more Schema derived datatypes + */ + @Test + public void testDynamicTypesGroup2() throws IOException { + if (hc == null) { + fail("the HelperContext unexpectedly null"); + } + + TypeHelper th = hc.getTypeHelper(); + Type rootType = th.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_2); + + assertNotNull(rootType); + + DataFactory df = hc.getDataFactory(); + DataObject rootObject = df.create(rootType); + + assertNotNull(rootObject); + + XMLHelper xh = hc.getXMLHelper(); + XMLDocument doc = xh.load(getClass().getResourceAsStream(TEST_XML_DOC_2)); + DataObject rootObject2 = doc.getRootObject(); + + assertNotNull(rootObject2); + List propList = rootObject2.getInstanceProperties(); + SortedSet<String> propNameSet = new TreeSet<String>(); + ListIterator li1 = propList.listIterator(); + while (li1.hasNext()) { + Object obj = li1.next(); + if (obj instanceof Property) { + propNameSet.add(((Property)obj).getName()); + } else { + fail("getInstanceProperties list contained: " + obj.toString()); + } + } + assertTrue("Property name set does not contain 'addresses'.", propNameSet.contains("addresses")); + assertTrue("Property name set does not contain 'cluster'.", propNameSet.contains("cluster")); + assertTrue("Property name set does not contain 'clusters'.", propNameSet.contains("clusters")); + assertTrue("Property name set does not contain 'components'.", propNameSet.contains("components")); + assertTrue("Property name set does not contain 'headerValue'.", propNameSet.contains("headerValue")); + assertTrue("Property name set does not contain 'item'.", propNameSet.contains("item")); + assertTrue("Property name set does not contain 'items'.", propNameSet.contains("items")); + assertTrue("Property name set does not contain 'nCName'.", propNameSet.contains("nCName")); + assertTrue("Property name set does not contain 'otherTag'.", propNameSet.contains("otherTag")); + assertTrue("Property name set does not contain 'overallStatus'.", propNameSet.contains("overallStatus")); + assertTrue("Property name set does not contain 'smallBigDecimal'.", propNameSet.contains("smallBigDecimal")); + assertTrue("Property name set does not contain 'smallBigInteger'.", propNameSet.contains("smallBigInteger")); + assertTrue("Property name set does not contain 'smallInt'.", propNameSet.contains("smallInt")); + assertTrue("Property name set does not contain 'smallOddNumber'.", propNameSet.contains("smallOddNumber")); + assertTrue("Property name set does not contain 'statusOrMonthList'.", propNameSet.contains("statusOrMonthList")); + assertTrue("Property name set does not contain 'wierdNumber'.", propNameSet.contains("wierdNumber")); + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/PropertyTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/PropertyTest.java new file mode 100644 index 0000000000..e70226c10a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/PropertyTest.java @@ -0,0 +1,263 @@ +/* + * 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.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +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.TestData.StandardDynamicFactory; +import test.sdo21.tests.TestData.StandardFactory; +import test.sdo21.tests.TestData.TestDataFactory; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + + +public class PropertyTest extends CTSTestCase { + private DataObject testDO; + TestDataFactory factory; + + public PropertyTest() { + // Tests on the Property interface should be independent of the metadata creation mechanism + // so just pick one Standard Factory + factory = new StandardDynamicFactory(); + } + + @Before + public void setUp () throws Exception { + super.setUp(); + factory.defineMetaData(getScope()); + testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE); + } + + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Verify Property.getDefault() for a newly created DataObject. + * @throws Exception + */ + @Test + public void testGetDefaultNewDO() throws Exception { + verifyGetDefault(factory.createTestData(getScope(), StandardFactory.API_TYPE)); + } + + /** + * Verify Property.getDefault() for a cleared DataObject. + */ + @Test + public void testGetDefaultClearedDO() { + // Set the values for each Property using populateFields, then unset + // them using unsetFields. + try { + ((StandardFactory)factory).populateFields(testDO, getScope()); + } catch (Exception e) { + fail("could not populate DataObject fields"); + } + unsetFields(testDO); + verifyGetDefault(testDO); + } + + /** + * Verify Property.getName() + */ + @Test + public void testPropertyGetName() { + Property property = testDO.getInstanceProperty("containMany"); + assertEquals("Property.getName() returned an unexpected value.", property.getName(), "containMany"); + } + + /** + * Verify Property.getType() + */ + @Test + public void testPropertyGetType() { + Property property = testDO.getInstanceProperty("containMany"); + + assertEquals("Property.getType() returned an unexpected value.", property.getType(), testDO.getType()); + } + + /** + * Verify Property.isMany()==true + */ + @Test + public void testPropertyIsManyTrue() { + Property property = testDO.getInstanceProperty("containMany"); + assertTrue("Property.isMany() returned an unexpected value.", property.isMany()); + } + + /** + * Verify Property.isMany()==false + */ + @Test + public void testPropertyIsManyFalse() { + Property property = testDO.getInstanceProperty("booleanVal"); + assertFalse("Property.isMany() returned an unexpected value.", property.isMany()); + } + + /** + * Verify Property.isContainment()==true + */ + @Test + public void testPropertyIsContainmentTrue() { + Property property = testDO.getInstanceProperty("containMany"); + assertTrue("Property.isContainment() returned an unexpected value.", property.isContainment()); + } + + /** + * Verify Property.isContainment()==false + */ + @Test + public void testPropertyIsContainmentFalse() { + Property property = testDO.getInstanceProperty("booleanVal"); + assertFalse("Property.isContainment() returned true when expecting false.", property.isContainment()); + } + + /** + * Verify Property.isReadOnly()==true + */ + @Test + public void testPropertyIsReadOnlyTrue() { + Property property = testDO.getInstanceProperty("readOnlyVal"); + assertTrue("Property.isReadOnly() returned false when expecting true.", property.isReadOnly()); + } + + /** + * Verify Property.isReadOnly()==false + */ + @Test + public void testPropertyIsReadOnlyFalse() { + Property property = testDO.getInstanceProperty("booleanVal"); + assertFalse("Property.isReadOnly() returned true when expecting false.", property.isReadOnly()); + } + + /** + * Verify Property.getContainingType + */ + @Test + public void testPropertyGetContainingType() { + Property property = testDO.getInstanceProperty("booleanVal"); + assertEquals("Property.getContainingType() returned an unexpected value.", property.getContainingType(), testDO + .getType()); + } + + /** + * Verify Property.getAliasNames() == empty List + */ + @Test + public void testPropertyGetAliasNamesEmpty() { + Property property = testDO.getInstanceProperty("booleanVal"); + assertEquals("Property.getAliasNames() returned a List of unexpected size.", 0, property.getAliasNames().size()); + } + + /** + * Verify Property.getAliasNames() == populated List + */ + @Ignore("Awaiting implementation of SDOUtil.addAliasName") + @Test + public void testPropertyGetAliasNames() { + List aliasNames = testDO.getInstanceProperty("decimalVal2").getAliasNames(); + assertEquals("Property.getAliasNames() returned a List of unexpected size.", 1, aliasNames.size()); + + String alias = (String)aliasNames.get(0); + assertEquals("Property.getAliasNames() returned a List with unexpected contents.", "Dec2", alias); + } + + /** + * Verify Property.getOpposite() == null + */ + @Test + public void testPropertyGetOppositeNull() { + Property property = testDO.getInstanceProperty("booleanVal"); + assertNull("Property.getOpposite() did not return null as expected.", property.getOpposite()); + } + + /** + * Verify Property.getOpposite() != null + */ + @Test + @Ignore + public void testPropertyGetOpposite() { + // TODO write this test + } + + /** + * verifyGetDefault is a private method that loops through each Property in + * the passed DataObject and verifies that the value is equal to the value + * returned by getDefault for each Property. The precondition is that unset + * has been called for any Property for which a value has been set. + * + * @param testedDO + */ + + private void verifyGetDefault(DataObject testedDO) { + List properties = testedDO.getInstanceProperties(); + Property property; + + for (int i = 0; i < properties.size(); i++) { + property = (Property)properties.get(i); + if (!(property.isReadOnly())) { + if (property.isMany()) { + assertNull("Property.getDefault() did not return null for many-valued Property " + property.getName() + + "'.", property.getDefault()); + } else { + assertEquals("Property.getDefault() did not return the correct default value for Property '" + property + .getName() + + "'.", testedDO.get(property), property.getDefault()); + } + } + } + } + + /** + * unsetFields() is a private method that loops through the Properties in + * the passed DataObject and unsets each Property. + * + * @param unsetDO + */ + + private void unsetFields(DataObject unsetDO) { + List properties = unsetDO.getInstanceProperties(); + Property currProp; + + for (int i = 0; i < properties.size(); i++) + { + currProp = (Property) properties.get(i); + if (!(currProp.isReadOnly())) { + unsetDO.unset(i); + } + } + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java new file mode 100644 index 0000000000..2e554e31c3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java @@ -0,0 +1,907 @@ +/*
+ * 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: 536535 $ $Date: 2007-05-09 15:04:49 +0100 (Wed, 09 May 2007) $
+ */
+package test.sdo21.tests.api.Sequence;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.Before;
+
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.api.CTSConsistencyBase;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+
+public abstract class SequenceConsistencyBase extends CTSConsistencyBase {
+ private DataObject sequenceDO;
+
+ /**
+ * getIndex is a private method used by the SequenceConsistencyBase class to accept as
+ * input a Property and return the index of that Property within the
+ * 'Sequenced' Type
+ */
+ private int getIndex(Property property) {
+ List properties = sequenceDO.getType().getProperties();
+ int propertyIndex = -1;
+ int i = 0;
+
+ while (i < properties.size() && propertyIndex < 0) {
+ if (((Property)properties.get(i)).equals(property))
+ propertyIndex = i;
+ i++;
+ }
+
+ return propertyIndex;
+ }
+
+ /**
+ * populateSequence is called before each test. It provides a set of
+ * consistent data for the tests to work with. The expected outcome of
+ * populateSequence is a Sequence as follows: {<Letters, "A">, <Letters,
+ * "B">, <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
+ * @throws Exception
+ */
+ @Before
+ public void populateSequence() throws Exception {
+ sequenceDO = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);
+
+ if (sequenceDO.getType().isSequenced()) {
+ Sequence sequence = sequenceDO.getSequence();
+
+ // Add elements to the Sequence by updating the DataObject
+
+ List letterList = sequenceDO.getList("Letters");
+ List numberList = sequenceDO.getList("Numbers");
+
+ letterList.add("A");
+ letterList.add("B");
+ numberList.add(Integer.valueOf(5));
+ letterList.add("C");
+ numberList.add(Integer.valueOf(16));
+ }
+ }
+
+ /**
+ * Verify that Sequence.getProperty(index) throws an Exception for an
+ * invalid index.
+ */
+ @Test
+ public void getPropertyInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.getProperty(5);
+ fail("Sequence.getProperty(int) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.getValue() throws an Exception for an invalid index.
+ */
+ @Test
+ public void getValueInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.getValue(5);
+ fail("Sequence.getValue(int) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.remove() throws an Exception for an invalid index.
+ */
+ @Test
+ public void removeInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.remove(-1);
+ fail("Sequence.remove(int) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.setValue() throws an Exception for an invalid index.
+ */
+ @Test
+ public void setValueInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.setValue(5, "attempt");
+ fail("Sequence.setValue(int, Object) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.size() returns the expected value.
+ */
+ @Test
+ public void testSize() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ assertEquals("Sequence.size() returned an unexpected value.", sequence.size(), 5);
+ }
+
+ /**
+ * Verify that Sequence.getProperty() returns the expected values.
+ */
+ @Test
+ public void testGetProperty() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ assertEquals("Sequence.getProperty() returned an unexpected Property.",
+ sequenceDO.getInstanceProperty("Letters"),
+ sequence.getProperty(1));
+ assertEquals("Sequence.getProperty() returned an unexpected Property.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(4));
+ }
+
+ /**
+ * Verify that Sequence.getValue() returns the expected values.
+ */
+ @Test
+ public void testGetValue() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ assertEquals("Sequence.getValue() returned an unexpected value.", "A", sequence.getValue(0));
+ assertEquals("Sequence.getValue() returned an unexpected value.", 5, sequence.getValue(2));
+ }
+
+ /**
+ * Use Sequence.setValue() to modify the Sequence, then verify the outcome
+ */
+ @Test
+ public void testSetValue() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.setValue(1, "F");
+
+ // {<Letters, "A">, <Letters, "F">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>}
+
+ assertEquals("Sequence.setValue() did not have the intended effect.", sequence.getValue(1), "F");
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.setValue() had an unexpected effect on the size of the List in the underlying DataObject.",
+ 3,
+ letters.size());
+ assertEquals("Sequence.setValue() did not have the expected effect on the underlying DataObject.",
+ "F",
+ (String)letters.get(1));
+ }
+
+ /**
+ * Use Sequence.remove() to modify the Sequence, then verify the outcome
+ */
+ @Test
+ public void testRemove() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.remove(1);
+
+ // {<Letters, "A">, <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.remove() did not decrement the size of the Sequence.", 4, sequence.size());
+ assertEquals("Sequence.remove() did not shift the elements as expected.", 5, sequence.getValue(1));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.remove() did not have the expected effect on the size of the List in the underlying DataObject.",
+ 2,
+ letters.size());
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(1));
+ }
+
+ /**
+ * Use Sequence.addText(String) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddText() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ String addString = new String("Structured text at the end.");
+ sequence.addText(addString);
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, "Structured text at the end."}
+
+ assertEquals("Sequence.add(String) did not increment the size of the Sequence.", 6, sequence.size());
+ assertEquals("Sequence.add(String) did not place the correct value at the correct index.",
+ addString,
+ sequence.getValue(5));
+ assertNull("Sequence.add(String) should result in a null Property in the final index.", sequence.getProperty(5));
+ }
+
+ /**
+ * Use Sequence.addText(int, String) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddTextWithIndex() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ String addString = new String("Structured text in the middle.");
+ sequence.addText(2, addString);
+
+ // {<Letters, "A">, <Letters, "B">, "Structured text in the middle.",
+ // <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.addText(int, String) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.addText(int, String) did not place the correct value at the correct index.",
+ addString,
+ sequence.getValue(2));
+ assertNull("Sequence.addText(int, String) should result in a null Property in the specified index.",
+ sequence.getProperty(2));
+ }
+
+ /**
+ * Use Sequence.move() to modify the Sequence, then verify the outcome
+ */
+ @Test
+ public void testMove() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.move(1, 3);
+
+ // {<Letters, "A">, <Letters, "C">, <Letters, "B">, <Numbers, 5>,
+ // <Numbers, 16>}
+
+ assertEquals("Sequence.move() had an unexpected effect on the size of the Sequence.", 5, sequence.size());
+ assertEquals("Sequence.move() did not place the expected value at the expected location.", "C", sequence
+ .getValue(1));
+ assertEquals("Sequence.move() had an unexpected effect on the index following the move-to index.",
+ "B",
+ sequence.getValue(2));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.remove() did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ letters.size());
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "A",
+ (String)letters.get(0));
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(1));
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "B",
+ (String)letters.get(2));
+ }
+
+ /**
+ * Verify that Sequence.move() throws an Exception for an invalid to index.
+ */
+ @Test
+ public void moveInvalidToIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.move(5, 0);
+ fail("Sequence.move(int, int) should throw an Exception when an invalid 'to' index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.move() throws an Exception for an invalid from
+ * index.
+ */
+ @Test
+ public void moveInvalidFromIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.move(0, -1);
+ fail("Sequence.move(int, int) should throw an Exception when an invalid 'from' index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(Property, Object) to modify the Sequence, then verify
+ * the outcome
+ */
+ @Test
+ public void testAddPropertyObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+ Property numberProp = sequenceDO.getInstanceProperty("Numbers");
+
+ sequence.add(numberProp, Integer.valueOf(8));
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Numbers, 8>}
+
+ assertEquals("Sequence.add(Property, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(Property, Object) did not place the expected value at the expected index.",
+ 8,
+ sequence.getValue(5));
+ assertEquals("Sequence.add(Property, Object) did not place the expected Property at the expected index.",
+ numberProp,
+ sequence.getProperty(5));
+
+ List numbers = sequenceDO.getList("Numbers");
+
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ numbers.get(0));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ numbers.get(1));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 8,
+ numbers.get(2));
+ }
+
+ /**
+ * Attempt add(Property, Object) with an invalid Property and verify the
+ * error handling
+ * @throws Exception
+ */
+ @Test
+ public void addPropertyObjectInvalidProperty() throws Exception {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ try {
+ sequence.add(testDO.getInstanceProperty("dateVal"), "A");
+ fail("Sequence.add(Property, Object) should throw an Exception when an invalid Property is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(Property, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addPropertyObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(sequenceDO.getInstanceProperty("Numbers"), "A");
+ fail("Sequence.add(Property, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(String, Object) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddStringObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.add("Letters", "K");
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Letters, "K">}
+
+ assertEquals("Sequence.add(String, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(String, Object) did not place the expected value at the expected index.",
+ "K",
+ sequence.getValue(5));
+ assertEquals("Sequence.add(String, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Letters"),
+ sequence.getProperty(5));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 4,
+ letters.size());
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "A",
+ (String)letters.get(0));
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "B",
+ (String)letters.get(1));
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(2));
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "K",
+ (String)letters.get(3));
+ }
+
+ /**
+ * Attempt add(String, Object) with an invalid String and verify the error
+ * handling
+ */
+ @Test
+ public void addStringObjectInvalidString() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add("NoSuchProperty", "A");
+ fail("Sequence.add(String, Object) should throw an Exception when an invalid String is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(String, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addStringObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add("Numbers", "A");
+ fail("Sequence.add(String, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, Object) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddIntObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.add(getIndex(sequenceDO.getInstanceProperty("Numbers")), Integer.valueOf(10));
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Numbers, 10>}
+
+ assertEquals("Sequence.add(Property, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(Property, Object) did not place the expected value at the expected index.",
+ 10,
+ sequence.getValue(5));
+ assertEquals("Sequence.add(Property, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(5));
+
+ List numbers = sequenceDO.getList("Numbers");
+
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ numbers.get(0));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ numbers.get(1));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 10,
+ numbers.get(2));
+ }
+
+ /**
+ * Attempt add(int, Object) with an invalid int and verify the error
+ * handling
+ */
+ @Test
+ public void addIntObjectInvalidInt() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ List properties = sequenceDO.getType().getProperties();
+ int invalidIndex = properties.size();
+
+ try {
+ sequence.add(invalidIndex, Integer.valueOf(16));
+ fail("Sequence.add(int, Object) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addIntObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(getIndex(sequenceDO.getInstanceProperty("Letters")), 7);
+ fail("Sequence.add(int, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, String, Object) to modify the Sequence, then verify
+ * the outcome
+ */
+ @Test
+ public void testAddIntStringObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ int sequenceIndex = 0;
+
+ sequence.add(sequenceIndex, "Numbers", Integer.valueOf(10));
+
+ // {<Numbers, 10>, <Letters, "A">, <Letters, "B">, <Numbers, 5>,
+ // <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.add(int, String, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(int, String, Object) did not place the expected value at the expected index.",
+ 10,
+ sequence.getValue(sequenceIndex));
+ assertEquals("Sequence.add(int, String, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(sequenceIndex));
+
+ List numbers = sequenceDO.getList("Numbers");
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 10,
+ (String)numbers.get(0));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ (String)numbers.get(1));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ (String)numbers.get(2));
+ }
+
+ /**
+ * Attempt add(int, String, Object) with an invalid int and verify the error
+ * handling
+ */
+ @Test
+ public void addIntStringObjectInvalidInt() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(-1, "Letters", "A");
+ fail("Sequence.add(int, String, Object) should throw an Exception when an invalid Sequence index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, String, Object) with an invalid String and verify the
+ * error handling
+ */
+ @Test
+ public void addIntStringObjectInvalidString() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, "Does Not Exist", "A");
+ fail("Sequence.add(int, String, Object) should throw an Exception when an invalid String is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, String, Object) with an invalid Object and verify the
+ * error handling
+ */
+ @Test
+ public void addIntStringObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, "Numbers", "A");
+ fail("Sequence.add(int, String, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, Property, Object) to modify the Sequence, then
+ * verify the outcome
+ */
+ @Test
+ public void testAddIntPropertyObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ int sequenceIndex = 3;
+ sequence.add(sequenceIndex, "Letters", "K");
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "K">,
+ // <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.add(int, Property, Object) did not increment the size of the Sequence.",
+ 6,
+ sequence.size());
+ assertEquals("Sequence.add(int, Property, Object) did not place the expected value at the expected index.",
+ "K",
+ sequence.getValue(sequenceIndex));
+ assertEquals("Sequence.add(int, Property, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Letters"),
+ sequence.getProperty(sequenceIndex));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 4,
+ letters.size());
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "A",
+ (String)letters.get(0));
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "B",
+ (String)letters.get(1));
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "K",
+ (String)letters.get(2));
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(3));
+ }
+
+ /**
+ * Attempt add(int, Property, Object) with an invalid int and verify the
+ * error handling
+ */
+ @Test
+ public void addIntPropertyObjectInvalidInt() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(-1, sequenceDO.getInstanceProperty("Letters"), "A");
+ fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Sequence index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, Property, Object) with an invalid Property and verify
+ * the error handling
+ * @throws Exception
+ */
+ @Test
+ public void addIntPropertyObjectInvalidProperty() throws Exception {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+
+ try {
+ sequence.add(0, testDO.getInstanceProperty("dateVal"), "A");
+ fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Property is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, Property, Object) with an invalid Object and verify the
+ * error handling
+ */
+ @Test
+ public void addIntPropertyObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, sequenceDO.getInstanceProperty("Numbers"), "A");
+ fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, int, Object) to modify the Sequence, then verify
+ * the outcome
+ */
+ @Test
+ public void testAddIntIntObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ int sequenceIndex = 5;
+
+ sequence.add(sequenceIndex, "Numbers", Integer.valueOf(10));
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Numbers, 10>}
+
+ assertEquals("Sequence.add(int, String, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(int, String, Object) did not place the expected value at the expected index.",
+ 10,
+ sequence.getValue(sequenceIndex));
+ assertEquals("Sequence.add(int, String, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(sequenceIndex));
+
+ List numbers = sequenceDO.getList("Numbers");
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ (String)numbers.get(0));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ (String)numbers.get(1));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 10,
+ (String)numbers.get(2));
+ }
+
+ /**
+ * Attempt add(int, int, Object) with an invalid Sequence index and verify
+ * the error handling
+ */
+ @Test
+ public void addIntIntObjectInvalidSequenceIndex() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(6, getIndex(sequenceDO.getInstanceProperty("Letters")), "A");
+ fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Sequence index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, int, Object) with an invalid Property index and verify
+ * the error handling
+ */
+ @Test
+ public void addIntIntObjectInvalidPropertyIndex() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, -1, "A");
+ fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Property index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, int, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addIntIntObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, getIndex(sequenceDO.getInstanceProperty("Letters")), 8);
+ fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyDynamic.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyDynamic.java new file mode 100644 index 0000000000..b97aa8e405 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyDynamic.java @@ -0,0 +1,34 @@ +/*
+ * 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: 537775 $ $Date: 2007-05-14 11:55:54 +0100 (Mon, 14 May 2007) $
+ */
+package test.sdo21.tests.api.Sequence;
+
+import test.sdo21.tests.TestData.StandardDynamicFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+public class SequenceConsistencyDynamic extends SequenceConsistencyBase {
+
+ public TestDataFactory createTestDataFactory() {
+
+ return new StandardDynamicFactory();
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencySuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencySuite.java new file mode 100644 index 0000000000..4c9d43a33a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencySuite.java @@ -0,0 +1,31 @@ +/*
+ * 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: 537775 $ $Date: 2007-05-14 11:55:54 +0100 (Mon, 14 May 2007) $
+ */
+package test.sdo21.tests.api.Sequence;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {SequenceConsistencyDynamic.class,
+ SequenceConsistencyXSD.class})
+public class SequenceConsistencySuite {
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyXSD.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyXSD.java new file mode 100644 index 0000000000..4ebc45ae2f --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyXSD.java @@ -0,0 +1,34 @@ +/*
+ * 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: 537775 $ $Date: 2007-05-14 11:55:54 +0100 (Mon, 14 May 2007) $
+ */
+package test.sdo21.tests.api.Sequence;
+
+import test.sdo21.tests.TestData.StandardXSDFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+
+public class SequenceConsistencyXSD extends SequenceConsistencyBase {
+
+ public TestDataFactory createTestDataFactory() {
+
+ return new StandardXSDFactory();
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java new file mode 100644 index 0000000000..b09d0597f3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java @@ -0,0 +1,100 @@ +/*
+ * 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.api.Sequence;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+
+import test.sdo21.framework.CTSTestCase;
+
+/**
+ * Set of tests for Sequence APIs.
+ */
+public class SequenceTest extends CTSTestCase {
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test to ensure that once an isMany=false property within a sequenced type
+ * retains an existing position in the sequence following an update.
+ *@see <A href="http://www.xcalia.com/support/browse/SDO-242">SDO Spec Jira 242</a>
+ */
+ @Test
+ public void testSeqWhenIsManyFalseAndValueUpdated()
+ {
+
+ DataFactory df = getScope().getDataFactory();
+ TypeHelper th = getScope().getTypeHelper();
+
+ Type stringType = th.getType("commonj.sdo", "String");
+
+ DataObject typeModel = df.create("commonj.sdo", "Type");
+ typeModel.set("name", "name");
+ typeModel.set("uri", "example.org");
+ typeModel.set("sequenced", true);
+
+ DataObject property1 = typeModel.createDataObject("property");
+ property1.set("name", "givenname");
+ property1.set("type", stringType);
+
+ DataObject property2 = typeModel.createDataObject("property");
+ property2.set("name", "familyname");
+ property2.set("type", stringType);
+
+ th.define(typeModel);
+
+ DataObject aName = df.create("example.org", "name");
+
+ aName.set("familyname", "Smith");
+ aName.set("givenname", "John");
+
+ Sequence seq = aName.getSequence();
+ // System.out.println(getScope().getXMLHelper().save(aName, "example./org", "aName"));
+
+ assertEquals(seq.getValue(0), "Smith");
+ assertEquals(seq.getValue(1), "John");
+
+ aName.set("familyname", "Jones");
+ // System.out.println(getScope().getXMLHelper().save(aName, "example./org", "aName"));
+
+ assertEquals(seq.size(), 2);
+
+ assertEquals(seq.getValue(0), "Jones");
+ assertEquals(seq.getValue(1), "John");
+
+ }
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddOpenTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddOpenTest.java new file mode 100644 index 0000000000..73ea84f0d2 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddOpenTest.java @@ -0,0 +1,435 @@ +/* + * 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 junit.framework.TestCase; +import test.sdo21.framework.TestHelper; +import test.sdo21.framework.junit3_8.CTSTestCase; +import test.sdo21.CTSSuite; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.DataFactory; + +/** + * Tests adding objects to a sequence. Note: the tests in this test case must be run sequentially as each test + * depends on state from the previous test. + */ +public class SequenceAddOpenTest extends CTSTestCase { + + protected TestHelper testHelper; + protected DataFactory dataFactory; + protected TypeHelper typeHelper; + protected DataObject testOpenDataObject; + + public SequenceAddOpenTest(String string) { + super(string); + } + + public void setUp() throws Exception { + super.setUp(); + + HelperContext scope = getScope(); + testHelper = getTestHelper(); + dataFactory = scope.getDataFactory(); + typeHelper = scope.getTypeHelper(); + + // define an open type if it is not already defined in the HelperContext provided + // by the implementation being tested + String typeURI = "http://www.example.com/cts/SequenceAddOpenTest"; + String typeName = "OpenDataObject"; + Type openType = typeHelper.getType(typeURI, typeName); + if (openType == null) { + DataObject typeDef = dataFactory.create("commonj.sdo", "Type"); + typeDef.set("uri", typeURI); + typeDef.set("name", typeName); + typeDef.set("open", true); + typeDef.set("sequenced", true); + openType = typeHelper.define(typeDef); + } + + testOpenDataObject = dataFactory.create( openType ); + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * <p/> + * boolean add(String propertyName, Object value) + */ + public void testAddBooleanByName() throws Exception { + + //Get a sequence to add to + Sequence testSequence = testOpenDataObject.getSequence(); + + //Add 3 proprerties + testSequence.add("testBoolean1", Boolean.TRUE); + testSequence.add("testBoolean2", Boolean.FALSE); + testSequence.add("testBoolean3", Boolean.TRUE); + + //Check that the size is reported correctly + //with the size of 3. + assertEquals(3, testSequence.size()); + + //Check the values that were added + assertEquals(Boolean.TRUE, testSequence.getValue(0)); + assertEquals(Boolean.FALSE, testSequence.getValue(1)); + assertEquals(Boolean.TRUE, testSequence.getValue(2)); + + Property prop = testSequence.getProperty(0); + + //OnDemand property should be a string + //Checking only the first property + assertEquals("testBoolean1", prop.getName()); + assertEquals("BooleanObject", prop.getType().getName()); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * <p/> + * boolean add(Property property, Object value) + */ + public void testAddBooleanByProperty() throws Exception { + + DataObject prop = dataFactory.create("commonj.sdo", "Property"); + prop.set("type", typeHelper.getType("commonj.sdo", "Boolean")); + prop.set("name", "testBoolean1"); + + Property openProp = typeHelper.defineOpenContentProperty(null, prop); + Sequence testSequence = testOpenDataObject.getSequence(); + testSequence.add(openProp, new Boolean(false)); + assertEquals(Boolean.FALSE, testSequence.getValue(0)); + + openProp = testSequence.getProperty(0); + + //OnDemand property should be a string + //Checking only the first property + assertEquals("testBoolean1", openProp.getName()); + assertEquals("Boolean", openProp.getType().getName()); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * <p/> + * boolean add(int propertyIndex, Object value) + */ + public void testAddBooleanByPropertyIndex() throws Exception { + + Sequence testSequence = testOpenDataObject.getSequence(); + testSequence.add("testBoolean", new Boolean(true)); + testSequence.add("testBoolean", new Boolean(false)); + + //Actual value to test from sequence + testSequence.add(0, new Boolean(false)); + assertEquals(Boolean.FALSE, testSequence.getValue(2)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * <p/> + * boolean add(int index, String propertyName, Object value) + */ + public void testAddBooleanByIndexAndPropertyName() throws Exception { + + //Get a sequence from the test fixture DataObject + Sequence testSequence = testOpenDataObject.getSequence(); + + testSequence.add(0, "testBoolean", new Boolean(true)); + assertEquals(Boolean.TRUE, testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * <p/> + * boolean add(int index, Property property, Object value) + */ + public void testAddBooleanByIndexAndProperty() throws Exception { + + DataObject prop = dataFactory.create("commonj.sdo", "Property"); + prop.set("type", typeHelper.getType("commonj.sdo", "Boolean")); + prop.set("name", "testBoolean"); + + Property openProp = typeHelper.defineOpenContentProperty(null, prop); + Sequence testSequence = testOpenDataObject.getSequence(); + testSequence.add(0, openProp, new Boolean(false)); + assertEquals(Boolean.FALSE, testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * <p/> + * boolean add(int index, int propertyIndex, Object value) + */ + public void testSequenceAddBooleanByIndexAndPropertyIndex() throws Exception { + + Sequence testSequence = testOpenDataObject.getSequence(); + testSequence.add("testBoolean", new Boolean(true)); + testSequence.add("testBoolean", new Boolean(false)); + + //Actual value to test from sequence + testSequence.add(0, 0, new Boolean(false)); + assertEquals(Boolean.FALSE, testSequence.getValue(2)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * <p/> + * boolean add(String propertyName, Object value) + */ + public void testAddStringByName() throws Exception { + + //Get a sequence to add to + Sequence testSequence = testOpenDataObject.getSequence(); + + testSequence.add("testString", new String("testString")); + assertEquals("testString", testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * <p/> + * boolean add(Property property, Object value) + */ + public void testAddStringByProperty() throws Exception { + + DataObject prop = dataFactory.create("commonj.sdo", "Property"); + prop.set("type", typeHelper.getType("commonj.sdo", "String")); + prop.set("name", "testString"); + + Property openProp = typeHelper.defineOpenContentProperty(null, prop); + Sequence testSequence = testOpenDataObject.getSequence(); + + //Actual value to test + testSequence.add(openProp, new String("testString")); + assertEquals("testString", testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * <p/> + * boolean add(int propertyIndex, Object value) + */ + public void testAddStringByPropertyIndex() throws Exception { + + Sequence testSequence = testOpenDataObject.getSequence(); + + //Add additional duplicate properties + testSequence.add("testString", new String("testString")); + testSequence.add("testString", new String("testString1")); + + //Actual value to check + testSequence.add(0, (Object)new String("testString2")); + assertEquals("testString2", testSequence.getValue(2)); + + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * <p/> + * boolean add(int index, String propertyName, Object value) + */ + public void testAddStringByIndexAndPropertyName() throws Exception { + + //Get a sequence from the test fixture DataObject + Sequence testSequence = testOpenDataObject.getSequence(); + + //Actual value to test + testSequence.add(0, "testString", new String("testString")); + assertEquals("testString", testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * <p/> + * boolean add(int index, Property property, Object value) + */ + public void testAddStringByIndexAndProperty() throws Exception { + + DataObject prop = dataFactory.create("commonj.sdo", "Property"); + prop.set("type", typeHelper.getType("commonj.sdo", "String")); + prop.set("name", "testString"); + + Property openProp = typeHelper.defineOpenContentProperty(null, prop); + Sequence testSequence = testOpenDataObject.getSequence(); + + //Actual value to test + testSequence.add(0, openProp, new String("testString")); + assertEquals("testString", testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * <p/> + * boolean add(int index, int propertyIndex, Object value) + */ + public void testSequenceAddStringByIndexAndPropertyIndex() throws Exception { + + Sequence testSequence = testOpenDataObject.getSequence(); + testSequence.add("testString", new String("testString1")); + testSequence.add("testString", new String("testString2")); + + //Actual value to test from the sequence + testSequence.add(0, 0, new String("testString")); + assertEquals("testString2", testSequence.getValue(2)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Character + * <p/> + * boolean add(Character propertyName, Object value) + */ + public void testAddCharacterByName() throws Exception { + + //Get a sequence to add to + Sequence testSequence = testOpenDataObject.getSequence(); + + testSequence.add("testCharacter", new Character('A')); + assertEquals('A', testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Character + * <p/> + * boolean add(Property property, Object value) + */ + public void testAddCharacterByProperty() throws Exception { + + DataObject prop = dataFactory.create("commonj.sdo", "Property"); + prop.set("type", typeHelper.getType("commonj.sdo", "Character")); + prop.set("name", "testCharacter"); + + Property openProp = typeHelper.defineOpenContentProperty(null, prop); + Sequence testSequence = testOpenDataObject.getSequence(); + + //Actual value to test + testSequence.add(openProp, new Character('A')); + assertEquals('A', testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Character + * <p/> + * boolean add(int propertyIndex, Object value) + */ + public void testAddCharacterByPropertyIndex() throws Exception { + + Sequence testSequence = testOpenDataObject.getSequence(); + + //Add additional duplicate properties + testSequence.add("testCharacter", new Character('A')); + testSequence.add("testCharacter", new Character('B')); + + //Actual value to check + testSequence.add(0, new Character('C')); + assertEquals('C', testSequence.getValue(2)); + + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Character + * <p/> + * boolean add(int index, Character propertyName, Object value) + */ + public void testAddCharacterByIndexAndPropertyName() throws Exception { + + //Get a sequence from the test fixture DataObject + Sequence testSequence = testOpenDataObject.getSequence(); + + //Actual value to test + testSequence.add(0, "testCharacter", new Character('A')); + assertEquals('A', testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Character + * <p/> + * boolean add(int index, Property property, Object value) + */ + public void testAddCharacterByIndexAndProperty() throws Exception { + + DataObject prop = dataFactory.create("commonj.sdo", "Property"); + prop.set("type", typeHelper.getType("commonj.sdo", "Character")); + prop.set("name", "testCharacter"); + + Property openProp = typeHelper.defineOpenContentProperty(null, prop); + Sequence testSequence = testOpenDataObject.getSequence(); + + //Actual value to test + testSequence.add(0, openProp, new Character('A')); + assertEquals('A', testSequence.getValue(0)); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Character + * <p/> + * boolean add(int index, int propertyIndex, Object value) + */ + public void testSequenceAddCharacterByIndexAndPropertyIndex() throws Exception { + + Sequence testSequence = testOpenDataObject.getSequence(); + testSequence.add("testCharacter", new Character('A')); + testSequence.add("testCharacter", new Character('B')); + + //Actual value to test from the sequence + testSequence.add(0, 0, new Character('C')); + assertEquals('C', testSequence.getValue(0)); + assertEquals('A', testSequence.getValue(1)); + assertEquals('B', testSequence.getValue(2)); + + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java new file mode 100644 index 0000000000..4c927b67da --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/SequenceAddTypedTest.java @@ -0,0 +1,599 @@ +/* + * 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 commonj.sdo.DataObject; +import commonj.sdo.Sequence; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import test.sdo21.framework.TestHelper; +import test.sdo21.framework.junit3_8.CTSTestCase; +import test.sdo21.CTSSuite; +import junit.framework.TestCase; + +public class SequenceAddTypedTest extends CTSTestCase { + + protected String URI = "http://www.example.com/cts/SequenceAddTypedTest"; + + protected TestHelper testHelper; + protected DataFactory dataFactory; + protected TypeHelper typeHelper; + protected DataObject testDataObject; + + public SequenceAddTypedTest(String string) throws Exception{ + super(string); + } + + public void setUp() throws Exception { + super.setUp(); + + HelperContext scope = getScope(); + testHelper = getTestHelper(); + dataFactory = scope.getDataFactory(); + typeHelper = scope.getTypeHelper(); + + + defineDynamicTypes(getName()); + } + + /** + * Helper function to define the types + * and also get the test name for use + * in the URI to create a seperate xmldoc + * for each test case. + * + * @param testName Name to append to URI + */ + + protected void defineDynamicTypes(String testName) throws Exception { + + //Setup Open DataObject and enable sequence + + + String testURI = URI + testName; + + if (typeHelper.getType(testURI, testName) == null) { + DataObject testRootType = dataFactory.create( "commonj.sdo", "Type" ); + testRootType.set( "uri" , testURI); + testRootType.set( "name", testName); + testRootType.set( "sequenced", true ); + + DataObject testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testBoolean" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "Boolean" )); + testProperty.set( "many", true); + + testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testString" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "String" )); + testProperty.set( "many", true); + + testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testCharacter" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "Character" )); + testProperty.set( "many", true); + + testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testDate" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "Date" )); + testProperty.set( "many", true); + + testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testDateTime" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "DateTime" )); + testProperty.set( "many", true); + + testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testDay" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "Day" )); + testProperty.set( "many", true); + + testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testDecimal" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "Decimal" )); + testProperty.set( "many", true); + + testProperty = testRootType.createDataObject( "property" ); + testProperty.set( "name", "testDouble" ); + testProperty.set( "type", typeHelper.getType("commonj.sdo", "Double" )); + testProperty.set( "many", true); + + typeHelper.define( testRootType ); + } + testDataObject = dataFactory.create( testURI, testName ); + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * + * boolean add(String propertyName, Object value) + * + */ + public void testAddBooleanByName() throws Exception { + + Boolean testTrue = Boolean.TRUE; + Boolean testFalse = Boolean.FALSE; + + //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + testSequence.add("testBoolean", Boolean.TRUE); + testSequence.add("testBoolean", Boolean.FALSE); + testSequence.add("testBoolean", Boolean.TRUE); + assertEquals( 3, testSequence.size() ); + + //Check the basic value + assertTrue(testTrue.equals(testSequence.getValue(0))); + assertTrue(testFalse.equals(testSequence.getValue(1))); + assertTrue(testTrue.equals(testSequence.getValue(2))); + + //Get the properties and check + //that they are equal to the types property + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * + * boolean add(Property property, Object value) + * + */ + public void testAddBooleanByProperty() throws Exception { + + Boolean testTrue = new Boolean(true); + Boolean testFalse = new Boolean(false); + + //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( testSequence.size(), 0 ); + + Property prop = testDataObject.getInstanceProperty("testBoolean"); + testSequence.add(prop, new Boolean(true)); + testSequence.add(prop, new Boolean(false)); + testSequence.add(prop, new Boolean(true)); + + //Check the basic value + assertEquals( 3, testSequence.size() ); + + assertTrue(testTrue.equals(testSequence.getValue(0))); + assertTrue(testFalse.equals(testSequence.getValue(1))); + assertTrue(testTrue.equals(testSequence.getValue(2))); + + //Get the properties and check + //that they are equal to the types property + + prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * + * boolean add(int propertyIndex, Object value) + * + */ + public void testAddBooleanByPropertyIndex() throws Exception { + + Boolean testTrue = new Boolean(true); + Boolean testFalse = new Boolean(false); + + //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + testSequence.add(0, new Boolean(true)); + testSequence.add(0, new Boolean(false)); + testSequence.add(0, new Boolean(true)); + + //Check the basic value + assertEquals(3, testSequence.size()); + assertTrue(testTrue.equals(testSequence.getValue(0))); + assertTrue(testFalse.equals(testSequence.getValue(1))); + assertTrue(testTrue.equals(testSequence.getValue(2))); + + //Get the properties and check + //that they are equal to the types property + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * + * boolean add(int index, String propertyName, Object value) + * + */ + public void testAddBooleanByIndexAndPropertyName() throws Exception { + + Boolean testTrue = new Boolean(true); + Boolean testFalse = new Boolean(false); + + //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + testSequence.add("testBoolean", new Boolean(true)); + testSequence.add("testBoolean", new Boolean(false)); + testSequence.add("testBoolean", new Boolean(true)); + + testSequence.add(1, "testBoolean", new Boolean(true)); + + //Check the basic values + assertEquals( 4, testSequence.size() ); + assertTrue(testTrue.equals(testSequence.getValue(0))); + assertTrue(testTrue.equals(testSequence.getValue(1))); + assertTrue(testFalse.equals(testSequence.getValue(2))); + assertTrue(testTrue.equals(testSequence.getValue(3))); + + //Get the properties and check + //that everything is set. + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + + } + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * + * boolean add(int index, Property property, Object value) + * + */ + public void testAddBooleanByIndexAndProperty() throws Exception { + + Boolean testTrue = new Boolean(true); + Boolean testFalse = new Boolean(false); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + Property prop = testDataObject.getInstanceProperty("testBoolean"); + testSequence.add(0, prop, new Boolean(true)); + testSequence.add(1, prop, new Boolean(false)); + testSequence.add(2, prop, new Boolean(true)); + + //Check the basic value + assertEquals( 3, testSequence.size() ); + assertTrue(testTrue.equals(testSequence.getValue(0))); + assertTrue(testFalse.equals(testSequence.getValue(1))); + assertTrue(testTrue.equals(testSequence.getValue(2))); + + //Get the properties and check + //that everything is set. + + prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of Boolean + * + * boolean add(int index, int propertyIndex, Object value) + * + */ + public void testAddBooleanByIndexAndPropertyIndex() throws Exception { + + Boolean testTrue = new Boolean(true); + Boolean testFalse = new Boolean(false); + + //DataObject testBoolean = testDataObject.getDataObject( "testBoolean" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + testSequence.add(0, 0, new Boolean(true)); + testSequence.add(1, 0, new Boolean(false)); + testSequence.add(2, 0, new Boolean(true)); + + //Check the basic value + assertEquals( 3, testSequence.size() ); + assertTrue(testTrue.equals(testSequence.getValue(0))); + assertTrue(testFalse.equals(testSequence.getValue(1))); + assertTrue(testTrue.equals(testSequence.getValue(2))); + + //Get the properties and check + //that everything is set. + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testBoolean")); + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * + * String add(String propertyName, Object value) + * + */ + public void testAddStringByName() throws Exception { + + String testString1 = new String("String1"); + String testString2 = new String("String2"); + + //DataObject testString = testDataObject.getDataObject( "testString" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + testSequence.add("testString", new String("String1")); + testSequence.add("testString", new String("String2")); + testSequence.add("testString", new String("String1")); + + //Check the basic value + assertTrue(testString1.equals(testSequence.getValue(0))); + assertTrue(testString2.equals(testSequence.getValue(1))); + assertTrue(testString1.equals(testSequence.getValue(2))); + + //Get the properties and check + //that they are equal to the types property + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * + * String add(Property property, Object value) + * + */ + public void testAddStringByProperty() throws Exception { + + String testString1 = new String("String1"); + String testString2 = new String("String2"); + + //DataObject testString = testDataObject.getDataObject( "testString" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + Property prop = testDataObject.getProperty("testString"); + testSequence.add(prop, new String("String1")); + testSequence.add(prop, new String("String2")); + testSequence.add(prop, new String("String1")); + + //Check the basic value + assertEquals( 3, testSequence.size() ); + + assertTrue(testString1.equals(testSequence.getValue(0))); + assertTrue(testString2.equals(testSequence.getValue(1))); + assertTrue(testString1.equals(testSequence.getValue(2))); + + //Get the properties and check + //that they are equal to the types property + + prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * + * String add(int propertyIndex, Object value) + * + */ + public void testAddStringByPropertyIndex() throws Exception { + + String testString1 = new String("String1"); + String testString2 = new String("String2"); + + //DataObject testString = testDataObject.getDataObject( "testString" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + + //For the property index, it should be the + //order the types were defined in + testSequence.add(1, (Object)new String("String1")); + testSequence.add(1, (Object)new String("String2")); + testSequence.add(1, (Object)new String("String1")); + + //Check the basic value + assertEquals( 3, testSequence.size() ); + assertTrue(testString1.equals(testSequence.getValue(0))); + assertTrue(testString2.equals(testSequence.getValue(1))); + assertTrue(testString1.equals(testSequence.getValue(2))); + + //Get the properties and check + //that they are equal to the types property + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * + * String add(int index, String propertyName, Object value) + * + */ + public void testAddStringByIndexAndPropertyName() throws Exception { + + String testString1 = new String("String1"); + String testString2 = new String("String2"); + + //DataObject testString = testDataObject.getDataObject( "testString" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + testSequence.add("testString", new String("String1")); + testSequence.add("testString", new String("String2")); + testSequence.add("testString", new String("String1")); + + testSequence.add(1, "testString", new String("String1")); + + //Check the basic values + assertEquals( 4, testSequence.size() ); + assertTrue(testString1.equals(testSequence.getValue(0))); + assertTrue(testString1.equals(testSequence.getValue(1))); + assertTrue(testString2.equals(testSequence.getValue(2))); + assertTrue(testString1.equals(testSequence.getValue(3))); + + //Get the properties and check + //that everything is set. + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + + } + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * + * String add(int index, Property property, Object value) + * + */ + public void testAddStringByIndexAndProperty() throws Exception { + + String testString1 = new String("String1"); + String testString2 = new String("String2"); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + Property prop = testDataObject.getProperty("testString"); + testSequence.add(0, prop, new String("String1")); + testSequence.add(1, prop, new String("String2")); + testSequence.add(2, prop, new String("String1")); + + //Check the basic value + assertEquals( 3, testSequence.size() ); + assertTrue(testString1.equals(testSequence.getValue(0))); + assertTrue(testString2.equals(testSequence.getValue(1))); + assertTrue(testString1.equals(testSequence.getValue(2))); + + //Get the properties and check + //that everything is set. + + prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + + } + + /** + * Tests the SDO 2.1 Sequence method for the + * java type of String + * + * String add(int index, int propertyIndex, Object value) + * + */ + public void testAddStringByIndexAndPropertyIndex() throws Exception { + + String testString1 = new String("String1"); + String testString2 = new String("String2"); + + //DataObject testString = testDataObject.getDataObject( "testString" ); + + Sequence testSequence = testDataObject.getSequence(); + assertEquals( 0, testSequence.size() ); + + testSequence.add(0, 1, new String("String1")); + testSequence.add(1, 1, new String("String2")); + testSequence.add(2, 1, new String("String1")); + + //Check the basic value + assertEquals( 3, testSequence.size() ); + assertTrue(testString1.equals(testSequence.getValue(0))); + assertTrue(testString2.equals(testSequence.getValue(1))); + assertTrue(testString1.equals(testSequence.getValue(2))); + + //Get the properties and check + //that everything is set. + + Property prop = testSequence.getProperty(0); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(1); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + prop = testSequence.getProperty(2); + assertEquals( prop , testDataObject.getInstanceProperty("testString")); + + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeHelper/TypeHelperTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeHelper/TypeHelperTest.java new file mode 100644 index 0000000000..31384c7372 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeHelper/TypeHelperTest.java @@ -0,0 +1,436 @@ +/*
+ * 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: 552500 $ $Date: 2007-07-02 15:18:46 +0100 (Mon, 02 Jul 2007) $
+ */
+package test.sdo21.tests.api.TypeHelper;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.TestData.TestDataFactory;
+import test.sdo21.tests.TestData.StandardXSDFactory;
+import test.sdo21.tests.util.CTSUtil;
+import test.sdo21.framework.CTSTestCase;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+public class TypeHelperTest extends CTSTestCase {
+
+ TestDataFactory factory;
+
+ public TypeHelperTest() {
+ // Tests on the Property interface should be independent of the metadata creation mechanism
+ // so just pick one Standard Factory
+ factory = new StandardXSDFactory();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ factory.defineMetaData(getScope());
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test that newly defined type has correct default values for open, sequenced, abstract, dataType
+ */
+ @Test
+ public void testNewTypeDefaults() {
+ HelperContext scope = getScope();
+ TypeHelper typeHelper = scope.getTypeHelper();
+ DataObject defineDO2 = scope.getDataFactory().create("commonj.sdo", "Type");
+ defineDO2.set("uri", StandardFactory.TEST_NAMESPACE);
+ defineDO2.set("name", "testNewTypeOpenIsFalse");
+ Type t = typeHelper.define(defineDO2);
+ assertFalse("Newly created type should have open=false by default", t.isOpen());
+ assertFalse("Newly created type should have abstract=false by default", t.isAbstract());
+ assertFalse("Newly created type should have sequenced=false by default", t.isSequenced());
+ assertFalse("Newly created type should have dataType=false by default", t.isDataType());
+ }
+
+ /**
+ * Verify the performance of TypeHelper.getType(URI, Name)
+ *
+ * @throws Exception
+ */
+ @Test
+ public void getTypeByURI() throws Exception {
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ Type testType = testDO.getType();
+
+ TypeHelper typeHelper = getScope().getTypeHelper();
+ Type returnedType = typeHelper.getType(testType.getURI(), testType.getName());
+
+ // TODO I thinkk we can assert that the types are the same instance here?
+ assertTrue("TypeHelper.getType(URI, Name) did not return the expected Type.", CTSUtil.areEqualTypes(returnedType, testType));
+ }
+
+ /**
+ * Verify the performance of TypeHelper.getType(Class)
+ *
+ * @throws Exception
+ */
+ @Test
+ @Ignore("this test currently never reaches the interesting assertion")
+ public void getTypeByClass() throws Exception {
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ Type testType = testDO.getType();
+
+ TypeHelper typeHelper = getScope().getTypeHelper();
+ Type returnedType = typeHelper.getType(testType.getURI(), testType.getName());
+
+ if (testType.getInstanceClass() != null) {
+ returnedType = typeHelper.getType(testType.getInstanceClass());
+ assertTrue("TypeHelper.getType(Class) did not return the expected Type.",
+ CTSUtil.areEqualTypes(returnedType, testType));
+ }
+ }
+
+ /**
+ * Verify the proper performance of TypeHelper.getType(Class) when a non-SDO
+ * class is passed to TypeHelper.getType(Class)
+ */
+ @Test
+ public void getTypeWithNonSDOClass() {
+ TypeHelper typeHelper = getTestHelper().createHelperContext().getTypeHelper();
+
+ assertNull("TypeHelper.getType(Class) should return null when no Type was defined for the interface Class.",
+ typeHelper.getType(TypeHelperTest.class));
+ }
+
+ /**
+ * Verify the proper performance of TypeHelper.getClass(URI, Name) when the
+ * namespace for URI does not include Name
+ */
+ @Test
+ public void getTypeByURIWithInvalidName() throws Exception {
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ TypeHelper typeHelper = getScope().getTypeHelper();
+
+ assertNull("TypeHelper.getType(URI, Name) should return null when no Type has the indicated Name in the URI namespace.",
+ typeHelper.getType(testDO.getType().getURI(), "UndefinedName"));
+ }
+
+ /**
+ * Verify the proper performance of TypeHelper.getClass(URI, Name) when the
+ * Name exists but not in the namespace of the URI
+ *
+ * @throws Exception
+ */
+ @Test
+ public void getTypeByURIWithInvalidURI() throws Exception {
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ TypeHelper typeHelper = getScope().getTypeHelper();
+
+ assertNull("TypeHelper.getType(URI, Name) should return null when no Type has the indicated Name in the URI namespace.",
+ typeHelper.getType("UndefinedURI", testDO.getType().getName()));
+ }
+
+ /**
+ * Verify the performance of TypeHelper.define(DataObject), use
+ * DataFactory.create(URI, name) to verify
+ *
+ * @throws Exception
+ */
+ @Test
+ public void DefineByDataObjectCreateByURI() throws Exception {
+ HelperContext scope = getScope();
+ DataObject testDO = factory.createTestData(scope, StandardFactory.API_TYPE);
+
+ TypeHelper typeHelper = scope.getTypeHelper();
+ Type stringType = typeHelper.getType("commonj.sdo", "String");
+
+ DataObject defineTypeDO = scope.getDataFactory().create("commonj.sdo", "Type");
+ defineTypeDO.set("uri", StandardFactory.TEST_NAMESPACE);
+ defineTypeDO.set("name", "DefinedType1");
+ DataObject IDProperty = defineTypeDO.createDataObject("property");
+ IDProperty.set("name", "ID");
+ IDProperty.set("type", stringType);
+ DataObject DOProperty = defineTypeDO.createDataObject("property");
+ DOProperty.set("name", "contained");
+ DOProperty.set("type", testDO.getType());
+ typeHelper.define(defineTypeDO);
+
+ // Verify the Type definition by creating a DataObject of the newly
+ // defined Type via DataFactory.create(URI, name).
+
+ DataObject result =
+ scope.getDataFactory().create(StandardFactory.TEST_NAMESPACE,
+ defineTypeDO.getString("name"));
+ assertNotNull("CTSSuite.getTestHelper().getDataFactory() returned null", result);
+ assertEquals("CTSSuite.getTestHelper().getDataFactory()e did not create a Type that could be instantiated.",
+ result.getType().getName(),
+ "DefinedType1");
+ assertNotNull("CTSSuite.getTestHelper().getDataFactory() did not create a Type that could be instantiated, getProperty(ID) was null",
+ result.getInstanceProperty("ID"));
+ }
+
+ /**
+ * Verify the performance of TypeHelper.define(DataObject), use
+ * DataFactory.create(Type) to verify
+ *
+ * @throws Exception
+ */
+ @Test
+ public void DefineByDataObjectCreateByType() throws Exception {
+ HelperContext scope = getScope();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ TypeHelper typeHelper = scope.getTypeHelper();
+ Type stringType = typeHelper.getType("commonj.sdo", "String");
+
+ DataObject defineTypeDO = scope.getDataFactory().create("commonj.sdo", "Type");
+ defineTypeDO.set("uri", StandardFactory.TEST_NAMESPACE);
+ defineTypeDO.set("name", "DefinedType2");
+ DataObject IDProperty = defineTypeDO.createDataObject("property");
+ IDProperty.set("name", "ID");
+ IDProperty.set("type", stringType);
+ DataObject DOProperty = defineTypeDO.createDataObject("property");
+ DOProperty.set("name", "contained");
+ DOProperty.set("type", testDO.getType());
+ Type definedType = typeHelper.define(defineTypeDO);
+
+ // Verify the Type definition by creating a DataObject of the newly
+ // defined Type via DataFactory.create(Type)
+
+ DataObject result = scope.getDataFactory().create(definedType);
+ assertNotNull("TypeHelper.define(DataObject) returned null", result);
+ assertEquals("TypeHelper.define(DataObject) did not create a Type that could be instantiated.", result
+ .getType().getName(), "DefinedType2");
+ assertNotNull("TypeHelper.define(DataObject) did not create a Type that could be instantiated, getProperty(ID) was null",
+ result.getInstanceProperty("ID"));
+ }
+
+ /**
+ * Verify the performance of TypeHelper.define(List)
+ *
+ * @throws Exception
+ */
+ @Test
+ public void DefineByList() throws Exception {
+ HelperContext scope = getScope();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ TypeHelper typeHelper = scope.getTypeHelper();
+ Type stringType = typeHelper.getType("commonj.sdo", "String");
+
+ DataObject define3 = scope.getDataFactory().create("commonj.sdo", "Type");
+ define3.set("uri", StandardFactory.TEST_NAMESPACE);
+ define3.set("name", "DefinedType3");
+ DataObject firstNameProperty = define3.createDataObject("property");
+ firstNameProperty.set("name", "firstName");
+ firstNameProperty.set("type", stringType);
+ DataObject DOProperty = define3.createDataObject("property");
+ DOProperty.set("name", "contained");
+ DOProperty.set("type", testDO.getType());
+
+ DataObject define4 = scope.getDataFactory().create("commonj.sdo", "Type");
+ define4.set("uri", StandardFactory.TEST_NAMESPACE);
+ define4.set("name", "DefinedType4");
+ DataObject lastNameProperty = define4.createDataObject("property");
+ lastNameProperty.set("name", "lastName");
+ lastNameProperty.set("type", stringType);
+ DataObject DOProperty2 = define4.createDataObject("property");
+ DOProperty2.set("name", "contained");
+ DOProperty2.set("type", testDO.getType());
+
+ List DOList = new ArrayList();
+ DOList.add(define3);
+ DOList.add(define4);
+
+ List types = typeHelper.define(DOList);
+
+ assertEquals("TypeHelper.define(List) should define the same number of Types as is present in List.", 2, types
+ .size());
+ Type typeInList = (Type) types.get(0);
+ Type define4Type;
+ if (typeInList.getName().equals("DefinedType3")) {
+ typeInList = (Type) types.get(1);
+ assertEquals("TypeHelper.define(List) returned a List that did not include Types with the expected names.",
+ "DefinedType4",
+ typeInList.getName());
+ define4Type = typeInList;
+ } else {
+ define4Type = typeInList;
+ assertEquals("TypeHelper.define(List) returned a List that did not include Types with the expected names.",
+ "DefinedType4",
+ typeInList.getName());
+ typeInList = (Type) types.get(1);
+ assertEquals("TypeHelper.define(List) returned a List that did not include Types with the expected names.",
+ "DefinedType3",
+ typeInList.getName());
+ }
+
+ // Attempt to create one of the Types using DataFactory.create(URI,
+ // name)
+
+ DataObject result =
+ scope.getDataFactory().create(StandardFactory.TEST_NAMESPACE,
+ define3.getString("name"));
+ assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(URI, name). result is null.",
+ result);
+ assertEquals("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(URI, name). getType() incorrect",
+ result.getType().getName(),
+ "DefinedType3");
+ assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(URI, name). firstName property returned null",
+ result.getInstanceProperty("firstName"));
+
+ // Attempt to create the other type using DataFactory.create(Type)
+
+ result = scope.getDataFactory().create(define4Type);
+
+ assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(Type). result is null.",
+ result);
+ assertEquals("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(Type). getType() incorrect",
+ result.getType().getName(),
+ "DefinedType4");
+ assertNotNull("TypeHelper.define(List) did not create a Type that could be instantiated with DataFactory.create(Type). lastName property returned null",
+ result.getInstanceProperty("lastName"));
+ }
+
+ /**
+ * Verify the error handling of TypeHelper.define(List) when List contains a
+ * member that is not a DataObject
+ *
+ * @throws Exception
+ */
+ @Test
+ public void DefineByListInvalidListMember() throws Exception {
+ HelperContext scope = getScope();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ TypeHelper typeHelper = scope.getTypeHelper();
+ Type intType = typeHelper.getType("commonj.sdo", "Int");
+
+ DataObject define5 = scope.getDataFactory().create("commonj.sdo", "Type");
+ define5.set("uri", StandardFactory.TEST_NAMESPACE);
+ define5.set("name", "DefinedType5");
+ DataObject ID1Property = define5.createDataObject("property");
+ ID1Property.set("name", "ID1");
+ ID1Property.set("type", intType);
+ DataObject DOProperty = define5.createDataObject("property");
+ DOProperty.set("name", "contained");
+ DOProperty.set("type", testDO.getType());
+
+ DataObject define6 = scope.getDataFactory().create("commonj.sdo", "Type");
+ define6.set("uri", StandardFactory.TEST_NAMESPACE);
+ define6.set("name", "DefinedType6");
+ DataObject ID2Property = define6.createDataObject("property");
+ ID2Property.set("name", "ID2");
+ ID2Property.set("type", intType);
+
+ List DOList = new ArrayList();
+ DOList.add(define5);
+ DOList.add("A");
+ DOList.add(define6);
+
+ try {
+ typeHelper.define(DOList);
+ fail("TypeHelper.define(List) should throw an Exception when List " + "contains a member that is not a DataObject.");
+ } catch (Exception e) {
+ // Do nothing
+ }
+ }
+
+ /**
+ * Verify the expected behavior of TypeHelper.define(DataObject) when a Type
+ * of the same name has already been defined differently.
+ *
+ * @throws Exception
+ */
+ @Test
+ @Ignore
+ public void singleRedefinitionDifferent() throws Exception {
+ // TODO complete this test case
+ HelperContext scope = getScope();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+
+ TypeHelper typeHelper = scope.getTypeHelper();
+ Type intType = typeHelper.getType("commonj.sdo", "Int");
+
+ // Determine what should happen when a Type is redefined (same URI
+ // & Name, but different properties).
+ // When this is known, uncomment the following and supply the
+ // appropriate test.
+ // While it's not clear to what should happen (from the spec), what is
+ // happening is that there is no
+ // notification of the duplication, and the originally defined Type is
+ // returned by the define() in the latter instance.
+
+ DataObject defineDO = scope.getDataFactory().create("commonj.sdo", "Type");
+ defineDO.set("uri", StandardFactory.TEST_NAMESPACE);
+ defineDO.set("name", "DefineTypeAgain");
+ DataObject numProperty = defineDO.createDataObject("property");
+ numProperty.set("name", "num");
+ numProperty.set("type", intType);
+
+ typeHelper.define(defineDO);
+
+ DataObject defineDO2 = scope.getDataFactory().create("commonj.sdo", "Type");
+ defineDO2.set("uri", StandardFactory.TEST_NAMESPACE);
+ defineDO2.set("name", "DefineTypeAgain");
+ DataObject DOProperty = defineDO2.createDataObject("property");
+ DOProperty.set("name", "contained");
+ DOProperty.set("type", testDO.getType());
+
+ typeHelper.define(defineDO2);
+ }
+
+ /**
+ * Verify the expected behavior of TypeHelper.define(DataObject) when a Type
+ * of the same name has already been defined, but defined identically.
+ */
+ @Test
+ @Ignore
+ public void singleRedefinitionSame() {
+ // TODO implement test
+ }
+
+ /**
+ * Verify the expected behavior of TypeHelper.define(List) when an element
+ * of the List has already been defined differently.
+ */
+ @Test
+ @Ignore
+ public void listRedefinitionDifferent() {
+ // TODO implement test
+ }
+
+ /**
+ * Verify the expected behavior of TypeHelper.define(List) when an element
+ * of the List has already been defined identically.
+ */
+ @Test
+ @Ignore
+ public void listRedefinitionSame() {
+ //TODO implement test
+ }
+
+
+}
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java new file mode 100644 index 0000000000..5f5c23ad5f --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/TypeTest.java @@ -0,0 +1,354 @@ +/* + * 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; + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/QNameTestCase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/QNameTestCase.java new file mode 100644 index 0000000000..2071abfa04 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/QNameTestCase.java @@ -0,0 +1,137 @@ +/** + * + * 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.api.XMLHelper; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import test.sdo21.framework.CTSTestCase; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.XMLDocument; + + +public class QNameTestCase extends CTSTestCase { + private final String xsdString = + "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " + + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + + "xmlns:simple=\"http://www.example.com/simple\"> " + + "<xsd:element name=\"stockQuote\" type=\"simple:Quote\"/> " + + "<xsd:complexType name=\"Quote\"> " + + "<xsd:sequence> " + + "<xsd:element name=\"symbol\" type=\"xsd:string\"/> " + + "<xsd:element name=\"policy\" type=\"xsd:QName\"/> " + + "</xsd:sequence> " + + "</xsd:complexType> " + + "</xsd:schema>"; + + private final String xmlString = + "<?xml version=\"1.0\" encoding=\"ASCII\"?> " + + "<simple:stockQuote xmlns:simple=\"http://www.example.com/simple\"> " + + "<symbol>fbnt</symbol> " + + "<policy>simple:stockQuote</policy> " + + "</simple:stockQuote>"; + + private final String TEST_NAMESPACE = "http://www.example.com/simple"; + + + /** + * Based on Spec 2.1, section 9.4.1, the return value of DataObject.get() on XSD QName property + * should be http://www.example.com/simple#stockQuote + * + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=95">2.1 spec section 9.4.1</a> + * @throws IOException + */ + @Test + public void testLoad() throws IOException { + XMLDocument doc = getScope().getXMLHelper().load(xmlString); + DataObject root = doc.getRootObject(); + assertEquals("http://www.example.com/simple#stockQuote", root.get("policy")); + } + + /** + * After serialization, the value of XSD QName property in XML should be <prefix>:stockQuote + */ + @Test + public void testSave() throws IOException { + Type quoteType = getScope().getTypeHelper().getType(TEST_NAMESPACE, "Quote"); + DataObject quote = getScope().getDataFactory().create(quoteType); + + quote.setString("symbol", "fbnt"); + quote.set("policy", "http://www.example.com/simple#stockQuote"); + + String str = getScope().getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote"); + int start = str.indexOf("<policy>"); + int end = str.indexOf("</policy>"); + assertTrue(start != -1 && end != -1); + + String policyValue = str.substring(start + "<policy>".length(), end); + + Pattern pattern = Pattern.compile(".*:stockQuote"); // prefix can be anything + + Matcher matcher = pattern.matcher(policyValue); + assertTrue(matcher.find()); + } + + /** + * Test the scenario that the xsd:QName property value contains non-existent namespace + */ + @Test + public void testSave2() throws IOException { + Type quoteType = getScope().getTypeHelper().getType(TEST_NAMESPACE, "Quote"); + DataObject quote = getScope().getDataFactory().create(quoteType); + + quote.setString("symbol", "fbnt"); + quote.set("policy", "http://www.example.com/simple2#stockQuote"); + + String str = getScope().getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote"); + + // Make sure the non-existent namespace was serialized + Pattern pattern = Pattern.compile(".*xmlns:.*=\"http://www.example.com/simple2\""); + Matcher matcher = pattern.matcher(str); + assertTrue(matcher.find()); + } + + @Before + @Override + public void setUp() throws Exception { + super.setUp(); + + + getScope().getXSDHelper().define(xsdString); + } + + @Override + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyBase.java new file mode 100644 index 0000000000..541b0024c5 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyBase.java @@ -0,0 +1,156 @@ +/* + * 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.XMLHelper; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + +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.helper.HelperContext; + + +public abstract class XMLHelperConsistencyBase extends CTSConsistencyBase { + private DataObject testDO; + private HelperContext helperContext; + + + + @Before + public void setUp () throws Exception { + super.setUp(); + testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE); + helperContext = getScope(); + } + + + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + + /** + * Serialize the DataObject then Deserialize the output using Java serialization. Result should be + * equivalent to testDO. + */ + @Test + public void testJavaSerializeDeserialize() { + try { + ((StandardFactory)factory).populateFields(testDO, helperContext); + } catch (Exception e) { + fail("Could not populate DataObject"); + } + DataObject tempDO = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); +// FIXME reintroduce +// try { +// ParamatizedTestUtil.serializeDataObjectJava(testDO, baos, helperContext); +// } catch (Exception e) { +// e.printStackTrace(); +// fail("An Exception occurred while serializing the DataObject: " + e.toString()); +// } +// +// try { +// ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); +// tempDO = ParamatizedTestUtil.deserializeDataObjectJava(bais, helperContext); +// } catch (Exception e) { +// e.printStackTrace(); +// fail("An Exception occurred while deserializing the output of the serialization: " + e.toString()); +// } +// +// assertNotNull("Deserialization returned a null value.", tempDO); +// assertTrue("Serialization and deserialization resulted in a nonequivalent DataObject.", +// ParamatizedTestUtil.equalDataObjects(testDO, tempDO)); + } + + /** + * Serialize the DataObject then Deserialize the output using the XMLHelper. Result should be + * equivalent to testDO. + */ + @Test + public void testXMLHelperSerializeDeserialize() { + try { + ((StandardFactory)factory).populateFields(testDO, helperContext); + } catch (Exception e) { + fail("Could not populate DataObject"); + } + DataObject tempDO = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + CTSUtil.serializeDataObjectXML(testDO, baos, helperContext); + } catch (Exception e) { + e.printStackTrace(); + fail("An Exception occurred while serializing the DataObject: " + e.toString()); + } + + try { + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + tempDO = CTSUtil.deserializeDataObjectXML(bais, helperContext); + } catch (Exception e) { + e.printStackTrace(); + fail("An Exception occurred while deserializing the output of the serialization: " + e.toString()); + } + + assertNotNull("Deserialization returned a null value.", tempDO); + assertTrue("Serialization and deserialization resulted in a nonequivalent DataObject.", + helperContext.getEqualityHelper().equal(testDO, tempDO)); + } + + /** + * Verifies that appropriate exception is thrown when an + * invalid XML document is specified. + */ + @Test + public void testFaultyXML() { + try { + helperContext.getXMLHelper().load(XMLHelperConsistencyBase.class.getResourceAsStream("/faulty.xml")); + fail("Attempting to load a faulty XML file should result in an Exception."); + } catch (Exception e) { + // success + } + } + + /** + * Tests the condition that an XML document is in itself valid, but does not comply with the XSD. + */ + @Test + public void testXMLWrongXSD() { + try { + helperContext.getXMLHelper().load(XMLHelperConsistencyBase.class.getResourceAsStream("/wrongNamespace.xml")); + fail("Attempting to load an XML specifying the wrong namespace file should result in an Exception."); + } catch (Exception e) { + // success + } + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyDynamic.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyDynamic.java new file mode 100644 index 0000000000..17a74d60d3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyDynamic.java @@ -0,0 +1,34 @@ +/* + * 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.XMLHelper; + +import test.sdo21.tests.TestData.StandardDynamicFactory; +import test.sdo21.tests.TestData.TestDataFactory; + +public class XMLHelperConsistencyDynamic extends XMLHelperConsistencyBase { + + public TestDataFactory createTestDataFactory() { + + return new StandardDynamicFactory(); + } + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencySuite.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencySuite.java new file mode 100644 index 0000000000..568e3c8fe8 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencySuite.java @@ -0,0 +1,31 @@ +/* + * 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.XMLHelper; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( {XMLHelperConsistencyDynamic.class, + XMLHelperConsistencyXSD.class}) +public class XMLHelperConsistencySuite { + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyXSD.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyXSD.java new file mode 100644 index 0000000000..94ba2f63f9 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLHelper/XMLHelperConsistencyXSD.java @@ -0,0 +1,34 @@ +/* + * 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.XMLHelper; + +import test.sdo21.tests.TestData.StandardXSDFactory; +import test.sdo21.tests.TestData.TestDataFactory; + +public class XMLHelperConsistencyXSD extends XMLHelperConsistencyBase { + + public TestDataFactory createTestDataFactory() { + + return new StandardXSDFactory(); + } + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLWithoutSchemaTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLWithoutSchemaTest.java new file mode 100644 index 0000000000..851bd5bb06 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/XMLWithoutSchemaTest.java @@ -0,0 +1,151 @@ +/* + * 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.api; + +import junit.framework.TestCase; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +/** + * This tests compliance with section 9.10 of the SDO 2.1 Java specification. + */ +public class XMLWithoutSchemaTest extends TestCase { + + + public XMLWithoutSchemaTest(String string) { + super(string); + } + + //protected String xml = "<XMLWithoutSchemaTest xmlns=\"http://test/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + + //above runs very slowly, because it tries to resolve (until timeout) the xmlns="http://test/" + protected String xml = "<XMLWithoutSchemaTest xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + + "<person id=\"1\"><name>Joe</name><age xsi:type=\"xs:int\">21</age></person>" + + "<person id=\"2\"><name>Sam</name><age xsi:type=\"xs:int\">40</age></person>" + + "</XMLWithoutSchemaTest>"; + + + public void testRootObject() { + // section 9.10 bullet 1 states that "The rootObject of the document will + // be an open, sequenced, mixed data object" + XMLDocument doc = XMLHelper.INSTANCE.load( xml ); + DataObject root = doc.getRootObject(); + assertTrue( root.getType().isOpen() ); + assertTrue( root.getType().isSequenced() ); + } + + public void testAttributeProperties() { + // section 9.10 bullet 3 states that "Attributes for which no meta-information is available + // are interpreted as open content String properties, where the name of the property is the + // local name of the attribute" + XMLDocument doc = XMLHelper.INSTANCE.load( xml ); + DataObject root = doc.getRootObject(); + DataObject person = root.getDataObject( "person.0" ); + + // test that the property is correctly defined + Property idProperty = person.getInstanceProperty( "id" ); + assertTrue( idProperty.isOpenContent() ); + assertTrue( idProperty.getType().isDataType() ); + //FB assertEquals( "String", idProperty.getType().getName() ); + assertEquals( "Object", idProperty.getType().getName() ); //FB Tuscany is doing this. Is this right? + + // test that we can access the instance property + String name = person.getString( idProperty ); + assertEquals( "1", name ); + } + + public void testElementProperties() { + XMLDocument doc = XMLHelper.INSTANCE.load( xml ); + DataObject root = doc.getRootObject(); + + // section 9.10 bullet 4 states that "Elements for which no meta-information is available + // are interpreted as open content properties, where the name of the property is the local + // name of the element. The property will always have containment=true." + Property personProperty = root.getInstanceProperty( "person" ); + assertTrue( personProperty.isContainment() ); + + // section 9.10 bullet 6 states that if there is no xsi:type on a complex element + // then the value's type will be "open, sequenced, mixed type". + assertTrue( personProperty.isOpenContent() ); + //FB assertTrue( personProperty.getType().isSequenced() ); + //FB see inconsistency in testComplexElementWithSimpleContent() + + // section 9.10 bullet 5 states that "If multiple elements with the same property name + // occur within the definition of a single type, the open content property corresponding + // to the element will have isMany=true." + //FB assertTrue( personProperty.isMany() ); + //FB isMany of an open content property depends on it's context + + // test that we can access the instance property + //FB DataObject person = root.getDataObject( personProperty ); + DataObject person = root.getDataObject( "person.0" ); + assertNotNull( person ); + } + + public void testComplexElementWithXsiType() { + XMLDocument doc = XMLHelper.INSTANCE.load( xml ); + DataObject root = doc.getRootObject(); + // section 9.10 bullet 6 states that "If an element contains an xsi:type attribute, it is + // used to determine the type of the value" + DataObject person = root.getDataObject( "person.0" ); + Property ageProperty = person.getInstanceProperty( "age" ); + assertEquals( "commonj.sdo", ageProperty.getType().getURI() ); + //FB assertEquals( "Int", ageProperty.getType().getName() ); + assertEquals( "DataObject", ageProperty.getType().getName() ); //FB Tuscany, is this right? + } + + public void testElementsWithSimpleContent() { + // section 9.10 bullet 6 states that "If no xsi:type attribute is present, then the values's type + // will be {commonj.sdo}String if the contents of the element is simple" + XMLDocument doc = XMLHelper.INSTANCE.load( xml ); + DataObject root = doc.getRootObject(); + DataObject person = root.getDataObject( "person.0" ); + + // test that the property is correctly defined + Property nameProperty = person.getInstanceProperty( "name" ); + assertTrue( nameProperty.isOpenContent() ); + assertTrue( nameProperty.getType().isDataType() ); + assertEquals( "String", nameProperty.getType().getName() ); + + // test that we can access the instance property + String name = person.getString( nameProperty ); + assertEquals( "Joe", name ); + } + + public void testComplexElementWithSimpleContent() { + //String xml = "<root xmlns=\"http://test/\"><name lang=\"en_US\">Adam</name></root>"; + //above runs very slowly, because it tries to resolve (until timeout) the xmlns="http://test/" + String xml = "<root><name lang=\"en_US\">Adam</name></root>"; + XMLDocument doc = XMLHelper.INSTANCE.load( xml ); + DataObject root = doc.getRootObject(); + Property nameProperty = root.getInstanceProperty( "name" ); + + assertEquals( "commonj.sdo", nameProperty.getType().getURI() ); + assertEquals( "DataObject", nameProperty.getType().getName() ); + //FB This check is inconsistent with the check in testElementProperties() + //FB assertTrue( personProperty.getType().isSequenced() ); + //FB because commonj.sdo.DataObject is not a sequenced type.... + + DataObject dobj = root.getDataObject( "name.0" ); + assertEquals( "en_US", dobj.getString( "lang" ) ); + assertEquals( "Adam", dobj.getSequence().getValue(0) ); + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/package.html b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/package.html new file mode 100644 index 0000000000..2f5eaaf7e5 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/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 test cases for API test. +</body> +</html> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java new file mode 100644 index 0000000000..83713db7e5 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/ConversionBase.java @@ -0,0 +1,287 @@ +/** + * + * 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.conversion; + +import junit.framework.TestCase; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.TimeZone; +import java.util.Date; +import java.math.BigDecimal; +import java.math.BigInteger; + +import test.sdo21.framework.TestHelper; +import test.sdo21.framework.junit3_8.CTSTestCase; +import test.sdo21.CTSSuite; +import commonj.sdo.DataObject; +import commonj.sdo.helper.TypeHelper; + +/** + * Base class for conversion tests. + */ +public class ConversionBase extends CTSTestCase { + + /** + * This variable is used to create unique type names to avoid name clashes + * in TypeHelper + */ + protected static int unique = 0; + + /** + * DateFormat is set up in the constructor as per the format in the + * specification. + */ + protected DateFormat f; + + /** + * The TestHelper interface provides access to SDO helper classes. + */ + protected TestHelper testHelper; + + /** + * Message to use when an invalid type conversion does not throw a + * ClassCastException + */ + protected static final String EXPECTED_CLASS_CAST_EXCEPTION = + "ClassCastException should have been thrown (invalid conversion)"; + + + public ConversionBase(String string) { + super(string); + } + + /** + * Sets up a time format and obtain a test helper. + */ + public void setUp() throws Exception { + super.setUp(); + + // set up time format as per page 71 of SDO for Java 2.1.0 FINAL + f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'"); + f.setTimeZone(TimeZone.getTimeZone("GMT")); + + // obtain TestHelper implementation + testHelper = getTestHelper(); + } + + /** + * Helper function for converions tests. Creates a DataObject with name + * 'product' and data hold property + * + * @param strName the name of the data hold property in the created object. + * @param strType the type of the data hold property in the created object. + * @return the created DataObject. + */ + private DataObject createTypeConversionObject(String strName, String strType) { + + // obtain a TypeHelper + TypeHelper typeHelper = getScope().getTypeHelper(); + + // create new DataType + String uri = "http://example.com/TypeConversionTest/" + unique; + String name = "TypeConversionTest" + unique; + unique++; + DataObject productType = getScope().getDataFactory().create("commonj.sdo", "Type"); + productType.set("uri", uri); + productType.set("name", name); + + // define property + DataObject dateValProperty = productType.createDataObject("property"); + dateValProperty.set("name", strName); + dateValProperty.set("type", typeHelper.getType("commonj.sdo", strType)); + dateValProperty.setBoolean("containment", false); + + // define the type + typeHelper.define(productType); + + // create DataObject using the new Type + return getScope().getDataFactory().create(uri, name); + } + + /** + * Helper function for boolean converions tests. Created a DataObject with + * 'boolVal' boolean property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createBooleanObject(boolean initialVal) { + DataObject productType = createTypeConversionObject("boolVal", "Boolean"); + productType.setBoolean("boolVal", initialVal); + return productType; + } + + /** + * Helper function for byte converions tests. Creates a DataObject with + * 'byteVal' byte property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createByteObject(byte initialVal) { + DataObject productType = createTypeConversionObject("byteVal", "Byte"); + productType.setByte("byteVal", initialVal); + return productType; + } + + /** + * Helper function for char converions tests. Creates a DataObject with + * 'charVal' char property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createCharObject(char initialVal) { + DataObject productType = createTypeConversionObject("charVal", "Character"); + productType.setChar("charVal", initialVal); + return productType; + } + + /** + * Helper function for Double converions tests. Creates a DataObject with + * 'doubleVal' double property. + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createDoubleObject(double initialVal) { + DataObject productType = createTypeConversionObject("doubleVal", "Double"); + productType.setDouble("doubleVal", initialVal); + return productType; + } + + /** + * Helper function for Float converions tests. Creates a DataObject with + * 'floatVal' float property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createFloatObject(float initialVal) { + DataObject productType = createTypeConversionObject("floatVal", "Float"); + productType.setFloat("floatVal", initialVal); + return productType; + } + + /** + * Helper function for int converions tests. Creates a DataObject with + * 'intVal' int property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createIntObject(int initialVal) { + DataObject productType = createTypeConversionObject("intVal", "Int"); + productType.setInt("intVal", initialVal); + return productType; + } + + /** + * Helper function for Long converions tests. Creates a DataObject with + * 'longVal' long property. + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createLongObject(long initialVal) { + DataObject productType = createTypeConversionObject("longVal", "Long"); + productType.setLong("longVal", initialVal); + return productType; + } + + /** + * Helper function for short converions tests. Creates a DataObject with + * 'shortVal' short property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createShortObject(short initialVal) { + DataObject productType = createTypeConversionObject("shortVal", "Short"); + productType.setShort("shortVal", initialVal); + return productType; + } + + /** + * Helper function for short converions tests. Creates a DataObject with + * 'stringVal' string property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createStringObject(String initialVal) { + DataObject productType = createTypeConversionObject("stringVal", "String"); + productType.setString("stringVal", initialVal); + return productType; + } + + /** + * Helper function for byte[] converions tests. Created a DataObject with + * 'bytesVal' byte[] property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createBytesObject(byte[] initialVal) { + DataObject productType = createTypeConversionObject("bytesVal", "Bytes"); + productType.setBytes("bytesVal", initialVal); + return productType; + } + + /** + * Helper function for Decimal converions tests. creates a DataObject with + * 'bigDecimalVal' BigDecimal property + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createBigDecimalObject(BigDecimal initialVal) { + DataObject productType = createTypeConversionObject("bigDecimalVal", "Decimal"); + productType.setBigDecimal("bigDecimalVal", initialVal); + return productType; + } + + /** + * Helper function for BigInteger converions tests. Creates a DataObject + * with 'bigIntegerVal' BigInteger property. + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createBigIntegerObject(BigInteger initialVal) { + DataObject productType = createTypeConversionObject("bigIntegerVal", "Integer"); + productType.setBigInteger("bigIntegerVal", initialVal); + return productType; + } + + /** + * Helper function for Date converions tests. Creates a DataObject with + * 'dateVal' date property. + * + * @param initialVal the initial value of the data hold property. + * @return the initialized DataObject. + */ + protected DataObject createDateObject(Date initialVal) { + DataObject productType = createTypeConversionObject("dateVal", "Date"); + productType.setDate("dateVal", initialVal); + return productType; + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/DateConversionTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/DateConversionTest.java new file mode 100644 index 0000000000..b9f74007ad --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/DateConversionTest.java @@ -0,0 +1,397 @@ +/* + * 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.conversion; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.lang.reflect.Method; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import org.junit.BeforeClass; +import org.junit.Ignore; + +import test.sdo21.CTSSuite; +import test.sdo21.framework.CTSTestCase; + +import commonj.sdo.helper.DataHelper; + +// TODO: Could convert to a paramatized test case and simplify this code a lot + +/** + * Set of tests for date and time related conversions. DateConversionTest + * insures that the DataHelper conversions accurately retain the information in + * the specified fields (e.g. month, day or year). It also provides coverage for + * the DataHelper API. + */ +public class DateConversionTest extends CTSTestCase { + private static Calendar test_calendar; + + private static Date test_date; + + private static DataHelper data_helper; + + private static final TestType TO_DATE_TIME = + new TestType("toDateTime", new int[] {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, + Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, + Calendar.MILLISECOND}); + + private static final TestType TO_DURATION = + new TestType("toDuration", new int[] {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, + Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, + Calendar.MILLISECOND}); + + private static final TestType TO_TIME = + new TestType("toTime", new int[] {Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND}); + + private static final TestType TO_DAY = new TestType("toDay", new int[] {Calendar.DAY_OF_MONTH}); + + private static final TestType TO_MONTH = new TestType("toMonth", new int[] {Calendar.MONTH}); + + private static final TestType TO_MONTH_DAY = + new TestType("toMonthDay", new int[] {Calendar.MONTH, Calendar.DAY_OF_MONTH}); + + private static final TestType TO_YEAR = new TestType("toYear", new int[] {Calendar.YEAR}); + + private static final TestType TO_YEAR_MONTH = + new TestType("toYearMonth", new int[] {Calendar.YEAR, Calendar.MONTH}); + + private static final TestType TO_YEAR_MONTH_DAY = + new TestType("toYearMonthDay", new int[] {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH}); + + /** + * Junit 4.1 will execute this once prior to test cases being executed. This + * sets up the Calendar with current date. + */ + @BeforeClass + public static void setupCalender() { + data_helper = getTestHelper().createHelperContext().getDataHelper(); + test_calendar = new GregorianCalendar(); + test_calendar.setTime(new Date(System.currentTimeMillis())); + test_date = test_calendar.getTime(); + } + + private static class TestType { + private static final Class[] DATE_CLASS_ARRAY = {Date.class}; + + private static final Class[] CALENDAR_CLASS_ARRAY = {Calendar.class}; + + Method date_method; + + Method calendar_method; + + int[] compare_fields; + + public TestType(String method_name, int[] compare_fields) { + try { + this.date_method = DataHelper.class.getMethod(method_name, DATE_CLASS_ARRAY); + } catch (NoSuchMethodException e) { + this.date_method = null; + } + + this.compare_fields = compare_fields; + try { + this.calendar_method = DataHelper.class.getMethod(method_name, CALENDAR_CLASS_ARRAY); + } catch (NoSuchMethodException e) { + this.calendar_method = null; + } + + } + + public Method getDateMethod() { + return this.date_method; + } + + public Method getCalendarMethod() { + return this.calendar_method; + } + } + + private static class Test { + String from_type; + + Date from_date; + + Calendar from_calendar; + + Class expected_exception; + + public Test() { + from_date = null; + from_calendar = null; + expected_exception = null; + } + + public void initialize(TestType from_type) { + this.from_type = from_type.getDateMethod().getName(); + + try { + String date_string = (String)from_type.getDateMethod().invoke(data_helper, new Object[] {test_date}); + this.from_date = data_helper.toDate(date_string); + date_string = (String)from_type.getCalendarMethod().invoke(data_helper, new Object[] {test_calendar}); + this.from_calendar = data_helper.toCalendar(date_string); + } catch (Exception e) { + throw new RuntimeException( "Failed to initialize test", e ); + } + + } + + // This method is needed because there is not a toDate(Date) method in + // DataHelper. + + private void initializeToDate() { + this.from_calendar = test_calendar; + this.from_date = test_date; + this.from_type = "toDate"; + } + + private void attemptConversion(TestType to_type) { + executeConversion(to_type.getDateMethod(), new Object[] {this.from_date}, to_type.compare_fields); + executeConversion(to_type.getCalendarMethod(), new Object[] {this.from_calendar}, to_type.compare_fields); + } + + private void executeConversion(Method conversion, Object[] parm, int[] compare_fields) { + String result; + + try { + result = (String)conversion.invoke(data_helper, parm); + assertNotNull( result ); + + compareFields(parm[0], result, compare_fields); + } catch (Exception e) { + e.printStackTrace(); + fail("An unexpected exception was thrown while calling " + conversion.getName() + + " after initializing with " + + this.from_type + + ":" + + e.toString()); + } + + } + + private void compareFields(Object compare_to, String output, int[] compare_fields) { + Calendar result = data_helper.toCalendar(output); + assertNotNull( "data_helper.toCalendar(" + output + ") should not return null", result ); + Calendar expected; + + if (compare_to instanceof Calendar) + expected = (GregorianCalendar)test_calendar; + else { + expected = new GregorianCalendar(); + expected.setTime((Date)test_date); + } + + for (int i = 0; i < compare_fields.length; i++) { + int expectedValue = expected.get(compare_fields[i]); + int actualValue = result.get(compare_fields[i]); + if (expectedValue != actualValue) { + throw new IllegalStateException( "Expected: [" + expectedValue + "] != Actual: [" + actualValue + "]" ); + } + } + } + + } + + /** + * testConversionsFromDay verifies each of the conversions from Day using + * the DataHelper + */ + @org.junit.Test + public void testConversionsFromDay() { + Test FromDay = new Test(); + FromDay.initialize(TO_DAY); + FromDay.attemptConversion(TO_DAY); + } + + /** + * testConversionsFromDate verifies each of the conversions from Date using + * the DataHelper + */ + @org.junit.Test + public void testConversionsFromDate() { + Test FromDate = new Test(); + + FromDate.initializeToDate(); + + FromDate.attemptConversion(TO_DATE_TIME); + FromDate.attemptConversion(TO_DURATION); + FromDate.attemptConversion(TO_TIME); + FromDate.attemptConversion(TO_DAY); + FromDate.attemptConversion(TO_MONTH); + FromDate.attemptConversion(TO_MONTH_DAY); + FromDate.attemptConversion(TO_YEAR); + FromDate.attemptConversion(TO_YEAR_MONTH); + FromDate.attemptConversion(TO_YEAR_MONTH_DAY); + } + + /** + * testConversionsFromDateTime verifies each of the conversions from + * DateTime using the DataHelper + */ + @org.junit.Test + public void testConversionsFromDateTime() { + Test FromDateTime = new Test(); + + FromDateTime.initialize(TO_DATE_TIME); + + FromDateTime.attemptConversion(TO_DATE_TIME); + FromDateTime.attemptConversion(TO_DURATION); + FromDateTime.attemptConversion(TO_TIME); + FromDateTime.attemptConversion(TO_DAY); + FromDateTime.attemptConversion(TO_MONTH); + FromDateTime.attemptConversion(TO_MONTH_DAY); + FromDateTime.attemptConversion(TO_YEAR); + FromDateTime.attemptConversion(TO_YEAR_MONTH); + FromDateTime.attemptConversion(TO_YEAR_MONTH_DAY); + } + + /** + * testConversionsFromDuration verifies each of the conversions from + * Duration using the DataHelper + */ + @org.junit.Test + public void testConversionsFromDuration() { + Test FromDuration = new Test(); + + FromDuration.initialize(TO_DURATION); + + FromDuration.attemptConversion(TO_DURATION); + FromDuration.attemptConversion(TO_DATE_TIME); + FromDuration.attemptConversion(TO_TIME); + FromDuration.attemptConversion(TO_DAY); + FromDuration.attemptConversion(TO_MONTH); + FromDuration.attemptConversion(TO_MONTH_DAY); + FromDuration.attemptConversion(TO_YEAR); + FromDuration.attemptConversion(TO_YEAR_MONTH); + FromDuration.attemptConversion(TO_YEAR_MONTH_DAY); + } + + /** + * testConversionsFromMonth verifies each of the conversions from Month + * using the DataHelper + */ + @org.junit.Test + public void testConversionsFromMonth() { + Test FromMonth = new Test(); + + FromMonth.initialize(TO_MONTH); + + FromMonth.attemptConversion(TO_MONTH); + } + + /** + * testConversionsFromMonthDay verifies each of the conversions from + * MonthDay using the DataHelper + */ + @org.junit.Test + public void testConversionsFromMonthDay() { + Test FromMonthDay = new Test(); + + FromMonthDay.initialize(TO_MONTH_DAY); + FromMonthDay.attemptConversion(TO_MONTH_DAY); + FromMonthDay.attemptConversion(TO_MONTH); + FromMonthDay.attemptConversion(TO_DAY); + } + + /** + * testConversionsFromTime verifies each of the conversions from Time using + * the DataHelper + */ + @org.junit.Test + public void testConversionsFromTime() { + Test FromTime = new Test(); + + FromTime.initialize(TO_TIME); + + FromTime.attemptConversion(TO_TIME); + } + + /** + * testConversionsFromYear verifies each of the conversions from Year using + * the DataHelper + */ + @org.junit.Test + public void testConversionsFromYear() { + Test FromYear = new Test(); + + FromYear.initialize(TO_YEAR); + + FromYear.attemptConversion(TO_YEAR); + } + + /** + * testConversionsFromYearMonth verifies each of the conversions from + * YearMonth using the DataHelper + */ + @org.junit.Test + public void testConversionsFromYearMonth() { + Test FromYearMonth = new Test(); + + FromYearMonth.initialize(TO_YEAR_MONTH); + + FromYearMonth.attemptConversion(TO_YEAR_MONTH); + FromYearMonth.attemptConversion(TO_MONTH); + FromYearMonth.attemptConversion(TO_YEAR); + } + + /** + * testConversionsFromYearMonthDay verifies each of the conversions from + * YearMonthDay using the DataHelper + */ + @org.junit.Test + public void testConversionsFromYearMonthDay() { + Test FromYearMonthDay = new Test(); + + FromYearMonthDay.initialize(TO_YEAR_MONTH_DAY); + + FromYearMonthDay.attemptConversion(TO_YEAR_MONTH_DAY); + FromYearMonthDay.attemptConversion(TO_YEAR_MONTH); + FromYearMonthDay.attemptConversion(TO_MONTH_DAY); + FromYearMonthDay.attemptConversion(TO_YEAR); + FromYearMonthDay.attemptConversion(TO_MONTH); + FromYearMonthDay.attemptConversion(TO_DAY); + } + + /** + * testToDateFormats verifies that strings that should be recognized by + * toDate do not result in a null Date value when passed to + * DataHelper.toDate(String). + */ + @org.junit.Test + @Ignore("This individual test is effectively in the UnderReview set. See TUSCANY-1175") + public void testToDateFormats() { + String[] validStrings = + {"2006-03-31T03:30:45.123Z", "-2006-03-31T03:30:45.1Z", "2006-03-31T03:30:45Z", "2006-03-31T03:30:45.123", + "2006-03-31T03:30:45.1", "-2006-03-31T03:30:45", "2006-03-31T03:30:45.123 EDT", + "2006-03-31T03:30:45.1 EDT", "2006-03-31T03:30:45 EDT", "---05 PST", "---04", "--12 GMT", "--12", + "--08-08 EST", "--08-08", "1976-08-08 PDT", "1976-08-08", "88-12 CST", "1988-12", "2005 CDT", "1999", + "P2006Y 08M 10D T 12H 24M 07S", "P2006Y 10D T 12H", "-P2006Y 08M 10D T 07S.2", "P08M 10D T 07H", + "-P 04M 10DT12H 24S.88", "PT12H"}; + + for (int i = 0; i < validStrings.length; i++) { + assertNotNull("DataHelper.toData() should not return null for '" + validStrings[i] + "'.", data_helper + .toDate(validStrings[i])); + } + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java new file mode 100644 index 0000000000..61a3112cc2 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/StringConversionTest.java @@ -0,0 +1,746 @@ +/** + * + * 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.conversion; + +import commonj.sdo.DataObject; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; + +import junit.framework.TestCase; + +public class StringConversionTest extends ConversionBase { + + public StringConversionTest(String string) { + super(string); + } + + /** + * DataObject class test. Testing getting decimal from DataObject with type + * string + */ + public void testStringGetTypeConversionBigDecimal() { + DataObject product = createStringObject("5"); + BigDecimal bdVal = product.getBigDecimal("stringVal"); + assertTrue(5 == bdVal.intValue()); + + DataObject product2 = createStringObject("string"); + try { + product2.getBigDecimal("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type string + */ + public void testStringGetTypeConversionBigInteger() { + DataObject product = createStringObject("5"); + BigInteger biVal = product.getBigInteger("stringVal"); + assertTrue(5 == biVal.intValue()); + + DataObject product2 = createStringObject("string"); + try { + product2.getBigInteger("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * string + */ + public void testStringGetTypeConversionDate() { + Date bdTemp = new Date(); + String dateString = f.format(bdTemp); + + DataObject product = createStringObject(dateString); + Date dateVal = product.getDate("stringVal"); + assertEquals(bdTemp, dateVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getDate("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * string + */ + public void testStringGetTypeConversionBoolean() { + DataObject product = createStringObject("true"); + boolean boolVal = product.getBoolean("stringVal"); + assertEquals(true, boolVal); + + DataObject product1 = createStringObject("false"); + boolVal = product1.getBoolean("stringVal"); + assertEquals(false, boolVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getBoolean("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * string + */ + public void testStringGetTypeConversionByte() { + DataObject product = createStringObject("5"); + byte byteVal = product.getByte("stringVal"); + assertEquals(5, byteVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getByte("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * string + */ + public void testStringGetTypeConversionChar() { + DataObject product = createStringObject("string"); + char charVal = product.getChar("stringVal"); + assertEquals('s', charVal); + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * string + */ + public void testStringGetTypeConversionDouble() { + DataObject product = createStringObject("5"); + double doubleVal = product.getDouble("stringVal"); + assertTrue(5 == doubleVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getDouble("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * string + */ + public void testStringGetTypeConversionFloat() { + DataObject product = createStringObject("5.5"); + float floatVal = product.getFloat("stringVal"); + assertTrue(5.5F == floatVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getFloat("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * string + */ + public void testStringGetTypeConversionInt() { + DataObject product = createStringObject("5"); + int intVal = product.getInt("stringVal"); + assertEquals(5, intVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getInt("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * string + */ + public void testStringGetTypeConversionLong() { + DataObject product = createStringObject("5"); + long longVal = product.getLong("stringVal"); + assertEquals(5, longVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getLong("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * string + */ + public void testStringGetTypeConversionShort() { + DataObject product = createStringObject("5"); + short shortVal = product.getShort("stringVal"); + assertEquals(5, shortVal); + + DataObject product2 = createStringObject("string"); + try { + product2.getShort("stringVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting bytes from DataObject with type + * string + */ + public void testStringGetTypeConversionBytes() { + DataObject product = createStringObject("0A64"); + + byte[] bytesRes = product.getBytes("stringVal"); + assertNotNull(bytesRes); + + assertEquals(2, bytesRes.length); + assertEquals(10, bytesRes[0]); + assertEquals(100, bytesRes[1]); + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * string + */ + public void testStringSetTypeConversionBoolean() { + DataObject product = createStringObject("string"); + product.setBoolean("stringVal", true); + + String strVal = product.getString("stringVal"); + assertEquals("true", strVal); + + DataObject product1 = createStringObject("string"); + product1.setBoolean("stringVal", false); + strVal = product1.getString("stringVal"); + assertEquals("false", strVal); + } + + /** + * DataObject class test. Testing setting byte to DataObject with type + * string + */ + public void testStringSetTypeConversionByte() { + DataObject product = createStringObject("string"); + product.setByte("stringVal", (byte)5); + + String strVal = product.getString("stringVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing setting char to DataObject with type + * string + */ + public void testStringSetTypeConversionChar() { + DataObject product = createStringObject("string"); + product.setChar("stringVal", 'd'); + + String strVal = product.getString("stringVal"); + assertEquals("d", strVal); + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * string + */ + public void testStringSetTypeConversionDouble() { + DataObject product = createStringObject("string"); + product.setDouble("stringVal", 5); + String strVal = product.getString("stringVal"); + assertEquals("5.0", strVal); + } + + /** + * DataObject class test. Testing setting float to DataObject with type + * string + */ + public void testStringSetTypeConversionFloat() { + DataObject product = createStringObject("string"); + product.setFloat("stringVal", 5.5F); + String strVal = product.getString("stringVal"); + assertEquals("5.5", strVal); + } + + /** + * DataObject class test. Testing setting int to DataObject with type string + */ + public void testStringSetTypeConversionInt() { + DataObject product = createStringObject("string"); + product.setInt("stringVal", 5); + String strVal = product.getString("stringVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * string + */ + public void testStringSetTypeConversionLong() { + DataObject product = createStringObject("string"); + product.setLong("stringVal", 5); + + String strVal = product.getString("stringVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing setting short to DataObject with type + * string + */ + public void testStringSetTypeConversionShort() { + DataObject product = createStringObject("string"); + product.setShort("stringVal", (short)5); + String strVal = product.getString("stringVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing setting bytes to DataObject with type + * string + */ + public void testStringSetTypeConversionBytes() { + DataObject product = createStringObject("string"); + + byte[] byteVal = {10, 100}; + product.setBytes("stringVal", byteVal); + + String strVal = product.getString("stringVal"); + assertEquals("0a64", strVal); + } + + /** + * DataObject class test. Testing setting decimal to DataObject with type + * string + */ + public void testStringSetTypeConversionBigDecimal() { + DataObject product = createStringObject("string"); + BigDecimal initialValue = new BigDecimal(5); + product.setBigDecimal("stringVal", initialValue); + + String strVal = product.getString("stringVal"); + assertEquals(initialValue.toString(), strVal); + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * string + */ + public void testStringSetTypeConversionBigInteger() { + DataObject product = createStringObject("string"); + product.setBigInteger("stringVal", BigInteger.valueOf(5)); + + String strVal = product.getString("stringVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing setting date to DataObject with type + * string + */ + public void testStringSetTypeConversionDate() { + Date bdTemp = new Date(); + String dateString = f.format(bdTemp); + + DataObject product = createStringObject("string"); + product.setDate("stringVal", bdTemp); + String strVal = product.getString("stringVal"); + assertEquals(dateString, strVal); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionString() { + DataObject product = createBooleanObject(true); + String strVal = product.getString("boolVal"); + assertEquals("true", strVal); + product.setBoolean("boolVal", false); + strVal = product.getString("boolVal"); + assertEquals("false", strVal); + } + + /** + * DataObject class test. Testing getting String from DataObject with type + * byte + */ + public void testByteGetTypeConversionString() { + DataObject product = createByteObject((byte)5); + + String stringVal = product.getString("byteVal"); + assertNotNull(stringVal); + assertEquals(0, stringVal.compareToIgnoreCase("5")); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * char + */ + public void testCharGetTypeConversionString() { + DataObject product = createCharObject('s'); + + String strRes = product.getString("charVal"); + assertNotNull(strRes); + assertEquals("s", strRes); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * double + */ + public void testDoubleGetTypeConversionString() { + DataObject product = createDoubleObject(5); + String strVal = product.getString("doubleVal"); + assertEquals("5.0", strVal); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * float + */ + public void testFloatGetTypeConversionString() { + DataObject product = createFloatObject(5.5F); + String strval = product.getString("floatVal"); + assertEquals("5.5", strval); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * int + */ + public void testIntGetTypeConversionString() { + DataObject product = createIntObject(5); + String strVal = product.getString("intVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * long + */ + public void testLongGetTypeConversionString() { + DataObject product = createLongObject(5); + String strVal = product.getString("longVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * short + */ + public void testShortGetTypeConversionString() { + DataObject product = createShortObject((short)5); + String strVal = product.getString("shortVal"); + assertEquals("5", strVal); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionString() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + String strRes = product.getString("bytesVal"); + assertEquals(0, strRes.compareToIgnoreCase("0a64")); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionString() { + BigDecimal initialVal = new BigDecimal(4); + DataObject product = createBigDecimalObject(initialVal); + + String strVal = product.getString("bigDecimalVal"); + assertEquals(strVal, initialVal.toString()); + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionString() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + String strVal = product.getString("bigIntegerVal"); + assertTrue(strVal.compareTo("4") == 0); + + } + + /** + * DataObject class test. Testing getting string from DataObject with type + * date + */ + public void testDateGetTypeConversionString() { + Date dateNow = new Date(); + DataObject product = createDateObject(dateNow); + String strVal = product.getString("dateVal"); + + String dateString = f.format(dateNow); + + assertTrue(strVal.compareTo(dateString) == 0); + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionString() { + DataObject product = createBooleanObject(true); + product.setString("boolVal", "false"); + boolean boolVal = product.getBoolean("boolVal"); + assertFalse(boolVal); + product.setString("boolVal", "true"); + boolVal = product.getBoolean("boolVal"); + assertTrue(boolVal); + } + + /** + * DataObject class test. Testing setting String to DataObject with type + * byte + */ + public void testByteSetTypeConversionString() { + DataObject product = createByteObject((byte)5); + + product.setString("byteVal", "6"); + byte byteVal = product.getByte("byteVal"); + assertTrue(byteVal == 6); + + try { + product.setString("byteVal", "string"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * char + */ + public void testCharSetTypeConversionString() { + DataObject product = createCharObject('s'); + + product.setString("charVal", "string"); + char charVal = product.getChar("charVal"); + assertTrue(charVal == 's'); + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * double + */ + public void testDoubleSetTypeConversionString() { + DataObject product = createDoubleObject(5); + product.setString("doubleVal", "6"); + double doubleVal = product.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + + DataObject product1 = createDoubleObject(5); + try { + product1.setString("doubleVal", "string"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting string from DataObject with type + * float + */ + public void testFloatSetTypeConversionString() { + DataObject product = createFloatObject(5.5F); + product.setString("floatVal", "6.0"); + + float floatVal = product.getFloat("floatVal"); + assertTrue(floatVal == 6); + + DataObject product1 = createFloatObject(5); + try { + product1.setString("floatVal", "string"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting string to DataObject with type int + */ + public void testIntSetTypeConversionString() { + DataObject product = createIntObject(5); + product.setString("intVal", "6"); + + int intVal = product.getInt("intVal"); + assertTrue(intVal == 6); + + DataObject product1 = createIntObject(5); + try { + product1.setString("intVal", "string"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * long + */ + public void testLongSetTypeConversionString() { + DataObject product = createLongObject(5); + product.setString("longVal", "6"); + long longVal = product.getLong("longVal"); + assertTrue(longVal == 6); + + DataObject product1 = createLongObject(5); + try { + product1.setString("longVal", "string"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * short + */ + public void testShortSetTypeConversionString() { + DataObject product = createShortObject((short)5); + product.setString("shortVal", "6"); + short shortVal = product.getShort("shortVal"); + assertTrue(shortVal == 6); + + DataObject product1 = createShortObject((short)5); + try { + product1.setString("shortVal", "string"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionString() { + byte[] byteVal = {1, 2}; + DataObject product = createBytesObject(byteVal); + product.setString("bytesVal", "0a64"); + byte[] bytesRes = product.getBytes("bytesVal"); + assertNotNull(bytesRes); + + assertEquals(2, bytesRes.length); + assertEquals(10, bytesRes[0]); + assertEquals(100, bytesRes[1]); + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionString() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + product.setString("bigDecimalVal", "5"); + + BigDecimal bdVal = product.getBigDecimal("bigDecimalVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionString() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + product.setString("bigIntegerVal", "5"); + BigInteger biVal = product.getBigInteger("bigIntegerVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting string to DataObject with type + * date + */ + public void testDateSetTypeConversionString() { + Date dateNow = new Date(); + DataObject product = createDateObject(dateNow); + + String dateString = f.format(dateNow); + product.setString("dateVal", dateString); + + Date dateRes = product.getDate("dateVal"); + assertEquals(dateNow.getTime(), dateRes.getTime()); + } + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java new file mode 100644 index 0000000000..21abeb1aba --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest.java @@ -0,0 +1,3583 @@ +/** + * + * 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.conversion; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; + + +import commonj.sdo.DataObject; + +/** + * This test case primarily tests the type conversion matrix in section 16 of + * the specification. There are tests for valid and invalid type conversions. + * Invalid type conversions are expected to throw a ClassCastException as per + * section 3.1.13 of the specification. Some of the tests perform conversions + * that result in loss of information e.g. getting a double property by calling + * getShort(). Type conversions should follow the rules of the Java language and + * are allowed to lose information (section 3.1.3) + * + * TODO there is overlap between this test and {@link TypeConversionTest2} which + * needs to be resolved + */ + +// TODO: could use expected exception function of test annotation +public class TypeConversionTest extends ConversionBase { + + public TypeConversionTest(String string) { + super(string); + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionByte() { + DataObject product = createBooleanObject(true); + try {// to byte + product.getByte("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionChar() { + DataObject product = createBooleanObject(true); + try {// to char + product.getChar("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionDouble() { + DataObject product = createBooleanObject(true); + try {// to double + product.getDouble("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionFloat() { + DataObject product = createBooleanObject(true); + try {// to float + product.getFloat("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionInt() { + DataObject product = createBooleanObject(true); + try { + product.getInt("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionLong() { + DataObject product = createBooleanObject(true); + try {// to long + product.getLong("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionShort() { + DataObject product = createBooleanObject(true); + try {// to short + product.getShort("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionBytes() { + DataObject product = createBooleanObject(true); + try {// to bytes[] + product.getBytes("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type boolean + */ + public void testBooleanGetTypeConversionBigDecimal() { + DataObject product = createBooleanObject(true); + try {// to BigDecimal + product.getBigDecimal("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type boolean + */ + public void testBooleanGetTypeConversionBigInteger() { + DataObject product = createBooleanObject(true); + try {// to BigInteger + product.getBigInteger("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting Date from DataObject with type + * boolean + */ + public void testBooleanGetTypeConversionDate() { + DataObject product = createBooleanObject(true); + try {// to Date + product.getDate("boolVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * byte + */ + public void testByteGetTypeConversionBoolean() { + DataObject product = createByteObject((byte)5); + try { + product.getBoolean("byteVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * byte + */ + public void testByteGetTypeConversionChar() { + DataObject product = createByteObject((byte)5); + try { + product.getChar("byteVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * byte + */ + public void testByteGetTypeConversionDouble() { + DataObject product = createByteObject((byte)5); + + double doubleVal = product.getDouble("byteVal"); + assertTrue(doubleVal == 5); + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * byte + */ + public void testByteGetTypeConversionFloat() { + DataObject product = createByteObject((byte)5); + + float floatVal = product.getFloat("byteVal"); + assertTrue(floatVal == 5); + } + + /** + * DataObject class test. Testing getting int from DataObject with type byte + */ + public void testByteGetTypeConversionInt() { + DataObject product = createByteObject((byte)5); + + int intVal = product.getInt("byteVal"); + assertTrue(intVal == 5); + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * byte + */ + public void testByteGetTypeConversionLong() { + DataObject product = createByteObject((byte)5); + + long longVal = product.getLong("byteVal"); + assertTrue(longVal == 5); + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * byte + */ + public void testByteGetTypeConversionShort() { + DataObject product = createByteObject((byte)5); + + short shortVal = product.getShort("byteVal"); + assertTrue(shortVal == 5); + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * byte + */ + public void testByteGetTypeConversionBytes() { + DataObject product = createByteObject((byte)5); + try { + product.getBytes("byteVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type byte + */ + public void testByteGetTypeConversionBigDecimal() { + byte value = 5; + DataObject product = createByteObject(value); + assertEquals( new BigDecimal(value), product.getBigDecimal("byteVal") ); + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type byte + */ + public void testByteGetTypeConversionBigInteger() { + byte value = 5; + DataObject product = createByteObject(value); + assertEquals( new BigInteger(String.valueOf(value)), product.getBigInteger("byteVal") ); + } + + /** + * DataObject class test. Testing getting Date from DataObject with type + * byte + */ + public void testByteGetTypeConversionDate() { + DataObject product = createByteObject((byte)5); + try { + product.getDate("byteVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * char + */ + public void testCharGetTypeConversionBoolean() { + DataObject product = createCharObject('s'); + try { + product.getBoolean("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * char + */ + public void testCharGetTypeConversionByte() { + DataObject product = createCharObject('s'); + try { + product.getByte("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * char + */ + public void testCharGetTypeConversionDouble() { + DataObject product = createCharObject('s'); + try { + product.getDouble("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * char + */ + public void testCharGetTypeConversionFloat() { + DataObject product = createCharObject('s'); + try { + product.getFloat("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting int from DataObject with type char + */ + public void testCharGetTypeConversionInt() { + DataObject product = createCharObject('s'); + try { + product.getInt("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * char + */ + public void testCharGetTypeConversionLong() { + DataObject product = createCharObject('s'); + try { + product.getLong("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * char + */ + public void testCharGetTypeConversionShort() { + DataObject product = createCharObject('s'); + try { + product.getShort("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * char + */ + public void testCharGetTypeConversionBytes() { + DataObject product = createCharObject('s'); + try { + product.getBytes("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type char + */ + public void testCharGetTypeConversionBigDecimal() { + DataObject product = createCharObject('s'); + try { + product.getBigDecimal("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type char + */ + public void testCharGetTypeConversionBigInteger() { + DataObject product = createCharObject('s'); + try { + product.getBigInteger("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting Date from DataObject with type + * char + */ + public void testCharGetTypeConversionDate() { + DataObject product = createCharObject('s'); + try { + product.getDate("charVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * double + */ + public void testDoubleGetTypeConversionBoolean() { + DataObject product = createDoubleObject(5); + try { + product.getBoolean("doubleVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * double + */ + public void testDoubleGetTypeConversionByte() { + DataObject product1 = createDoubleObject(5); + byte byteVal = product1.getByte("doubleVal"); + assertEquals(5, byteVal); + + int largeValue = Byte.MAX_VALUE + 1; + DataObject product = createDoubleObject(largeValue); + byte b = product.getByte("doubleVal"); + assertEquals((byte)largeValue, b); + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * double + */ + public void testDoubleGetTypeConversionChar() { + DataObject product = createDoubleObject(5); + try { + product.getChar("doubleVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * double + */ + public void testDoubleGetTypeConversionFloat() { + DataObject product1 = createDoubleObject(5); + float floatVal = product1.getFloat("doubleVal"); + assertTrue(floatVal == 5.0F); + + double largeValue = ((double)Float.MAX_VALUE) + 1.0; + DataObject product = createDoubleObject(largeValue); + float f = product.getFloat("doubleVal"); + assertEquals((float)largeValue, f); + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * double + */ + public void testDoubleGetTypeConversionInt() { + DataObject product1 = createDoubleObject(5); + int intVal = product1.getInt("doubleVal"); + assertEquals(5, intVal); + + double largeValue = ((double)Integer.MAX_VALUE) + 1.0; + DataObject product = createDoubleObject(largeValue); + int value = product.getInt("doubleVal"); + assertEquals((int)largeValue, value); + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * double + */ + public void testDoubleGetTypeConversionLong() { + DataObject product1 = createDoubleObject(5); + long longVal = product1.getLong("doubleVal"); + assertEquals(5, longVal); + + double largeValue = ((double)Long.MAX_VALUE) + 1.0; + DataObject product = createDoubleObject(largeValue); + long l = product.getLong("doubleVal"); + assertEquals((long)largeValue, l); + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * double + */ + public void testDoubleGetTypeConversionShort() { + DataObject product1 = createDoubleObject(5); + short shortVal = product1.getShort("doubleVal"); + assertEquals(5, shortVal); + + int largeValue = Short.MAX_VALUE + 1; + DataObject product = createDoubleObject(largeValue); + short s = product.getShort("doubleVal"); + assertEquals((short)largeValue, s); + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * double + */ + public void testDoubleGetTypeConversionBytes() { + DataObject product = createDoubleObject(5); + try { + product.getBytes("doubleVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting Bigdecimal from DataObject with + * type double + */ + public void testDoubleGetTypeConversionBigDecimal() { + DataObject product = createDoubleObject(5); + + BigDecimal bdVal = product.getBigDecimal("doubleVal"); + assertEquals(5, bdVal.intValue()); + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type double + */ + public void testDoubleGetTypeConversionBigInteger() { + DataObject product = createDoubleObject(5); + + BigInteger biVal = product.getBigInteger("doubleVal"); + assertEquals(5, biVal.intValue()); + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * double + */ + public void testDoubleGetTypeConversionDate() { + DataObject product = createDoubleObject(5); + try { + product.getDate("doubleVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * float + */ + public void testFloatGetTypeConversionBoolean() { + DataObject product = createFloatObject(5); + try { + product.getBoolean("floatVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * float + */ + public void testFloatGetTypeConversionByte() { + DataObject product1 = createFloatObject(5); + byte byteVal = product1.getByte("floatVal"); + assertEquals(5, byteVal); + + float value = 5.5F; + DataObject product = createFloatObject(value); + byte b = product.getByte("floatVal"); + assertEquals((byte)value, b); + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * float + */ + public void testFloatGetTypeConversionChar() { + DataObject product = createFloatObject(5); + try { + product.getChar("floatVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * float + */ + public void testFloatGetTypeConversionDouble() { + DataObject product1 = createFloatObject(5); + double doubleVal = product1.getDouble("floatVal"); + assertTrue(doubleVal == 5); + + float value = 5.5F; + DataObject product = createFloatObject(value); + double d = product.getDouble("floatVal"); + assertEquals((double)value, d); + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * float + */ + public void testFloatGetTypeConversionInt() { + DataObject product1 = createFloatObject(5); + int intVal = product1.getInt("floatVal"); + assertEquals(5, intVal); + + float value = 5.5F; + DataObject product = createFloatObject(value); + int i = product.getInt("floatVal"); + assertEquals((int)value, i); + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * float + */ + public void testFloatGetTypeConversionLong() { + DataObject product1 = createFloatObject(5); + long longVal = product1.getLong("floatVal"); + assertTrue(longVal == 5); + + float f = 5.5F; + DataObject product = createFloatObject(f); + long l = product.getLong("floatVal"); + assertEquals((long)f, l); + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * float + */ + public void testFloatGetTypeConversionShort() { + + DataObject product1 = createFloatObject(5); + short shortVal = product1.getShort("floatVal"); + assertTrue(shortVal == 5); + + float value = 5.5F; + DataObject product = createFloatObject(value); + short s = product.getShort("floatVal"); + assertEquals((short)value, s); + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * float + */ + public void testFloatGetTypeConversionBytes() { + DataObject product = createFloatObject(5); + try { + product.getBytes("floatVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type float + */ + public void testFloatGetTypeConversionBigDecimal() { + DataObject product = createFloatObject(5.5F); + BigDecimal bdval = product.getBigDecimal("floatVal"); + assertTrue(bdval.floatValue() == 5.5F); + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type float + */ + public void testFloatGetTypeConversionBigInteger() { + DataObject product1 = createFloatObject(5); + BigInteger bdval = product1.getBigInteger("floatVal"); + assertTrue(bdval.intValue() == 5); + + float value = 5.5F; + DataObject product = createFloatObject(value); + BigInteger big = product.getBigInteger("floatVal"); + assertEquals(new BigInteger("" + (int)value), big); + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * float + */ + public void testFloatGetTypeConversionDate() { + DataObject product = createFloatObject(5); + try { + product.getDate("floatVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * int + */ + public void testIntGetTypeConversionBoolean() { + DataObject product = createIntObject(5); + try { + product.getBoolean("intVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting byte from DataObject with type int + */ + public void testIntGetTypeConversionByte() { + DataObject product1 = createIntObject(5); + byte byteVal = product1.getByte("intVal"); + assertTrue(byteVal == 5); + + int value = Byte.MAX_VALUE + 1; + DataObject product = createIntObject(value); + byte b = product.getByte("intVal"); + assertEquals((byte)value, b); + } + + /** + * DataObject class test. Testing getting char from DataObject with type int + */ + public void testIntGetTypeConversionChar() { + DataObject product = createIntObject(5); + try { + product.getChar("intVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * int + */ + public void testIntGetTypeConversionDouble() { + DataObject product = createIntObject(5); + double doubleVal = product.getDouble("intVal"); + assertTrue(doubleVal == 5); + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * int + */ + public void testIntGetTypeConversionFloat() { + DataObject product1 = createIntObject(5); + float floatVal = product1.getFloat("intVal"); + assertTrue(floatVal == 5); + } + + /** + * DataObject class test. Testing getting long from DataObject with type int + */ + public void testIntGetTypeConversionLong() { + DataObject product = createIntObject(5); + long longVal = product.getLong("intVal"); + assertTrue(longVal == 5); + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * int + */ + public void testIntGetTypeConversionShort() { + DataObject product1 = createIntObject(5); + short shortVal = product1.getShort("intVal"); + assertTrue(shortVal == 5); + + int value = Short.MAX_VALUE + 1; + DataObject product = createIntObject(value); + short s = product.getShort("intVal"); + assertEquals((short)value, s); + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * int + */ + public void testIntGetTypeConversionBytes() { + DataObject product = createIntObject(5); + try { + product.getBytes("intVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type int + */ + public void testIntGetTypeConversionBigDecimal() { + DataObject product1 = createIntObject(5); + BigDecimal bdVal = product1.getBigDecimal("intVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type int + */ + public void testIntGetTypeConversionBigInteger() { + DataObject product = createIntObject(5); + BigInteger biVal = product.getBigInteger("intVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing getting date from DataObject with type int + */ + public void testIntGetTypeConversionDate() { + DataObject product = createIntObject(5); + try { + product.getDate("intVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * long + */ + public void testLongGetTypeConversionBoolean() { + DataObject product = createLongObject(5); + try { + product.getBoolean("longVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * long + */ + public void testLongGetTypeConversionByte() { + DataObject product1 = createLongObject(5); + byte byteVal = product1.getByte("longVal"); + assertTrue(byteVal == 5); + + int value = Byte.MAX_VALUE + 1; + DataObject product = createLongObject(value); + byte b = product.getByte("longVal"); + assertEquals((byte)value, b); + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * long + */ + public void testLongGetTypeConversionChar() { + DataObject product = createLongObject(5); + try { + product.getChar("longVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * long + */ + public void testLongGetTypeConversionDouble() { + DataObject product = createLongObject(5); + double doubleVal = product.getDouble("longVal"); + assertTrue(doubleVal == 5); + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * long + */ + public void testLongGetTypeConversionFloat() { + DataObject product1 = createLongObject(5); + float floatVal = product1.getFloat("longVal"); + assertTrue(floatVal == 5); + } + + /** + * DataObject class test. Testing getting int from DataObject with type long + */ + public void testLongGetTypeConversionInt() { + DataObject product1 = createLongObject(5); + int intVal = product1.getInt("longVal"); + assertTrue(intVal == 5); + + long value = Long.MAX_VALUE; + DataObject product = createLongObject(value); + int i = product.getInt("longVal"); + assertEquals((int)value, i); + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * long + */ + public void testLongGetTypeConversionShort() { + DataObject product1 = createLongObject(5); + short shortVal = product1.getByte("longVal"); + assertTrue(shortVal == 5); + + int value = Short.MAX_VALUE + 1; + DataObject product = createLongObject(value); + short s = product.getShort("longVal"); + assertEquals((short)value, s); + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * long + */ + public void testLongGetTypeConversionBytes() { + DataObject product = createLongObject(5); + try { + product.getBytes("longVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type long + */ + public void testLongGetTypeConversionBigDecimal() { + DataObject product = createLongObject(5); + BigDecimal bdVal = product.getBigDecimal("longVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type long + */ + public void testLongGetTypeConversionBigInteger() { + DataObject product1 = createLongObject(5); + BigInteger biVal = product1.getBigInteger("longVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * long + */ + public void testLongGetTypeConversionDate() { + Date dateNow = new Date(); + DataObject product1 = createLongObject(dateNow.getTime()); + Date dateRes = product1.getDate("longVal"); + assertTrue(dateRes.getTime() == dateNow.getTime()); + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * short + */ + public void testShortGetTypeConversionBoolean() { + DataObject product = createShortObject((short)5); + try { + product.getBoolean("shortVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * short + */ + public void testShortGetTypeConversionByte() { + DataObject product1 = createShortObject((short)5); + byte byteVal = product1.getByte("shortVal"); + assertTrue(byteVal == 5); + + short value = (Byte.MAX_VALUE + 1); + DataObject product = createShortObject(value); + byte b = product.getByte("shortVal"); + assertEquals((byte)value, b); + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * short + */ + public void testShortGetTypeConversionChar() { + DataObject product = createShortObject((short)5); + try { + product.getChar("shortVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * short + */ + public void testShortGetTypeConversionDouble() { + DataObject product = createShortObject((short)5); + double doubleVal = product.getDouble("shortVal"); + assertTrue(doubleVal == 5); + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * short + */ + public void testShortGetTypeConversionFloat() { + DataObject product = createShortObject((short)5); + float floatVal = product.getFloat("shortVal"); + assertTrue(floatVal == 5); + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * short + */ + public void testShortGetTypeConversionInt() { + DataObject product = createShortObject((short)5); + int intVal = product.getInt("shortVal"); + assertTrue(intVal == 5); + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * short + */ + public void testShortGetTypeConversionLong() { + DataObject product = createShortObject((short)5); + long longVal = product.getLong("shortVal"); + assertTrue(longVal == 5); + } + + /** + * DataObject class test. Testing getting bytes[] from DataObject with type + * short + */ + public void testShortGetTypeConversionBytes() { + DataObject product = createShortObject((short)5); + try { + product.getBytes("shortVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type short + */ + public void testShortGetTypeConversionBigDecimal() { + short value = 5; + DataObject dobj = createShortObject(value); + assertEquals( new BigDecimal(value), dobj.getBigDecimal("shortVal") ); + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type short + */ + public void testShortGetTypeConversionBigInteger() { + short value = 5; + DataObject dobj = createShortObject(value); + assertEquals( new BigInteger(String.valueOf(value)), dobj.getBigInteger("shortVal") ); + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * short + */ + public void testShortGetTypeConversionDate() { + DataObject product = createShortObject((short)5); + try { + product.getDate("shortVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionBoolean() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getBoolean("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionByte() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getByte("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionChar() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getChar("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionDouble() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getDouble("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionFloat() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getFloat("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionInt() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getInt("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionLong() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getLong("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionShort() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getShort("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type byte[] + */ + public void testBytesGetTypeConversionBigDecimal() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getBigDecimal("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type byte[] + */ + public void testBytesGetTypeConversionBigInteger() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + BigInteger biVal = product.getBigInteger("bytesVal"); + byte[] bytesRes = biVal.toByteArray(); + + assertEquals(2, bytesRes.length); + assertEquals(10, bytesRes[0]); + assertEquals(100, bytesRes[1]); + // System.out.println("testBytesGetTypeConversionBigInteger="+); + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * byte[] + */ + public void testBytesGetTypeConversionDate() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.getDate("bytesVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionBoolean() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + try { + product.getBoolean("bigDecimalVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionByte() { + BigDecimal value = new BigDecimal(4); + DataObject product = createBigDecimalObject(value); + assertEquals( value.byteValue(), product.getByte("bigDecimalVal") ); + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionChar() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + try { + product.getChar("bigDecimalVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionDouble() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + double doubleVal = product.getDouble("bigDecimalVal"); + assertTrue(doubleVal == 4); + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionFloat() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + float floatVal = product.getFloat("bigDecimalVal"); + assertTrue(floatVal == 4); + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionInt() { + DataObject product1 = createBigDecimalObject(new BigDecimal(4)); + int intVal = product1.getInt("bigDecimalVal"); + assertTrue(intVal == 4); + + BigDecimal value = new BigDecimal(4.4); + DataObject product = createBigDecimalObject(value); + int i = product.getInt("bigDecimalVal"); + assertEquals(value.intValue(), i); + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionLong() { + DataObject product1 = createBigDecimalObject(new BigDecimal(4)); + long intVal = product1.getLong("bigDecimalVal"); + assertTrue(intVal == 4); + + BigDecimal value = new BigDecimal(4.4); + DataObject product = createBigDecimalObject(value); + long l = product.getLong("bigDecimalVal"); + assertEquals(value.longValue(), l); + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionShort() { + BigDecimal value = new BigDecimal(4); + DataObject product = createBigDecimalObject(value); + assertEquals( value.shortValue(), product.getShort("bigDecimalVal") ); + } + + /** + * DataObject class test. Testing getting byte[] from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionBytes() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + try { + product.getBytes("bigDecimalVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type BigDecimal + */ + public void testBigDecimalGetTypeConversionBigInteger() { + DataObject product1 = createBigDecimalObject(new BigDecimal(4)); + BigInteger biVal = product1.getBigInteger("bigDecimalVal"); + assertTrue(biVal.intValue() == 4); + + BigDecimal value = new BigDecimal(4.4); + DataObject product = createBigDecimalObject(value); + BigInteger big = product.getBigInteger("bigDecimalVal"); + assertEquals(value.toBigInteger(), big); + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * BigDecimal + */ + public void testBigDecimalGetTypeConversionDate() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + try { + product.getDate("bigDecimalVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionBoolean() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + try { + product.getBoolean("bigIntegerVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionByte() { + BigInteger value = new BigInteger("5"); + DataObject product = createBigIntegerObject(value); + assertEquals( value.byteValue(), product.getByte("bigIntegerVal") ); + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionChar() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + try { + product.getChar("bigIntegerVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionDouble() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + double doubleVal = product.getDouble("bigIntegerVal"); + assertTrue(doubleVal == 4); + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionFloat() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + float floatVal = product.getFloat("bigIntegerVal"); + assertTrue(floatVal == 4); + } + + /** + * DataObject class test. Testing getting int from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionInt() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + int intVal = product.getInt("bigIntegerVal"); + assertTrue(intVal == 4); + + BigInteger value = BigInteger.valueOf(Long.MAX_VALUE); + DataObject product1 = createBigIntegerObject(value); + int i = product1.getInt("bigIntegerVal"); + assertEquals(value.intValue(), i); + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionLong() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + long longVal = product.getLong("bigIntegerVal"); + assertTrue(longVal == 4); + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionShort() { + BigInteger value = new BigInteger("5"); + DataObject product = createBigIntegerObject(value); + assertEquals( value.shortValue(), product.getShort("bigIntegerVal") ); + } + + /** + * DataObject class test. Testing getting byte[] from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionBytes() { + byte[] byteVal = {10, 100}; + DataObject product = createBigIntegerObject(new BigInteger(byteVal)); + + byte[] bytesRes = product.getBytes("bigIntegerVal"); + assertNotNull(bytesRes); + + assertEquals(2, bytesRes.length); + assertEquals(10, bytesRes[0]); + assertEquals(100, bytesRes[1]); + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type BigInteger + */ + public void testBigIntegerGetTypeConversionBigDecimal() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + BigDecimal bdVal = product.getBigDecimal("bigIntegerVal"); + assertTrue(bdVal.intValue() == 4); + } + + /** + * DataObject class test. Testing getting date from DataObject with type + * BigInteger + */ + public void testBigIntegerGetTypeConversionDate() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + try { + product.getDate("bigIntegerVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting boolean from DataObject with type + * date + */ + public void testDateGetTypeConversionBoolean() { + DataObject product = createDateObject(new Date()); + try { + product.getBoolean("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting byte from DataObject with type + * date + */ + public void testDateGetTypeConversionByte() { + DataObject product = createDateObject(new Date()); + try { + product.getByte("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting char from DataObject with type + * date + */ + public void testDateGetTypeConversionChar() { + DataObject product = createDateObject(new Date()); + try { + product.getChar("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting double from DataObject with type + * date + */ + public void testDateGetTypeConversionDouble() { + DataObject product = createDateObject(new Date()); + try { + product.getDouble("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * date + */ + public void testDateGetTypeConversionFloat() { + DataObject product = createDateObject(new Date()); + try { + product.getFloat("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting int from DataObject with type date + */ + public void testDateGetTypeConversionInt() { + DataObject product = createDateObject(new Date()); + try { + product.getInt("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting long from DataObject with type + * date + */ + public void testDateGetTypeConversionLong() { + Date dateNow = new Date(); + DataObject product = createDateObject(dateNow); + + long longVal = product.getLong("dateVal"); + assertEquals(dateNow.getTime(), longVal); + + } + + /** + * DataObject class test. Testing getting short from DataObject with type + * date + */ + public void testDateGetTypeConversionShort() { + DataObject product = createDateObject(new Date()); + try { + product.getShort("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting byte[] from DataObject with type + * date + */ + public void testDateGetTypeConversionBytes() { + DataObject product = createDateObject(new Date()); + try { + product.getBytes("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting BigDecimal from DataObject with + * type date + */ + public void testDateGetTypeConversionBigDecimal() { + DataObject product = createDateObject(new Date()); + try { + product.getBigDecimal("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing getting BigInteger from DataObject with + * type date + */ + public void testDateGetTypeConversionBigInteger() { + DataObject product = createDateObject(new Date()); + try { + product.getBigInteger("dateVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting byte to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionByte() { + DataObject product = createBooleanObject(true); + try {// to byte + product.setByte("boolVal", (byte)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting char to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionChar() { + DataObject product = createBooleanObject(true); + try { + product.setChar("boolVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionDouble() { + DataObject product = createBooleanObject(true); + try { + product.setDouble("boolVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting float to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionFloat() { + DataObject product = createBooleanObject(true); + try { + product.setFloat("boolVal", 5.5F); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting int to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionInt() { + DataObject product = createBooleanObject(true); + try { + product.setInt("boolVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting long to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionLong() { + DataObject product = createBooleanObject(true); + try { + product.setLong("boolVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting short to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionShort() { + DataObject product = createBooleanObject(true); + try { + product.setShort("boolVal", (short)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting bytes[] to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionBytes() { + DataObject product = createBooleanObject(true); + byte[] byteVal = {10, 100}; + try { + product.setBytes("boolVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionBigDecimal() { + DataObject product = createBooleanObject(true); + BigDecimal bdVal = new BigDecimal(4); + try { + product.setBigDecimal("boolVal", bdVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionBigInteger() { + DataObject product = createBooleanObject(true); + try { + product.setBigInteger("boolVal", BigInteger.valueOf(4)); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting Date to DataObject with type + * boolean + */ + public void testBooleanSetTypeConversionDate() { + DataObject product = createBooleanObject(true); + try {// to Date + product.setDate("boolVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * byte + */ + public void testByteSetTypeConversionBoolean() { + DataObject product = createByteObject((byte)5); + try { + product.setBoolean("byteVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting char to DataObject with type byte + */ + public void testByteSetTypeConversionChar() { + DataObject product = createByteObject((byte)5); + try { + product.setChar("byteVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * byte + */ + public void testByteSetTypeConversionDouble() { + DataObject product = createByteObject((byte)5); + + double value = 20; + product.setDouble("byteVal", value); + byte byteVal = product.getByte("byteVal"); + assertEquals((byte)value, byteVal); + } + + /** + * DataObject class test. Testing setting float to DataObject with type byte + */ + public void testByteSetTypeConversionFloat() { + DataObject product = createByteObject((byte)5); + + float value = 6; + product.setFloat("byteVal", value); + byte byteVal = product.getByte("byteVal"); + assertEquals((byte)value, byteVal); + } + + /** + * DataObject class test. Testing setting int to DataObject with type byte + */ + public void testByteSetTypeConversionInt() { + DataObject product = createByteObject((byte)5); + + int value = Byte.MAX_VALUE + 1; + product.setInt("byteVal", value); + byte byteVal = product.getByte("byteVal"); + assertEquals((byte)value, byteVal); + } + + /** + * DataObject class test. Testing setting long to DataObject with type byte + */ + public void testByteSetTypeConversionLong() { + DataObject product = createByteObject((byte)5); + + long value = 123456789; + product.setLong("byteVal", value); + byte byteVal = product.getByte("byteVal"); + assertEquals((byte)value, byteVal); + + } + + /** + * DataObject class test. Testing setting short to DataObject with type byte + */ + public void testByteSetTypeConversionShort() { + DataObject product = createByteObject((byte)5); + + short s = (short)6; + product.setShort("byteVal", s); + byte byteVal = product.getByte("byteVal"); + assertEquals((byte)s, byteVal); + } + + + /** + * DataObject class test. Testing setting bytes[] to DataObject with type + * byte + */ + public void testByteSetTypeConversionBytes() { + DataObject product = createByteObject((byte)5); + byte[] byteVal = {10, 100}; + try { + product.setBytes("byteVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * byte + */ + public void testByteSetTypeConversionBigDecimal() { + byte value = 5; + byte newVal = 25; + DataObject product = createByteObject(value); + product.setBigDecimal("byteVal", new BigDecimal(newVal)); + assertEquals( newVal, product.getByte("byteVal") ); + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * byte + */ + public void testByteSetTypeConversionBigInteger() { + byte value = 5; + byte newVal = 25; + DataObject product = createByteObject(value); + product.setBigInteger("byteVal", BigInteger.valueOf(newVal)); + assertEquals( newVal, product.getByte("byteVal") ); + } + + /** + * DataObject class test. Testing setting Date to DataObject with type byte + */ + public void testByteSetTypeConversionDate() { + DataObject product = createByteObject((byte)5); + try { + product.setDate("byteVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * char + */ + public void testCharSetTypeConversionBoolean() { + DataObject product = createCharObject('s'); + try { + product.setBoolean("charVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting byte to DataObject with type char + */ + public void testCharSetTypeConversionByte() { + DataObject product = createCharObject('s'); + try { + product.setByte("charVal", (byte)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * char + */ + public void testCharSetTypeConversionDouble() { + DataObject product = createCharObject('s'); + try { + product.setDouble("charVal", (double)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting float to DataObject with type char + */ + public void testCharSetTypeConversionFloat() { + DataObject product = createCharObject('s'); + try { + product.setFloat("charVal", 5.5F); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting int to DataObject with type char + */ + public void testCharSetTypeConversionInt() { + DataObject product = createCharObject('s'); + try { + product.setInt("charVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting long to DataObject with type char + */ + public void testCharSetTypeConversionLong() { + DataObject product = createCharObject('s'); + try { + product.setLong("charVal", (long)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting short to DataObject with type char + */ + public void testCharSetTypeConversionShort() { + DataObject product = createCharObject('s'); + try { + product.setShort("charVal", (short)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting bytes[] to DataObject with type + * char + */ + public void testCharSetTypeConversionBytes() { + DataObject product = createCharObject('s'); + byte[] byteVal = {10, 100}; + try { + product.setBytes("charVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * char + */ + public void testCharSetTypeConversionBigDecimal() { + DataObject product = createCharObject('s'); + try { + product.setBigDecimal("charVal", new BigDecimal(4)); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * char + */ + public void testCharSetTypeConversionBigInteger() { + DataObject product = createCharObject('s'); + try { + product.setBigInteger("charVal", BigInteger.valueOf(5)); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting Date to DataObject with type char + */ + public void testCharSetTypeConversionDate() { + DataObject product = createCharObject('s'); + try { + product.setDate("charVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * double + */ + public void testDoubleSetTypeConversionBoolean() { + DataObject product = createDoubleObject(5); + try { + product.setBoolean("doubleVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting byte to DataObject with type + * double + */ + public void testDoubleSetTypeConversionByte() { + DataObject product1 = createDoubleObject(5); + product1.setByte("doubleVal", (byte)6); + double doubleVal = product1.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + } + + /** + * DataObject class test. Testing setting char to DataObject with type + * double + */ + public void testDoubleSetTypeConversionChar() { + DataObject product = createDoubleObject(5); + try { + product.setChar("doubleVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting float to DataObject with type + * double + */ + public void testDoubleSetTypeConversionFloat() { + DataObject product1 = createDoubleObject(5); + product1.setFloat("doubleVal", 6); + double doubleVal = product1.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + } + + /** + * DataObject class test. Testing setting int to DataObject with type double + */ + public void testDoubleSetTypeConversionInt() { + DataObject product1 = createDoubleObject(5); + product1.setInt("doubleVal", 6); + double doubleVal = product1.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + } + + /** + * DataObject class test. Testing setting long to DataObject with type + * double + */ + public void testDoubleSetTypeConversionLong() { + DataObject product1 = createDoubleObject(5); + product1.setLong("doubleVal", (long)6); + double doubleVal = product1.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + } + + /** + * DataObject class test. Testing setting short to DataObject with type + * double + */ + public void testDoubleSetTypeConversionShort() { + DataObject product1 = createDoubleObject(5); + product1.setShort("doubleVal", (short)6); + double doubleVal = product1.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + } + + /** + * DataObject class test. Testing setting byte[] to DataObject with type + * double + */ + public void testDoubleSetTypeConversionBytes() { + DataObject product = createDoubleObject(5); + byte[] byteVal = {10, 100}; + try { + product.setBytes("doubleVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting Bigdecimal to DataObject with type + * double + */ + public void testDoubleSetTypeConversionBigDecimal() { + DataObject product = createDoubleObject(5); + + product.setBigDecimal("doubleVal", new BigDecimal(6)); + double doubleVal = product.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * double + */ + public void testDoubleSetTypeConversionBigInteger() { + DataObject product = createDoubleObject(5); + + product.setBigInteger("doubleVal", BigInteger.valueOf(6)); + double doubleVal = product.getDouble("doubleVal"); + assertTrue(doubleVal == 6); + } + + /** + * DataObject class test. Testing setting date to DataObject with type + * double + */ + public void testDoubleSetTypeConversionDate() { + DataObject product = createDoubleObject(5); + try { + product.getDate("doubleVal"); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * float + */ + public void testFloatSetTypeConversionBoolean() { + DataObject product = createFloatObject(5); + try { + product.setBoolean("floatVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting byte to DataObject with type float + */ + public void testFloatSetTypeConversionByte() { + DataObject product1 = createFloatObject(5); + product1.setByte("floatVal", (byte)6); + + float floatVal = product1.getFloat("floatVal"); + assertTrue(floatVal == 6); + } + + /** + * DataObject class test. Testing setting char to DataObject with type float + */ + public void testFloatSetTypeConversionChar() { + DataObject product = createFloatObject(5); + try { + product.setChar("floatVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * float + */ + public void testFloatSetTypeConversionDouble() { + DataObject product1 = createFloatObject(5); + product1.setDouble("floatVal", (double)6); + float floatVal = product1.getFloat("floatVal"); + assertTrue(floatVal == 6); + } + + /** + * DataObject class test. Testing setting int to DataObject with type float + */ + public void testFloatSetTypeConversionInt() { + DataObject product1 = createFloatObject(5); + int value = 6; + product1.setInt("floatVal", value); + float floatVal = product1.getFloat("floatVal"); + assertEquals((float)value, floatVal); + } + + /** + * DataObject class test. Testing setting long to DataObject with type float + */ + public void testFloatSetTypeConversionLong() { + DataObject product1 = createFloatObject(5); + product1.setLong("floatVal", (long)6); + + float floatVal = product1.getFloat("floatVal"); + assertTrue(floatVal == 6); + } + + /** + * DataObject class test. Testing setting short to DataObject with type + * float + */ + public void testFloatSetTypeConversionShort() { + DataObject product1 = createFloatObject(5); + product1.setShort("floatVal", (short)6); + float floatVal = product1.getFloat("floatVal"); + assertTrue(floatVal == 6); + } + + /** + * DataObject class test. Testing setting byte[] to DataObject with type + * float + */ + public void testFloatSetTypeConversionBytes() { + DataObject product = createFloatObject(5); + + byte[] byteVal = {10, 100}; + try { + product.setBytes("floatVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * float + */ + public void testFloatSetTypeConversionBigDecimal() { + DataObject product = createFloatObject(5.5F); + product.setBigDecimal("floatVal", new BigDecimal(6)); + float floatVal = product.getFloat("floatVal"); + assertTrue(floatVal == 6); + } + + /** + * DataObject class test. Testing Setting BigInteger to DataObject with type + * float + */ + public void testFloatSetTypeConversionBigInteger() { + DataObject product1 = createFloatObject(5); + product1.setBigInteger("floatVal", BigInteger.valueOf(6)); + + float floatVal = product1.getFloat("floatVal"); + assertTrue(floatVal == 6); + } + + /** + * DataObject class test. Testing setting date to DataObject with type float + */ + public void testFloatSetTypeConversionDate() { + DataObject product = createFloatObject(5); + try { + product.setDate("floatVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * int + */ + public void testIntSetTypeConversionBoolean() { + DataObject product = createIntObject(5); + try { + product.setBoolean("intVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting byte to DataObject with type int + */ + public void testIntSetTypeConversionByte() { + DataObject product1 = createIntObject(5); + product1.setByte("intVal", (byte)6); + + int intVal = product1.getInt("intVal"); + assertTrue(intVal == 6); + } + + /** + * DataObject class test. Testing setting char to DataObject with type int + */ + public void testIntSetTypeConversionChar() { + DataObject product = createIntObject(5); + try { + product.setChar("intVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting double to DataObject with type int + */ + public void testIntSetTypeConversionDouble() { + DataObject product = createIntObject(5); + double value = (double)6; + product.setDouble("intVal", value); + int intVal = product.getInt("intVal"); + assertEquals((int)value, intVal); + } + + /** + * DataObject class test. Testing setting float to DataObject with type int + */ + public void testIntSetTypeConversionFloat() { + DataObject product1 = createIntObject(5); + float value = 6.0F; + product1.setFloat("intVal", value); + int intVal = product1.getInt("intVal"); + assertEquals((int)value, intVal); + } + + /** + * DataObject class test. Testing setting long to DataObject with type int + */ + public void testIntSetTypeConversionLong() { + DataObject product = createIntObject(5); + long value = (long)6789; + product.setLong("intVal", value); + int intVal = product.getInt("intVal"); + assertEquals((int)value, intVal); + } + + /** + * DataObject class test. Testing setting short to DataObject with type int + */ + public void testIntSetTypeConversionShort() { + DataObject product1 = createIntObject(5); + product1.setShort("intVal", (short)6); + + int intVal = product1.getInt("intVal"); + assertTrue(intVal == 6); + } + + /** + * DataObject class test. Testing setting bytes[] to DataObject with type + * int + */ + public void testIntSetTypeConversionBytes() { + DataObject product = createIntObject(5); + byte[] byteVal = {10, 100}; + try { + product.setBytes("intVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * int + */ + public void testIntSetTypeConversionBigDecimal() { + DataObject product1 = createIntObject(5); + product1.setBigDecimal("intVal", new BigDecimal(6)); + + int intVal = product1.getInt("intVal"); + assertTrue(intVal == 6); + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * int + */ + public void testIntSetTypeConversionBigInteger() { + DataObject product = createIntObject(5); + product.setBigInteger("intVal", BigInteger.valueOf(6)); + + int intVal = product.getInt("intVal"); + assertTrue(intVal == 6); + } + + /** + * DataObject class test. Testing setting date to DataObject with type int + */ + public void testIntSetTypeConversionDate() { + DataObject product = createIntObject(5); + try { + product.setDate("intVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * long + */ + public void testLongSetTypeConversionBoolean() { + DataObject product = createLongObject(5); + try { + product.setBoolean("longVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting byte to DataObject with type long + */ + public void testLongSetTypeConversionByte() { + DataObject product1 = createLongObject(5); + product1.setByte("longVal", (byte)6); + long longVal = product1.getLong("longVal"); + assertTrue(longVal == 6); + } + + /** + * DataObject class test. Testing setting char to DataObject with type long + */ + public void testLongSetTypeConversionChar() { + DataObject product = createLongObject(5); + try { + product.setChar("longVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * long + */ + public void testLongSetTypeConversionDouble() { + DataObject product = createLongObject(5); + product.setDouble("longVal", (double)6); + long longVal = product.getLong("longVal"); + assertTrue(longVal == 6); + } + + /** + * DataObject class test. Testing setting float to DataObject with type long + */ + public void testLongSetTypeConversionFloat() { + DataObject product1 = createLongObject(5); + float value = 6F; + product1.setFloat("longVal", value); + long longVal = product1.getLong("longVal"); + assertEquals((long)value, longVal); + } + + /** + * DataObject class test. Testing setting int to DataObject with type long + */ + public void testLongSetTypeConversionInt() { + DataObject product1 = createLongObject(5); + product1.setInt("longVal", 6); + long longVal = product1.getLong("longVal"); + assertTrue(longVal == 6); + + } + + /** + * DataObject class test. Testing setting short to DataObject with type long + */ + public void testLongSetTypeConversionShort() { + DataObject product1 = createLongObject(5); + product1.setShort("longVal", (short)6); + long longVal = product1.getLong("longVal"); + assertTrue(longVal == 6); + } + + /** + * DataObject class test. Testing setting byte[] to DataObject with type + * long + */ + public void testLongSetTypeConversionBytes() { + DataObject product = createLongObject(5); + + byte[] byteVal = {10, 100}; + try { + product.setBytes("longVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * long + */ + public void testLongSetTypeConversionBigDecimal() { + DataObject product = createLongObject(5); + product.setBigDecimal("longVal", new BigDecimal(6)); + long longVal = product.getLong("longVal"); + assertTrue(longVal == 6); + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * long + */ + public void testLongSetTypeConversionBigInteger() { + DataObject product1 = createLongObject(5); + product1.setBigInteger("longVal", BigInteger.valueOf(6)); + long longVal = product1.getLong("longVal"); + assertTrue(longVal == 6); + } + + /** + * DataObject class test. Testing setting date to DataObject with type long + */ + public void testLongSetTypeConversionDate() { + Date dateNow = new Date(); + DataObject product1 = createLongObject(5); + product1.setDate("longVal", dateNow); + + long longVal = product1.getLong("longVal"); + assertTrue(longVal == dateNow.getTime()); + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * short + */ + public void testShortSetTypeConversionBoolean() { + DataObject product = createShortObject((short)5); + try { + product.setBoolean("shortVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting byte to DataObject with type short + */ + public void testShortSetTypeConversionByte() { + DataObject product1 = createShortObject((short)5); + product1.setByte("shortVal", (byte)6); + short shortVal = product1.getShort("shortVal"); + assertTrue(shortVal == 6); + } + + /** + * DataObject class test. Testing setting char to DataObject with type short + */ + public void testShortSetTypeConversionChar() { + DataObject product = createShortObject((short)5); + try { + product.setChar("shortVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * short + */ + public void testShortSetTypeConversionDouble() { + DataObject product = createShortObject((short)5); + double value = (double)6; + product.setDouble("shortVal", value); + short shortVal = product.getShort("shortVal"); + assertEquals((short)value, shortVal); + } + + /** + * DataObject class test. Testing getting float from DataObject with type + * short + */ + public void testShortSetTypeConversionFloat() { + DataObject product = createShortObject((short)5); + float value = 6F; + product.setFloat("shortVal", value); + short shortVal = product.getShort("shortVal"); + assertEquals((short)value, shortVal); + } + + /** + * DataObject class test. Testing setting int to DataObject with type short + */ + public void testShortSetTypeConversionInt() { + DataObject product = createShortObject((short)5); + int value = 123456; + product.setInt("shortVal", value); + short shortVal = product.getShort("shortVal"); + assertEquals((short)value, shortVal); + } + + /** + * DataObject class test. Testing setting long to DataObject with type short + */ + public void testShortSetTypeConversionLong() { + DataObject product = createShortObject((short)5); + long value = (long)6; + product.setLong("shortVal", value); + short shortVal = product.getShort("shortVal"); + assertEquals((short)value, shortVal); + } + + + /** + * DataObject class test. Testing setting bytes[] to DataObject with type + * short + */ + public void testShortSetTypeConversionBytes() { + DataObject product = createShortObject((short)5); + byte[] byteVal = {10, 100}; + try { + product.setBytes("shortVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * short + */ + public void testShortSetTypeConversionBigDecimal() { + short value = 5; + BigDecimal newValue = new BigDecimal(6); + DataObject product = createShortObject(value); + product.setBigDecimal("shortVal", newValue); + assertEquals( newValue, product.getBigDecimal("shortVal") ); + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * short + */ + public void testShortSetTypeConversionBigInteger() { + short value = 5; + BigInteger newValue = BigInteger.valueOf(6); + DataObject product = createShortObject(value); + product.setBigInteger("shortVal", newValue); + assertEquals( newValue, product.getBigInteger("shortVal") ); + } + + /** + * DataObject class test. Testing setting date to DataObject with type short + */ + public void testShortSetTypeConversionDate() { + DataObject product = createShortObject((short)5); + try { + product.setDate("shortVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionBoolean() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setBoolean("bytesVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting byte to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionByte() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setByte("bytesVal", (byte)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting char to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionChar() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setChar("bytesVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionDouble() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setDouble("bytesVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting float to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionFloat() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setFloat("bytesVal", 5.5F); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting int to DataObject with type byte[] + */ + public void testBytesSetTypeConversionInt() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setInt("bytesVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting long to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionLong() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setLong("bytesVal", (long)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting short to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionShort() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setShort("bytesVal", (short)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionBigDecimal() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setBigDecimal("bytesVal", new BigDecimal(4)); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionBigInteger() { + byte[] byteArray1 = {1, 2}; + byte[] byteArray2 = {10, 100}; + + DataObject product = createBytesObject(byteArray1); + + BigInteger value = new BigInteger(byteArray2); + product.setBigInteger("bytesVal", value); + + byte[] bytesRes = product.getBytes("bytesVal"); + assertNotNull(bytesRes); + + assertEquals(2, bytesRes.length); + assertEquals(10, bytesRes[0]); + assertEquals(100, bytesRes[1]); + } + + /** + * DataObject class test. Testing setting date to DataObject with type + * byte[] + */ + public void testBytesSetTypeConversionDate() { + byte[] byteVal = {10, 100}; + DataObject product = createBytesObject(byteVal); + try { + product.setDate("bytesVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionBoolean() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + try { + product.setBoolean("bigDecimalVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting byte to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionByte() { + byte byteValue = 12; + BigDecimal value = BigDecimal.valueOf(4); + DataObject product = createBigDecimalObject(value); + product.setByte("bigDecimalVal", byteValue ); + assertEquals( byteValue, product.getByte("bigDecimalVal") ); + } + + /** + * DataObject class test. Testing setting char to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionChar() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + try { + product.setChar("bigDecimalVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionDouble() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + product.setDouble("bigDecimalVal", 5); + BigDecimal bdVal = product.getBigDecimal("bigDecimalVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting float to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionFloat() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + product.setFloat("bigDecimalVal", 5F); + BigDecimal bdVal = product.getBigDecimal("bigDecimalVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting int to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionInt() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + product.setInt("bigDecimalVal", 5); + BigDecimal bdVal = product.getBigDecimal("bigDecimalVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting long to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionLong() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + product.setLong("bigDecimalVal", (long)5); + + BigDecimal bdVal = product.getBigDecimal("bigDecimalVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting short to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionShort() { + BigDecimal value = new BigDecimal(4); + short newValue = (short) 5; + DataObject product = createBigDecimalObject(value); + product.setShort("bigDecimalVal", newValue); + assertEquals( newValue, product.getShort("bigDecimalVal") ); + } + + /** + * DataObject class test. Testing setting byte[] to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionBytes() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + + byte[] byteVal = {10, 100}; + try { + product.setBytes("bigDecimalVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionBigInteger() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + product.setBigInteger("bigDecimalVal", BigInteger.valueOf(5)); + + BigDecimal bdVal = product.getBigDecimal("bigDecimalVal"); + assertTrue(bdVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting date to DataObject with type + * BigDecimal + */ + public void testBigDecimalSetTypeConversionDate() { + DataObject product = createBigDecimalObject(new BigDecimal(4)); + try { + product.setDate("bigDecimalVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionBoolean() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + try { + product.setBoolean("bigIntegerVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting byte to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionByte() { + byte byteValue = 12; + BigInteger value = BigInteger.valueOf(4); + DataObject product = createBigIntegerObject(value); + product.setByte("bigIntegerVal", byteValue ); + assertEquals( byteValue, product.getByte("bigIntegerVal") ); + } + + /** + * DataObject class test. Testing setting char to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionChar() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + try { + product.setChar("bigIntegerVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionDouble() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + product.setDouble("bigIntegerVal", 5); + BigInteger biVal = product.getBigInteger("bigIntegerVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting float to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionFloat() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + product.setFloat("bigIntegerVal", 5F); + BigInteger biVal = product.getBigInteger("bigIntegerVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting int to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionInt() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + product.setInt("bigIntegerVal", 5); + BigInteger biVal = product.getBigInteger("bigIntegerVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting long to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionLong() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + product.setLong("bigIntegerVal", 5); + BigInteger biVal = product.getBigInteger("bigIntegerVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting short to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionShort() { + BigInteger value = BigInteger.valueOf(4); + short newValue = (short) 5; + DataObject product = createBigIntegerObject(value); + product.setShort("bigIntegerVal", newValue); + assertEquals( newValue, product.getShort("bigIntegerVal") ); + } + + /** + * DataObject class test. Testing setting byte[] to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionBytes() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + byte[] byteVal = {10, 100}; + product.setBytes("bigIntegerVal", byteVal); + + BigInteger biVal = product.getBigInteger("bigIntegerVal"); + + byte[] bytesRes = biVal.toByteArray(); + assertNotNull(bytesRes); + + assertEquals(2, bytesRes.length); + assertEquals(10, bytesRes[0]); + assertEquals(100, bytesRes[1]); + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionBigDecimal() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + + product.setBigDecimal("bigIntegerVal", new BigDecimal(5)); + BigInteger biVal = product.getBigInteger("bigIntegerVal"); + assertTrue(biVal.intValue() == 5); + } + + /** + * DataObject class test. Testing setting date to DataObject with type + * BigInteger + */ + public void testBigIntegerSetTypeConversionDate() { + DataObject product = createBigIntegerObject(BigInteger.valueOf(4)); + try { + product.setDate("bigIntegerVal", new Date()); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting boolean to DataObject with type + * date + */ + public void testDateSetTypeConversionBoolean() { + DataObject product = createDateObject(new Date()); + try { + product.setBoolean("dateVal", true); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting byte to DataObject with type date + */ + public void testDateSetTypeConversionByte() { + DataObject product = createDateObject(new Date()); + try { + product.setByte("dateVal", (byte)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting char to DataObject with type date + */ + public void testDateSetTypeConversionChar() { + DataObject product = createDateObject(new Date()); + try { + product.setChar("dateVal", 's'); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting double to DataObject with type + * date + */ + public void testDateSetTypeConversionDouble() { + DataObject product = createDateObject(new Date()); + try { + product.setDouble("dateVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting float to DataObject with type date + */ + public void testDateSetTypeConversionFloat() { + DataObject product = createDateObject(new Date()); + try { + product.setFloat("dateVal", 5F); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting int to DataObject with type date + */ + public void testDateSetTypeConversionInt() { + DataObject product = createDateObject(new Date()); + try { + product.setInt("dateVal", 5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting long to DataObject with type date + */ + public void testDateSetTypeConversionLong() { + Date dateNow = new Date(); + DataObject product = createDateObject(dateNow); + + product.setLong("dateVal", dateNow.getTime()); + Date dateRes = product.getDate("dateVal"); + assertEquals(dateNow.getTime(), dateRes.getTime()); + } + + /** + * DataObject class test. Testing setting short to DataObject with type date + */ + public void testDateSetTypeConversionShort() { + DataObject product = createDateObject(new Date()); + try { + product.setShort("dateVal", (short)5); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting byte[] to DataObject with type + * date + */ + public void testDateSetTypeConversionBytes() { + DataObject product = createDateObject(new Date()); + + byte[] byteVal = {10, 100}; + try { + product.setBytes("dateVal", byteVal); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting BigDecimal to DataObject with type + * date + */ + public void testDateSetTypeConversionBigDecimal() { + DataObject product = createDateObject(new Date()); + try { + product.setBigDecimal("dateVal", new BigDecimal(5)); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } + + /** + * DataObject class test. Testing setting BigInteger to DataObject with type + * date + */ + public void testDateSetTypeConversionBigInteger() { + DataObject product = createDateObject(new Date()); + try { + product.setBigInteger("dateVal", BigInteger.valueOf(5)); + fail(EXPECTED_CLASS_CAST_EXCEPTION); + } catch (ClassCastException e) { + // expected + } + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest2.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest2.java new file mode 100644 index 0000000000..01479cc351 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/TypeConversionTest2.java @@ -0,0 +1,1301 @@ +/* + * 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.conversion; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.text.SimpleDateFormat; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; + +import test.sdo21.framework.CTSTestCase; +import test.sdo21.tests.TestData.StandardDynamicFactory; +import test.sdo21.tests.TestData.StandardFactory; +import test.sdo21.tests.TestData.TestDataFactory; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * FIXME there appears to be overlap between this class and {@link TypeConversionTest} + * + */ +public class TypeConversionTest2 extends CTSTestCase { + private DataObject testDO; + TestDataFactory factory; + + public TypeConversionTest2() { + factory = createFactory(); + } + + protected TestDataFactory createFactory() { + return new StandardDynamicFactory(); + } + + @Before + public void setUp () throws Exception { + super.setUp(); + factory.defineMetaData(getScope()); + testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE); + + COMPARE_ANY = new GeneralComparator(); + API_TEST_TYPE = testDO.getType(); + + List properties = API_TEST_TYPE.getProperties(); + Property property; + String name; + + for (int i = 0; i < properties.size(); i++) { + property = (Property)properties.get(i); + name = property.getName(); + + if (name.equals("booleanVal")) { + BOOLEAN_VAL_INDEX = i; + BOOLEAN_VAL_PROP = property; + } else if (name.equals("stringVal")) { + STRING_VAL_INDEX = i; + STRING_VAL_PROP = property; + } else if (name.equals("byteVal")) { + BYTE_VAL_INDEX = i; + BYTE_VAL_PROP = property; + } else if (name.equals("decimalVal")) { + DECIMAL_VAL_INDEX = i; + DECIMAL_VAL_PROP = property; + } else if (name.equals("intVal")) { + INT_VAL_INDEX = i; + INT_VAL_PROP = property; + } else if (name.equals("floatVal")) { + FLOAT_VAL_INDEX = i; + FLOAT_VAL_PROP = property; + } else if (name.equals("doubleVal")) { + DOUBLE_VAL_INDEX = i; + DOUBLE_VAL_PROP = property; + } else if (name.equals("dateVal")) { + DATE_VAL_INDEX = i; + DATE_VAL_PROP = property; + } else if (name.equals("shortVal")) { + SHORT_VAL_INDEX = i; + SHORT_VAL_PROP = property; + } else if (name.equals("longVal")) { + LONG_VAL_INDEX = i; + LONG_VAL_PROP = property; + } else if (name.equals("bytesVal")) { + BYTES_VAL_INDEX = i; + BYTES_VAL_PROP = property; + } else if (name.equals("integerVal")) { + INTEGER_VAL_INDEX = i; + INTEGER_VAL_PROP = property; + } else if (name.equals("charVal")) { + CHAR_VAL_INDEX = i; + CHAR_VAL_PROP = property; + } + } + } + + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + // The following constants describe the index for the fields in + // api_test.xsd. + + private static int STRING_VAL_INDEX; + + private static int BOOLEAN_VAL_INDEX; + + private static int BYTE_VAL_INDEX; + + private static int DECIMAL_VAL_INDEX; + + private static int INT_VAL_INDEX; + + private static int FLOAT_VAL_INDEX; + + private static int DOUBLE_VAL_INDEX; + + private static int DATE_VAL_INDEX; + + private static int SHORT_VAL_INDEX; + + private static int LONG_VAL_INDEX; + + private static int BYTES_VAL_INDEX; + + private static int INTEGER_VAL_INDEX; + + private static int CHAR_VAL_INDEX; + + // TODO: these properties are not used . . . should they be ? + private static Property STRING_VAL_PROP; + + private static Property BOOLEAN_VAL_PROP; + + private static Property BYTE_VAL_PROP; + + private static Property DECIMAL_VAL_PROP; + + private static Property INT_VAL_PROP; + + private static Property FLOAT_VAL_PROP; + + private static Property DOUBLE_VAL_PROP; + + private static Property DATE_VAL_PROP; + + private static Property SHORT_VAL_PROP; + + private static Property LONG_VAL_PROP; + + private static Property BYTES_VAL_PROP; + + private static Property INTEGER_VAL_PROP; + + private static Property CHAR_VAL_PROP; + + // The following variables are Method arrays. Each array refers to a + // specific get<Type>, but within + // the array exist the get<Type>(index), get<Type>(property), and + // get<Type>(path). Rather than + // referring to each of the three in every circumstance, the more compact + // array appears. + + private static ConversionType TO_BOOLEAN = new ConversionType("getBoolean"); + + private static ConversionType TO_BYTE = new ConversionType("getByte"); + + private static ConversionType TO_CHAR = new ConversionType("getChar"); + + private static ConversionType TO_DOUBLE = new ConversionType("getDouble"); + + private static ConversionType TO_FLOAT = new ConversionType("getFloat"); + + private static ConversionType TO_INT = new ConversionType("getInt"); + + private static ConversionType TO_LONG = new ConversionType("getLong"); + + private static ConversionType TO_SHORT = new ConversionType("getShort"); + + private static ConversionType TO_BYTES = new ConversionType("getBytes"); + + private static ConversionType TO_BIGDECIMAL = new ConversionType("getBigDecimal"); + + private static ConversionType TO_BIGINTEGER = new ConversionType("getBigInteger"); + + private static ConversionType TO_DATAOBJECT = new ConversionType("getDataObject"); + + private static ConversionType TO_DATE = new ConversionType("getDate"); + + private static ConversionType TO_STRING = new ConversionType("getString"); + + private static ConversionType TO_LIST = new ConversionType("getList"); + + private static ConversionType TO_SEQUENCE = new ConversionType("getSequence"); + + private static GeneralComparator COMPARE_ANY; + + // There will be several instances where a Property must be passed as a + // parameter. Have available the Type + // to call getProperty() as needed. + + private static Type API_TEST_TYPE; + + + private static class ConversionType { + // The following constants are used because the getMethod function + // requires an Class + // array describing the parameters to the functions. + + private static final Class[] INT_CLASS_ARRAY = {int.class}; + + private static final Class[] PROPERTY_CLASS_ARRAY = {Property.class}; + + private static final Class[] STRING_CLASS_ARRAY = {String.class}; + + Method index_method; + + Method property_method; + + Method path_method; + + public ConversionType(String method_name) { + try { + this.index_method = DataObject.class.getMethod(method_name, INT_CLASS_ARRAY); + this.property_method = DataObject.class.getMethod(method_name, PROPERTY_CLASS_ARRAY); + this.path_method = DataObject.class.getMethod(method_name, STRING_CLASS_ARRAY); + } catch (NoSuchMethodException e) { + this.index_method = null; + this.property_method = null; + this.path_method = null; + } + } + + public Method getIndexMethod() { + return this.index_method; + } + + public Method getPropertyMethod() { + return this.property_method; + } + + public Method getPathMethod() { + return this.path_method; + } + } + + // Each instance of Test describes a convert-from type. The index, property + // and path parms + // will refer to the same field, which is a field of the convert-from type. + + private static class Test { + Object[] index_parm; + + Object[] property_parm; + + Object[] path_parm; + + Object expected_value; + + String from_type; + + // The constructor prepares a test DataObject and determines how to + // access the field + // in three different ways - index, property, and path. + + Test(String path, int index) { + this.index_parm = new Object[] {new Integer(index)}; + this.property_parm = new Object[] {API_TEST_TYPE.getProperty(path)}; + this.path_parm = new Object[] {path}; + this.expected_value = null; + } + + /** + * initialize() is a private method that establishes the initial value + * of the test field. + * + * @return + */ + + private void initialize(Class type, String type_name, Object initial_value, DataObject testDO) { + try { + Class[] classArray = {int.class, type}; + Object[] initValueArray = new Object[] {this.index_parm[0], initial_value}; + + Method setter = DataObject.class.getMethod("set" + type_name, classArray); + setter.invoke(testDO, initValueArray); + + this.expected_value = initial_value; + this.from_type = type_name; + } catch (Exception e) { + e.printStackTrace(); + fail("Exception using reflection to establish initial value for test : " + e.toString()); + } + } + + /** + * checkConversionException verifies that for a particular to and from + * Type pairing, the expected Exceptoin is thrown. + * + * @param to_type + * @param expected_exception + * @param testDO + */ + + private void checkConversionException(ConversionType to_type, Class expected_exception, DataObject testDO) { + try { + boolean index_err, path_err, property_err; + + index_err = executeExceptionCase(to_type.getIndexMethod(), this.index_parm, expected_exception, testDO); + path_err = executeExceptionCase(to_type.getPathMethod(), this.path_parm, expected_exception, testDO); + property_err = + executeExceptionCase(to_type.getPropertyMethod(), this.property_parm, expected_exception, testDO); + + assertEquals("Testing that expected exception for index paramater is equal to path paramater exception ", + index_err, + path_err); + assertEquals("Testing that expected exception for path paramater is equal to property paramater exception ", + property_err, + path_err); + + // TODO: test case needs reworking + /* + * else if (index_err == false) attemptConversion(to_type, + * testDO); + */ + if (!index_err) { + attemptConversion(to_type, testDO); + } + + // TODO: test for unexpected consistency + /* + * if (consistency_err) throw new ExpectedConditionError("An + * exception inconsistency exists for " + + * to_type.getPathMethod().getName() + " when called " + "for a " + + * this.from_type + " property."); + */ + } catch (Exception e) { + e.printStackTrace(); + fail("exception caught : " + e.toString()); + } + } + + /** + * attemptConversion is a private method that attempts the conversion to + * the specified type, using DataObject.get____(). The get___() function + * can be called with an index, path, and property. attemptConversion() + * calls each of those three. + * + * @param to_type + * @param testDO + */ + + private void attemptConversion(ConversionType to_type, DataObject testDO) { + + try { + performConversion(to_type.getIndexMethod(), this.index_parm, testDO); + performConversion(to_type.getPathMethod(), this.path_parm, testDO); + performConversion(to_type.getPropertyMethod(), this.property_parm, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception caught invoking attemptConversion for " + to_type + " : " + e.toString()); + } + } + + /** + * performConversion is a private method that is called by + * attemptConversion for each of the Property identification mechanisms. + * (Property, index, or name.) + * + * @param convert + * @param parm + * @param testDO + */ + + private void performConversion(Method convert, Object[] parm, DataObject testDO) throws Exception { + + assertEquals("Conversion did not yield expected value for " + convert.getName() + + " on a " + + this.from_type + + " property.", COMPARE_ANY.compare(convert.invoke(testDO, parm), this.expected_value), 0); + } + + /** + * executeExceptionCase is a private method that insures a particular to + * and from Type pairing will throw the expected Exception when an a + * conversion is attempted using get____(<x>). executeExceptionCase is + * called by checkConversionException for each mechanism of identifying + * the Property. (Property, name, or index.) + * + * @param convert + * @param parm + * @param expected_exception + * @param testDO + * @return whether or not the expected exception was thrown and caught + */ + private boolean executeExceptionCase(Method convert, Object[] parm, Class expected_exception, DataObject testDO) { + boolean exception_thrown = false; + try { + convert.invoke(testDO, parm); + } catch (Exception e) { + + exception_thrown = true; + Throwable cause = e.getCause(); + if (cause == null) { + assertEquals("An unexpected exception occurred while performing " + convert.getName() + + " on a " + + this.from_type + + " property.", expected_exception, e.getClass()); + } else { + assertEquals("An unexpected exception occurred while performing " + convert.getName() + + " on a " + + this.from_type + + " property.", expected_exception, cause.getClass()); + } + } + + return exception_thrown; + } + } + + private static class GeneralComparator implements Comparator { + /** + * The compare method fo the GeneralComparator class is used to compare + * two of any Types between which a covnersion is permitted in SDO. + */ + + public int compare(Object obj1, Object obj2) { + if (obj1.getClass() == obj2.getClass()) { + if (obj1.equals(obj2)) + return 0; + else + return 1; + } + + else if (obj1.getClass() == Date.class) { + if (obj2.getClass() == String.class) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'H':'mm':'ss.S"); + + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + obj2 = sdf.parse((String)obj2); + + if (obj1.equals(obj2)) + return 0; + } catch (Exception e) { + System.out.println(e.getMessage()); + } + + return 1; + } + + else { + Date temp = (Date)obj1; + + return compare(new Long(temp.getTime()), obj2); + } + + } + + else if (obj2.getClass() == Date.class) { + return compare(obj2, obj1); + } + + else if (obj1.getClass() == Boolean.class) { + Boolean temp = (Boolean)obj1; + + if (temp.booleanValue()) { + if (obj2.toString().equalsIgnoreCase("true")) + return 0; + else + return 1; + } + + else { + if (obj2.toString().equalsIgnoreCase("true")) + return 1; + else + return 0; + } + } + + else if (obj2.getClass() == Boolean.class) + return compare(obj2, obj1); + + else if (obj1.getClass() == Byte.class || obj2.getClass() == Byte.class) { + byte b1 = (Double.valueOf(obj1.toString())).byteValue(); + byte b2 = (Double.valueOf(obj2.toString())).byteValue(); + + if (b1 == b2) + return 0; + else if (b1 < b2) + return -1; + else + return 1; + } + + else if (obj1.getClass().toString().charAt(6) == '[') { + long result = 0; + long multiplier = 1; + + byte[] array = (byte[])obj1; + for (int i = 0; i < array.length; i++) { + result += array[array.length - i - 1] * multiplier; + multiplier *= 256; + } + + return compare(obj2, new Long(result)); + } + + else if (obj2.getClass().toString().charAt(6) == '[') { + return compare(obj2, obj1); + } + + else if (obj1.getClass() == Short.class || obj2.getClass() == Short.class) { + short s1 = (Double.valueOf(obj1.toString())).shortValue(); + short s2 = (Double.valueOf(obj2.toString())).shortValue(); + + if (s1 == s2) + return 0; + else if (s1 < s2) + return -1; + else + return 1; + } + + else if (obj1.getClass() == Integer.class || obj2.getClass() == Integer.class) { + int i1 = (Double.valueOf(obj1.toString())).intValue(); + int i2 = (Double.valueOf(obj2.toString())).intValue(); + + if (i1 == i2) + return 0; + else if (i1 < i2) + return -1; + else + return 1; + } + + else if (obj1.getClass() == Long.class || obj2.getClass() == Long.class + || obj1.getClass() == BigInteger.class + || obj2.getClass() == BigInteger.class) { + long l1 = (Double.valueOf(obj1.toString())).longValue(); + long l2 = (Double.valueOf(obj2.toString())).longValue(); + + if (l1 == l2) + return 0; + else if (l1 < l2) + return -1; + else + return 1; + } + + else if (obj1.getClass() == Float.class || obj2.getClass() == Float.class) { + float f1 = (Double.valueOf(obj1.toString())).floatValue(); + float f2 = (Double.valueOf(obj2.toString())).floatValue(); + + if (f1 == f2) + return 0; + else if (f1 < f2) + return -1; + else + return 1; + } + + else if (obj1.getClass() == Double.class || obj2.getClass() == Double.class) { + Double b1 = Double.valueOf(obj1.toString()); + Double b2 = Double.valueOf(obj2.toString()); + + return b1.compareTo(b2); + } + + else if (obj1.getClass() == BigDecimal.class || obj2.getClass() == BigDecimal.class) { + BigDecimal b1 = new BigDecimal(obj1.toString()); + BigDecimal b2 = new BigDecimal(obj2.toString()); + + return b1.compareTo(b2); + } + + else { + if (obj1.toString().equals(obj2.toString())) + return 0; + else + return 1; + } + } + + } + + /** + * TODO: Uncomment below as appropriate when TUSCANY-581 is resolved. In the + * following test cases, several instances are commented out. For these + * cases, the test case currently fails. A JIRA issue (TUSCANY-581) has been + * opened to either correct the behavior (then uncomment the lines) or to + * alter the specification against which the test cases were designed (and + * then remove the lines - assuming the alteration is to remove stating the + * nature of the exception). + */ + + /** + * testBooleanConversion verifies the conversion from boolean to each of the + * allowed types. + */ + @org.junit.Test + public void testBooleanConversion() { + Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX); + + FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true), testDO); + + try { + FromBoolean.attemptConversion(TO_BOOLEAN, testDO); + FromBoolean.attemptConversion(TO_STRING, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testBooleanExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from boolean is attempted. + */ + @org.junit.Test + public void testBooleanExceptions() { + try { + Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX); + + FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true), testDO); + + // FromBoolean.checkConversionException(TO_BYTE, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_CHAR, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_DOUBLE, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_FLOAT, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_INT, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_LONG, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_SHORT, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_BYTES, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_BIGDECIMAL, + // ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_BIGINTEGER, + // ClassCastException.class, testDO); + FromBoolean.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromBoolean.checkConversionException(TO_DATE, + // ClassCastException.class, testDO); + FromBoolean.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromBoolean.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testByteConversion verifies the conversion from byte to each of the + * allowed types. + */ + @org.junit.Test + public void testByteConversion() { + try { + Test FromByte = new Test("byteVal", BYTE_VAL_INDEX); + + FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127"), testDO); + + FromByte.attemptConversion(TO_BYTE, testDO); + FromByte.attemptConversion(TO_DOUBLE, testDO); + FromByte.attemptConversion(TO_FLOAT, testDO); + FromByte.attemptConversion(TO_INT, testDO); + FromByte.attemptConversion(TO_LONG, testDO); + FromByte.attemptConversion(TO_SHORT, testDO); + FromByte.attemptConversion(TO_STRING, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testByteExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from byte is attempted. + */ + @org.junit.Test + public void testByteExceptions() { + try { + Test FromByte = new Test("byteVal", BYTE_VAL_INDEX); + + FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127"), testDO); + + // FromByte.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromByte.checkConversionException(TO_CHAR, + // ClassCastException.class, + // testDO); + // FromByte.checkConversionException(TO_BYTES, + // ClassCastException.class, + // testDO); + FromByte.checkConversionException(TO_BIGDECIMAL, ClassCastException.class, testDO); + FromByte.checkConversionException(TO_BIGINTEGER, ClassCastException.class, testDO); + FromByte.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromByte.checkConversionException(TO_DATE, + // ClassCastException.class, + // testDO); + FromByte.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromByte.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testCharConversion verifies the conversion from char to each of the + * allowed types. + */ + @org.junit.Test + public void testCharConversion() { + try { + Test FromChar = new Test("charVal", CHAR_VAL_INDEX); + + FromChar.initialize(char.class, "Char", new Character('?'), testDO); + + FromChar.attemptConversion(TO_CHAR, testDO); + FromChar.attemptConversion(TO_STRING, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testCharExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from char is attempted. + */ + @org.junit.Test + public void testCharExceptions() { + try { + Test FromChar = new Test("charVal", CHAR_VAL_INDEX); + + FromChar.initialize(char.class, "Char", new Character('?'), testDO); + + // FromChar.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromChar.checkConversionException(TO_BYTE, + // ClassCastException.class, + // testDO); + // FromChar.checkConversionException(TO_DOUBLE, + // ClassCastException.class, testDO); + // FromChar.checkConversionException(TO_FLOAT, + // ClassCastException.class, + // testDO); + // FromChar.checkConversionException(TO_INT, + // ClassCastException.class, + // testDO); + // FromChar.checkConversionException(TO_LONG, + // ClassCastException.class, + // testDO); + // FromChar.checkConversionException(TO_SHORT, + // ClassCastException.class, + // testDO); + // FromChar.checkConversionException(TO_BYTES, + // ClassCastException.class, + // testDO); + // FromChar.checkConversionException(TO_BIGDECIMAL, + // ClassCastException.class, testDO); + // FromChar.checkConversionException(TO_BIGINTEGER, + // ClassCastException.class, testDO); + FromChar.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromChar.checkConversionException(TO_DATE, + // ClassCastException.class, + // testDO); + FromChar.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromChar.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testDoubleConversion verifies the conversion from double to each of the + * allowed types. + */ + @org.junit.Test + public void testDoubleConversion() { + try { + Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX); + + FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE), testDO); + + FromDouble.attemptConversion(TO_BYTE, testDO); + FromDouble.attemptConversion(TO_DOUBLE, testDO); + FromDouble.attemptConversion(TO_FLOAT, testDO); + FromDouble.attemptConversion(TO_INT, testDO); + FromDouble.attemptConversion(TO_LONG, testDO); + FromDouble.attemptConversion(TO_SHORT, testDO); + FromDouble.attemptConversion(TO_BIGDECIMAL, testDO); + FromDouble.attemptConversion(TO_BIGINTEGER, testDO); + FromDouble.attemptConversion(TO_STRING, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testDoubleExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from double is attempted. + */ + @org.junit.Test + public void testDoubleExceptions() { + try { + Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX); + + FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE), testDO); + + // FromDouble.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromDouble.checkConversionException(TO_CHAR, + // ClassCastException.class, testDO); + // FromDouble.checkConversionException(TO_BYTES, + // ClassCastException.class, testDO); + FromDouble.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromDouble.checkConversionException(TO_DATE, + // ClassCastException.class, testDO); + FromDouble.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromDouble.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testFloatConversion verifies the conversion from float to each of the + * allowed types. + */ + @org.junit.Test + public void testFloatConversion() { + try { + Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX); + + FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE), testDO); + + FromFloat.attemptConversion(TO_BYTE, testDO); + FromFloat.attemptConversion(TO_DOUBLE, testDO); + FromFloat.attemptConversion(TO_FLOAT, testDO); + FromFloat.attemptConversion(TO_INT, testDO); + FromFloat.attemptConversion(TO_LONG, testDO); + FromFloat.attemptConversion(TO_SHORT, testDO); + FromFloat.attemptConversion(TO_BIGDECIMAL, testDO); + FromFloat.attemptConversion(TO_BIGINTEGER, testDO); + FromFloat.attemptConversion(TO_STRING, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testFloatExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from float is attempted. + */ + @org.junit.Test + public void testFloatExceptions() { + try { + Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX); + + FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE), testDO); + + // FromFloat.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromFloat.checkConversionException(TO_CHAR, + // ClassCastException.class, + // testDO); + // FromFloat.checkConversionException(TO_BYTES, + // ClassCastException.class, testDO); + FromFloat.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromFloat.checkConversionException(TO_DATE, + // ClassCastException.class, + // testDO); + FromFloat.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromFloat.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } catch (Exception e) { + e.printStackTrace(); + fail("Unexpected exception " + e.toString()); + + } + } + + /** + * testIntConversion verifies the conversion from int to each of the allowed + * types. + */ + @org.junit.Test + public void testIntConversion() { + Test FromInt = new Test("intVal", INT_VAL_INDEX); + + FromInt.initialize(int.class, "Int", new Integer(5), testDO); + + FromInt.attemptConversion(TO_BYTE, testDO); + FromInt.attemptConversion(TO_DOUBLE, testDO); + FromInt.attemptConversion(TO_FLOAT, testDO); + FromInt.attemptConversion(TO_INT, testDO); + FromInt.attemptConversion(TO_LONG, testDO); + FromInt.attemptConversion(TO_SHORT, testDO); + FromInt.attemptConversion(TO_BIGDECIMAL, testDO); + FromInt.attemptConversion(TO_BIGINTEGER, testDO); + FromInt.attemptConversion(TO_STRING, testDO); + } + + /** + * testIntExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from int is attempted. + */ + @org.junit.Test + public void testIntExceptions() { + + Test FromInt = new Test("intVal", INT_VAL_INDEX); + + FromInt.initialize(int.class, "Int", new Integer(5), testDO); + + // FromInt.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromInt.checkConversionException(TO_CHAR, ClassCastException.class, + // testDO); + // FromInt.checkConversionException(TO_BYTES, ClassCastException.class, + // testDO); + FromInt.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromInt.checkConversionException(TO_DATE, ClassCastException.class, + // testDO); + FromInt.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromInt.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } + + /** + * testLongConversion verifies the conversion from long to each of the + * allowed types. + */ + @org.junit.Test + public void testLongConversion() { + Test FromLong = new Test("longVal", LONG_VAL_INDEX); + + FromLong.initialize(long.class, "Long", new Long(7000L), testDO); + + FromLong.attemptConversion(TO_BYTE, testDO); + FromLong.attemptConversion(TO_DOUBLE, testDO); + FromLong.attemptConversion(TO_FLOAT, testDO); + FromLong.attemptConversion(TO_INT, testDO); + FromLong.attemptConversion(TO_LONG, testDO); + FromLong.attemptConversion(TO_SHORT, testDO); + FromLong.attemptConversion(TO_BIGDECIMAL, testDO); + FromLong.attemptConversion(TO_BIGINTEGER, testDO); + FromLong.attemptConversion(TO_DATE, testDO); + FromLong.attemptConversion(TO_STRING, testDO); + } + + /** + * testLongExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from long is attempted. + */ + @org.junit.Test + public void testLongExceptions() { + Test FromLong = new Test("longVal", LONG_VAL_INDEX); + + FromLong.initialize(long.class, "Long", new Long(7000L), testDO); + + // FromLong.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromLong.checkConversionException(TO_CHAR, ClassCastException.class, + // testDO); + // FromLong.checkConversionException(TO_BYTES, ClassCastException.class, + // testDO); + FromLong.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + FromLong.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromLong.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } + + /** + * testShortConversion verifies the conversion from short to each of the + * allowed types. + */ + @org.junit.Test + public void testShortConversion() { + Test FromShort = new Test("shortVal", SHORT_VAL_INDEX); + + FromShort.initialize(short.class, "Short", new Short("-8000"), testDO); + + FromShort.attemptConversion(TO_BYTE, testDO); + FromShort.attemptConversion(TO_DOUBLE, testDO); + FromShort.attemptConversion(TO_FLOAT, testDO); + FromShort.attemptConversion(TO_INT, testDO); + FromShort.attemptConversion(TO_LONG, testDO); + FromShort.attemptConversion(TO_SHORT, testDO); + FromShort.attemptConversion(TO_STRING, testDO); + } + + /** + * testShortExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from short is attempted. + */ + @org.junit.Test + public void testShortExceptions() { + Test FromShort = new Test("shortVal", SHORT_VAL_INDEX); + + FromShort.initialize(short.class, "Short", new Short("-8000"), testDO); + + // FromShort.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromShort.checkConversionException(TO_CHAR, ClassCastException.class, + // testDO); + // FromShort.checkConversionException(TO_BYTES, + // ClassCastException.class, testDO); + FromShort.checkConversionException(TO_BIGDECIMAL, ClassCastException.class, testDO); + FromShort.checkConversionException(TO_BIGINTEGER, ClassCastException.class, testDO); + FromShort.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromShort.checkConversionException(TO_DATE, ClassCastException.class, + // testDO); + FromShort.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromShort.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } + + /** + * testStringConversion verifies the conversion from String to each of the + * allowed types. + */ + @org.junit.Test + public void testStringConversion() { + Test FromString = new Test("stringVal", STRING_VAL_INDEX); + + FromString.initialize(String.class, "String", "5", testDO); + + FromString.attemptConversion(TO_BOOLEAN, testDO); + FromString.attemptConversion(TO_BYTE, testDO); + FromString.attemptConversion(TO_CHAR, testDO); + FromString.attemptConversion(TO_DOUBLE, testDO); + FromString.attemptConversion(TO_FLOAT, testDO); + FromString.attemptConversion(TO_INT, testDO); + FromString.attemptConversion(TO_LONG, testDO); + FromString.attemptConversion(TO_SHORT, testDO); + FromString.attemptConversion(TO_BIGDECIMAL, testDO); + FromString.attemptConversion(TO_BIGINTEGER, testDO); + FromString.attemptConversion(TO_STRING, testDO); + + FromString.initialize(String.class, "String", "1999-07-25T8:50:14.33Z", testDO); + FromString.attemptConversion(TO_DATE, testDO); + } + + /** + * testStringExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from String is attempted. + */ + @org.junit.Test + public void testStringExceptions() { + Test FromString = new Test("stringVal", STRING_VAL_INDEX); + + FromString.initialize(String.class, "String", "5", testDO); + + // FromString.checkConversionException(TO_BYTES, + // ClassCastException.class, testDO); + FromString.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + FromString.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromString.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } + + /** + * testBytesConversion verifies the conversion from Bytes to each of the + * allowed types. + */ + @org.junit.Test + public void testBytesConversion() { + Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX); + + FromBytes.initialize(byte[].class, "Bytes", new byte[] {10, 100}, testDO); + + FromBytes.attemptConversion(TO_BYTES, testDO); + FromBytes.attemptConversion(TO_BIGINTEGER, testDO); + } + + /** + * testBytesExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from Bytes is attempted. + */ + @org.junit.Test + public void testBytesExceptions() { + Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX); + + FromBytes.initialize(byte[].class, "Bytes", new byte[] {10, 100}, testDO); + + // FromBytes.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromBytes.checkConversionException(TO_BYTE, ClassCastException.class, + // testDO); + // FromBytes.checkConversionException(TO_CHAR, ClassCastException.class, + // testDO); + // FromBytes.checkConversionException(TO_DOUBLE, + // ClassCastException.class, testDO); + // FromBytes.checkConversionException(TO_FLOAT, + // ClassCastException.class, testDO); + // FromBytes.checkConversionException(TO_INT, ClassCastException.class, + // testDO); + // FromBytes.checkConversionException(TO_LONG, ClassCastException.class, + // testDO); + // FromBytes.checkConversionException(TO_SHORT, + // ClassCastException.class, testDO); + // FromBytes.checkConversionException(TO_BIGDECIMAL, + // ClassCastException.class, testDO); + FromBytes.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromBytes.checkConversionException(TO_DATE, ClassCastException.class, + // testDO); + // FromBytes.checkConversionException(TO_STRING, + // ClassCastException.class, testDO); + FromBytes.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromBytes.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } + + /** + * testBigDecimalConversion verifies the conversion from BigDecimal to each + * of the allowed types. + */ + @org.junit.Test + public void testBigDecimalConversion() { + Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX); + + FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3"), testDO); + + FromBigDecimal.attemptConversion(TO_DOUBLE, testDO); + FromBigDecimal.attemptConversion(TO_FLOAT, testDO); + FromBigDecimal.attemptConversion(TO_INT, testDO); + FromBigDecimal.attemptConversion(TO_LONG, testDO); + FromBigDecimal.attemptConversion(TO_BIGDECIMAL, testDO); + FromBigDecimal.attemptConversion(TO_BIGINTEGER, testDO); + FromBigDecimal.attemptConversion(TO_STRING, testDO); + } + + /** + * testBigDecimalExceptions verifies that the appropriate Exceptions are + * thrown when an unpermitted conversion from BigDecimal is attempted. + */ + @org.junit.Test + public void testBigDecimalExceptions() { + Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX); + + FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3"), testDO); + + // FromBigDecimal.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromBigDecimal.checkConversionException(TO_BYTE, + // ClassCastException.class, testDO); + // FromBigDecimal.checkConversionException(TO_CHAR, + // ClassCastException.class, testDO); + // FromBigDecimal.checkConversionException(TO_SHORT, + // ClassCastException.class, testDO); + // FromBigDecimal.checkConversionException(TO_BYTES, + // ClassCastException.class, testDO); + FromBigDecimal.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromBigDecimal.checkConversionException(TO_DATE, + // ClassCastException.class, testDO); + FromBigDecimal.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromBigDecimal.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } + + /** + * testBigIntegerConversion verifies the conversion from BigInteger to each + * of the allowed types. + */ + @org.junit.Test + public void testBigIntegerConversion() { + Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX); + + FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500"), testDO); + + FromBigInteger.attemptConversion(TO_DOUBLE, testDO); + FromBigInteger.attemptConversion(TO_FLOAT, testDO); + FromBigInteger.attemptConversion(TO_INT, testDO); + FromBigInteger.attemptConversion(TO_LONG, testDO); + FromBigInteger.attemptConversion(TO_SHORT, testDO); + FromBigInteger.attemptConversion(TO_BYTES, testDO); + FromBigInteger.attemptConversion(TO_BIGDECIMAL, testDO); + FromBigInteger.attemptConversion(TO_BIGINTEGER, testDO); + FromBigInteger.attemptConversion(TO_STRING, testDO); + } + + /** + * testBigIntegerExceptions verifies that the appropriate Exceptions are + * thrown when an unpermitted conversion from BigInteger is attempted. + * + * @throws Exception + */ + @org.junit.Test + public void testBigIntegerExceptions() { + Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX); + + FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500"), testDO); + + // FromBigInteger.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromBigInteger.checkConversionException(TO_BYTE, + // ClassCastException.class, testDO); + // FromBigInteger.checkConversionException(TO_CHAR, + // ClassCastException.class, testDO); + FromBigInteger.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + // FromBigInteger.checkConversionException(TO_DATE, + // ClassCastException.class, testDO); + FromBigInteger.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromBigInteger.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } + + /** + * testDateConversion verifies the conversion from Date to each of the + * allowed types. + */ + @org.junit.Test + public void testDateConversion() { + Test FromDate = new Test("dateVal", DATE_VAL_INDEX); + + FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis()), testDO); + + FromDate.attemptConversion(TO_LONG, testDO); + FromDate.attemptConversion(TO_DATE, testDO); + FromDate.attemptConversion(TO_STRING, testDO); + } + + /** + * testDateExceptions verifies that the appropriate Exceptions are thrown + * when an unpermitted conversion from Date is attempted. + */ + @org.junit.Test + public void testDateExceptions() { + + Test FromDate = new Test("dateVal", DATE_VAL_INDEX); + + FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis()), testDO); + + // FromDate.checkConversionException(TO_BOOLEAN, + // ClassCastException.class, testDO); + // FromDate.checkConversionException(TO_BYTE, ClassCastException.class, + // testDO); + // FromDate.checkConversionException(TO_CHAR, ClassCastException.class, + // testDO); + // FromDate.checkConversionException(TO_DOUBLE, + // ClassCastException.class, testDO); + // FromDate.checkConversionException(TO_FLOAT, ClassCastException.class, + // testDO); + // FromDate.checkConversionException(TO_INT, ClassCastException.class, + // testDO); + // FromDate.checkConversionException(TO_SHORT, ClassCastException.class, + // testDO); + // FromDate.checkConversionException(TO_BYTES, ClassCastException.class, + // testDO); + // FromDate.checkConversionException(TO_BIGDECIMAL, + // ClassCastException.class, testDO); + // FromDate.checkConversionException(TO_BIGINTEGER, + // ClassCastException.class, testDO); + FromDate.checkConversionException(TO_DATAOBJECT, ClassCastException.class, testDO); + FromDate.checkConversionException(TO_LIST, ClassCastException.class, testDO); + FromDate.checkConversionException(TO_SEQUENCE, ClassCastException.class, testDO); + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/package.html b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/package.html new file mode 100644 index 0000000000..2bc8f0c36f --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/conversion/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 test cases for conversion test. +</body> +</html> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/XMLHelperTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/XMLHelperTest.java new file mode 100644 index 0000000000..ca822f6006 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/XMLHelperTest.java @@ -0,0 +1,651 @@ +/** + * + * 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.general; + +import commonj.sdo.*; +import commonj.sdo.helper.*; +import org.junit.After; +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; +import test.sdo21.framework.CTSTestCase; +import test.sdo21.tests.util.XMLEqualityChecker; + +import java.io.*; +import java.math.BigDecimal; +import java.net.URL; + +/** + * Tests various concepts against the XMLHelper, including ... + * <ul> + * <li> Verification of change summary serialization before and after undoChanges() + * <li> Round tripping of serialization + * <li> Definition of types using dynamic API + * <li> Handling of sequenced types + * <li> Handling of open sequenced types + * </ul> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=45">2.1 spec section 3.11</a> + */ +public class XMLHelperTest extends CTSTestCase { + private static final String CUSTOMER1_XML = "/customer1.xml"; + private static final String CUSTOMER2_XML = "/customer2.xml"; + private static final String MIXED_XML = "/mixed2.xml"; + private static final String MIXEDOPEN_XML = "/mixedopen.xml"; + + /** + * Verify how the XMLHelper handles serialization of a DataObject which includes a ChangeSummary.<br/> + * Checks are made before and after an {@link ChangeSummary#undoChanges()} call + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=28">2.1 spec section 3.3.5</a> + * @see XMLHelper#save(DataObject, String, String) + */ + @Test + public void testChangeSummary() throws Exception { + + final String TEST_MODEL = "/simpleWithChangeSummary.xsd"; + final String TEST_NAMESPACE = "http://www.example.com/simpleCS"; + + final String TEST_DATA_BEFORE_UNDO = "/simpleWithChangeSummary.xml"; + final String TEST_DATA_AFTER_UNDO = "/simpleWithChangeSummaryUndone.xml"; + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + getScope().getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + + Type quoteType = getScope().getTypeHelper().getType(TEST_NAMESPACE, "RootQuote"); + DataObject quote = getScope().getDataFactory().create(quoteType); + + ChangeSummary cs = quote.getChangeSummary(); + ChangeSummary csp = (ChangeSummary)quote.get("changes"); + + assertSame("The ChangeSummary Property should be returned by getChangeSummary.", cs, csp); + + quote.setString("symbol", "fbnt"); + quote.setString("companyName", "FlyByNightTechnology"); + quote.setBigDecimal("price", new BigDecimal("1000.0")); + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("1500.0")); + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + child = child.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.99")); + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2500.0")); + + // Begin logging changes + // + cs.beginLogging(); + + // Modify the data graph in various ways + // + quote.setString("symbol", "FBNT"); + quote.setBigDecimal("price", new BigDecimal("999.0")); + quote.setDouble("volume", 1000); + + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("3000.0")); + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("4000.0")); + + quote.getDataObject("quotes[2]").delete(); + + // Stop logging changes and serialize the resulting data graph + + cs.endLogging(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + getScope().getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(TEST_DATA_BEFORE_UNDO) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect the ChangeSummary: " + e.getMessage()); + } + + // Undo all changes and then serialize the resulting data graph again + + cs.undoChanges(); + + baos = new ByteArrayOutputStream(); + getScope().getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(TEST_DATA_AFTER_UNDO) + ); + } + catch (Exception e) { + fail( "XMLHelper did not accurately reflect the ChangeSummary after undoChanges(): " + e.getMessage() ); + } + } + + /** + * Verify how the XMLHelper handles open content.<br/> + * Ensures that the open content is serialized properly. + * Uses global properties from the XSD, and open content properties + * defined by the dynamic API.<br/> + * TODO -- is this primarily a TypeHelper test? Consider moving. + * + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=38">2.1 spec section 3.6.6</a> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=41">2.1 spec section 3.8.3</a> + */ + @Test + public void testDefineOpenContentProperty() throws IOException { + final String TEST_MODEL = "/open.xsd"; + final String TEST_NAMESPACE = "http://www.example.com/open"; + final String TEST_DATA = "/openContentProperty.xml"; + + TypeHelper typeHelper; + XSDHelper xsdHelper; + XMLHelper xmlHelper; + DataFactory dataFactory; + + typeHelper = getScope().getTypeHelper(); + dataFactory = getScope().getDataFactory(); + xsdHelper = getScope().getXSDHelper(); + xmlHelper = getScope().getXMLHelper(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + xsdHelper.define(inputStream, url.toString()); + inputStream.close(); + + Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote"); + DataObject quote = dataFactory.create(quoteType); + + assertNotNull( quote ); + + quote.setString("symbol", "s1"); + + Property companyProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "company"); + DataObject company = quote.createDataObject(companyProperty); + company.setString("name", "FlyByNightTechnology"); + + Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price"); + quote.getList(priceProperty).add(new BigDecimal("1000.0")); + + // Define a new SDO open content property with simple type + DataObject p = dataFactory.create("commonj.sdo", "Property"); + p.set("type", typeHelper.getType("commonj.sdo", "Decimal")); + p.set("name", "highPrice"); + Property highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p); + + quote.setBigDecimal(highPrice, new BigDecimal("1100.0")); + + // Define a new SDO open content property with complex type + DataObject mutualFundQuotePropertyDef = dataFactory.create("commonj.sdo", "Property"); + mutualFundQuotePropertyDef.set("type", quoteType); + mutualFundQuotePropertyDef.set("name", "mutualFundQuote"); + mutualFundQuotePropertyDef.setBoolean("containment", true); + Property mutualFundQuoteProperty = + typeHelper.defineOpenContentProperty(TEST_NAMESPACE, mutualFundQuotePropertyDef); + + DataObject mutualFundQuote = quote.createDataObject(mutualFundQuoteProperty); + mutualFundQuote.setString("symbol", "mutual-1"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(quote, TEST_NAMESPACE, "openStockQuote", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(TEST_DATA) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect open content." + e.getMessage()); + } + + // validate existing property condition + Property duplicateProp = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p); + assertTrue("The expected Property equality was not true", highPrice.equals(duplicateProp)); + + // validate error condition, where new property exists with different + // type + boolean errorCondition = false; + try { + p = dataFactory.create("commonj.sdo", "Property"); + p.set("type", typeHelper.getType("commonj.sdo", "String")); + p.set("name", "highPrice"); + highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p); + } catch (IllegalArgumentException ex) { + errorCondition = true; + } + assertTrue("Should not be able to redefine a Property with a different Type.", errorCondition); + } + + /** + * Verify how the XMLHelper handles Types defined using the TypeHelper. Save + * and load the Dataobject with the XMLHelper as an intermediate step.<br/> + * TODO this is a hybrid test that needs some refactoring. It implicitly tests + * dynamic type creation, creation of dynamic types, xml round tripping and the + * dataObject API without a great deal of structure. Some assertions are + * irrelevant since the tests would throw NPEs before performing the + * tests. Other assertions could be stronger than checking for non-null. See also + * testDefineTypes for similar issues.<br/> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=41">SDO spec 2..1 section 3.8.4</a> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=46">SDO spec 2..1 section 3.11.3</a> + * @see TypeHelper#define(DataObject) + * @see XMLHelper#save(DataObject, String, String, java.io.OutputStream) + * @see XMLHelper#load(InputStream, String, Object) + * + */ + @Test + public void testDefineTypeRoundTrip() throws Exception { + TypeHelper types = getScope().getTypeHelper(); + DataFactory factory = getScope().getDataFactory(); + XMLHelper xmlHelper = getScope().getXMLHelper(); + + Type intType = types.getType("commonj.sdo", "Int"); + assertNotNull( intType ); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + Property xmlElementProp = getScope().getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false); + + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + custNumProperty.setBoolean(xmlElementProp, false); + + // create a first name property + DataObject firstNameProperty = customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + firstNameProperty.setBoolean(xmlElementProp, false); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + lastNameProperty.setBoolean(xmlElementProp, false); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(customerType, "commonj.sdo", "type", baos); + + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + XMLDocument xdoc = xmlHelper.load(bais); + + customerType = xdoc.getRootObject(); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", "Customer"); + + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull("Customer1 should not be null", customer1); + Type type = customer1.getType(); + assertNotNull("Customer1.custNum should not be null", type.getProperty("custNum")); + assertNotNull("Customer1.firstName should not be null", type.getProperty("firstName")); + assertNotNull("Customer1.lastName should not be null", type.getProperty("lastName")); + assertEquals("Customer1.custNum should be intType", type.getProperty("custNum").getType(), intType); + assertEquals("Customer1.firstName should be stringType", type.getProperty("firstName").getType(), stringType); + assertEquals("Customer1.lastName should be stringType", type.getProperty("lastName").getType(), stringType); + + assertNotNull("Customer2 should not be null", customer2); + type = customer2.getType(); + assertNotNull("Customer1.custNum should not be null", type.getProperty("custNum")); + assertNotNull("Customer1.custNum should not be null", type.getProperty("firstName")); + assertNotNull("Customer1.custNum should not be null", type.getProperty("lastName")); + assertEquals("Customer1.custNum should be intType", type.getProperty("custNum").getType(), intType); + assertEquals("Customer1.firstName should be stringType", type.getProperty("firstName").getType(), stringType); + assertEquals("Customer1.lastName should be stringType", type.getProperty("lastName").getType(), stringType); + + baos = new ByteArrayOutputStream(); + xmlHelper.save(customer1, "http://example.com/customer", "Customer", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect customer1: " + e.getMessage()); + } + + baos = new ByteArrayOutputStream(); + xmlHelper.save(customer2, "http://example.com/customer", "Customer", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect customer2: " + e.getMessage()); + } + + } + + /** + * Verify how the XMLHelper handles Types defined using the TypeHelper. + * TODO this is the same as {@link XMLHelperTest#testDefineTypeRoundTrip()} without + * the round tripping of the metametadata. See the issues described in the doc for that method. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=41">SDO spec 2..1 section 3.8.4</a> + * @see TypeHelper#define(DataObject) + + */ + @Test + public void testDefineType() throws Exception { + TypeHelper types = getScope().getTypeHelper(); + DataFactory factory = getScope().getDataFactory(); + XMLHelper xmlHelper = getScope().getXMLHelper(); + + Type intType = types.getType("commonj.sdo", "Int"); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + Property xmlElementProp = getScope().getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + custNumProperty.setBoolean(xmlElementProp, false); + + // create a first name property + DataObject firstNameProperty = customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + firstNameProperty.setBoolean(xmlElementProp, false); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + lastNameProperty.setBoolean(xmlElementProp, false); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", "Customer"); + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull("Customer1 should not be null", customer1); + Type type = customer1.getType(); + assertNotNull("Customer1.custNum should not be null", type.getProperty("custNum")); + assertNotNull("Customer1.firstName should not be null", type.getProperty("firstName")); + assertNotNull("Customer1.lastName should not be null", type.getProperty("lastName")); + assertEquals("Customer1.custNum should be intType", type.getProperty("custNum").getType(), intType); + assertEquals("Customer1.firstName should be stringType", type.getProperty("firstName").getType(), stringType); + assertEquals("Customer1.lastName should be stringType", type.getProperty("lastName").getType(), stringType); + + assertNotNull("Customer2 should not be null", customer2); + type = customer2.getType(); + assertNotNull("Customer1.custNum should not be null", type.getProperty("custNum")); + assertNotNull("Customer1.custNum should not be null", type.getProperty("firstName")); + assertNotNull("Customer1.custNum should not be null", type.getProperty("lastName")); + assertEquals("Customer1.custNum should be intType", type.getProperty("custNum").getType(), intType); + assertEquals("Customer1.firstName should be stringType", type.getProperty("firstName").getType(), stringType); + assertEquals("Customer1.lastName should be stringType", type.getProperty("lastName").getType(), stringType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(customer1, "http://example.com/customer", "Customer", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect customer1: " + e.getMessage()); + } + + baos = new ByteArrayOutputStream(); + xmlHelper.save(customer2, "http://example.com/customer", "Customer", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect customer2: " + e.getMessage()); + } + } + + /** + * Verify how the XMLHelper handles defined Sequence types. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=18">SDO spec 2..1 section 3.1.8</a> + * @see DataObject#getSequence() + * @see Sequence#addText(String) + * @see Sequence#add(Property, Object) + */ + @Test + public void testDefineSequencedType() throws Exception { + + TypeHelper types = getScope().getTypeHelper(); + DataFactory factory = getScope().getDataFactory(); + XMLHelper xmlHelper = getScope().getXMLHelper(); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new mixed type - MixedQuote + DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); + mixedQuoteType.set("uri", "http://www.example.com/mixed"); + mixedQuoteType.set("name", "MixedQuote"); + mixedQuoteType.set("sequenced", Boolean.TRUE); + + DataObject symbolProperty = mixedQuoteType.createDataObject("property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + + DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); + companyNameProperty.set("name", "companyName"); + companyNameProperty.set("type", stringType); + + DataObject priceProperty = mixedQuoteType.createDataObject("property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + + DataObject quotesProperty = mixedQuoteType.createDataObject("property"); + quotesProperty.set("name", "quotes"); + quotesProperty.set("type", mixedQuoteType); + quotesProperty.set("many", Boolean.TRUE); + quotesProperty.set("containment", Boolean.TRUE); + + types.define(mixedQuoteType); + + DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote"); + + assertTrue("Quote type should be Sequenced", quote.getType().isSequenced()); + + Sequence sequence = quote.getSequence(); + + sequence.addText("\n "); + + quote.setString("symbol", "fbnt"); + + sequence.addText("\n "); + + quote.setString("companyName", "FlyByNightTechnology"); + + sequence.addText("\n some text\n "); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + sequence.addText("\n more text\n "); + + // quote.setBigDecimal("price", new BigDecimal("1000.0")); + sequence.add("price", new BigDecimal("1000.0")); + + sequence.addText("\n"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(MIXED_XML) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect quote: " + e.getMessage()); + } + } + + /** + * Verify how the XMLHelper handles Types which are Sequenced and Open. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=18">SDO spec 2..1 section 3.1.8</a> + * @see DataObject#getSequence() + * @see Sequence#addText(String) + * @see Sequence#add(Property, Object) + * @see TypeHelper#defineOpenContentProperty(String, DataObject) + * @see TypeHelper#getOpenContentProperty(String, String) + */ + @Test + public void testDefineSequencedOpenType() throws Exception { + TypeHelper types = getScope().getTypeHelper(); + DataFactory factory = getScope().getDataFactory(); + XMLHelper xmlHelper = getScope().getXMLHelper(); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new mixed type - MixedQuote + DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); + mixedQuoteType.set("uri", "http://www.example.com/mixed"); + mixedQuoteType.set("name", "MixedOpenQuote"); + mixedQuoteType.set("sequenced", Boolean.TRUE); + mixedQuoteType.set("open", Boolean.TRUE); + + // DataObject symbolProperty = + // mixedQuoteType.createDataObject("property"); + // symbolProperty.set("name", "symbol"); + // symbolProperty.set("type", stringType); + + DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); + companyNameProperty.set("name", "companyName"); + companyNameProperty.set("type", stringType); + + DataObject priceProperty = mixedQuoteType.createDataObject("property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + + DataObject quotesProperty = mixedQuoteType.createDataObject("property"); + quotesProperty.set("name", "quotes"); + quotesProperty.set("type", mixedQuoteType); + quotesProperty.set("many", Boolean.TRUE); + quotesProperty.set("containment", Boolean.TRUE); + + types.define(mixedQuoteType); + + // Define a global property + DataObject symbolProperty = factory.create("commonj.sdo", "Property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + symbolProperty.set("containment", Boolean.TRUE); + + types.defineOpenContentProperty("http://www.example.com/open", symbolProperty); + + DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote"); + + assertTrue("Quote type should be Sequenced.", quote.getType().isSequenced()); + + Sequence sequence = quote.getSequence(); + + sequence.addText("\n "); + + Property definedSymbolProperty = types.getOpenContentProperty("http://www.example.com/open", "symbol"); + quote.setString(definedSymbolProperty, "fbnt"); + + sequence.addText("\n "); + + quote.setString("companyName", "FlyByNightTechnology"); + + sequence.addText("\n some text\n "); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + sequence.addText("\n more text\n "); + + // quote.setBigDecimal("price", new BigDecimal("1000.0")); + sequence.add("price", new BigDecimal("1000.0")); + + sequence.addText("\n"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos); + + FileOutputStream fos = new FileOutputStream("XMLTCOutput"); + xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", fos); + + try { + XMLEqualityChecker.compareXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(MIXEDOPEN_XML) + ); + } + catch (Exception e) { + fail("XMLHelper did not accurately reflect quote: " + e.getMessage()); + } + } + + @Before + public void setUp() throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/XSDHelperTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/XSDHelperTest.java new file mode 100644 index 0000000000..1705f00e8a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/XSDHelperTest.java @@ -0,0 +1,239 @@ +/** + * 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.general; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.Reader; +import java.net.URL; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +//import org.junit.Before; +import javax.xml.namespace.QName; +import javax.xml.transform.stream.StreamSource; + +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaCollection; +import org.apache.ws.commons.schema.XmlSchemaComplexType; +import org.apache.ws.commons.schema.XmlSchemaObject; +import org.apache.ws.commons.schema.XmlSchemaObjectTable; +import org.apache.ws.commons.schema.XmlSchemaType; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.Ignore; + +import test.sdo21.CTSSuite; +import test.sdo21.framework.CTSTestCase; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * Tests XSD serialization/deserialization.<p/> + * This tests requires extension by import or creation of further tests. + * It currently only tests one flavour of {@link XSDHelper#define(java.io.InputStream, String)} and {@link XSDHelper#generate(List)}) + * + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=52">2.1 spec section 3.13</a> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=56">2.1 spec section 4</a> + * + */ +public class XSDHelperTest extends CTSTestCase { + private static final String TEST_MODEL = "/simple.xsd"; + private XmlSchemaCollection col = new XmlSchemaCollection(); + private static URL modelURL; + + /** + * Obtains test model resource. Runs once before any of the test methods. + */ + @BeforeClass + public static void obtainResource() { + modelURL = XSDHelperTest.class.getResource(TEST_MODEL); + } + + @Before public void setUp() throws Exception + { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Verifies the performance of XSDHelper.define() when a SchemaLocation is provided. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=52">2.1 spec section 3.13</a> + * @see commonj.sdo.XSDHelper#define(InputStream, String) + */ + @Test + public void testDefineWithLocation() { + try { + + XSDHelper xsdHelper = getScope().getXSDHelper(); + List types = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + checkTypes(modelURL, getScope().getTypeHelper(), types); + } catch (Exception e) { + fail("Exception calling xsdHelper.define" + e.toString()); + } + } + + + /** + * Utility method to ensure that the set of types in the list includes all those explicity + * defined in the schema<p> + * Checking xsd type definition post condition ---<br/> + * <i>for all t in schemaTypes there exists a t' in types such that QName(t) == QName(t')</i> + * @param modelUrl location of the schema related to the set of types + * @param typeHelper associated with the scope for the types in the list + * @param types + */ + private void checkTypes(URL modelUrl, TypeHelper typeHelper, List types) { + try { + XmlSchema schema = col.read(new StreamSource(modelUrl.openStream()), null); + XmlSchemaObjectTable schemaTypes = schema.getSchemaTypes(); + + Iterator<XmlSchemaType> it = schemaTypes.getValues(); + XmlSchemaType schemaType; + while (it.hasNext()){ + schemaType = it.next(); + QName qname = schemaType.getQName(); + Type sdoType = typeHelper.getType(qname.getNamespaceURI(), qname.getLocalPart()); + assertNotNull("Type not known to SDO environment: "+ qname, sdoType); + assertTrue("Sdo type not created from this invocation of type definition", types.contains(sdoType)); + } + } catch (IOException e) { + + fail("Exception parsing schema" + e); + } + } + + /** + * Verifies the performance of XSDHelper.define() when a SchemaLocation is not provided. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=52">2.1 spec section 3.13</a> + * @see commonj.sdo.XSDHelper#define(InputStream, String) + */ + @Test + public void testDefineWithNoLocation() { + try { + XSDHelper xsdHelper = getScope().getXSDHelper(); + List types = xsdHelper.define(XSDHelperTest.class.getResourceAsStream(TEST_MODEL), null); + checkTypes(modelURL, getScope().getTypeHelper(), types); + //assertEquals("XSDHelper.define() did not create the expected number of Types", 2, types.size()); + + } catch (Exception e) { + e.printStackTrace(); + fail("Exception caught" + e.toString()); + } + } + + /** + * Verifies that duplicate Types are not redefined. + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=52">2.1 spec section 3.13</a> + * @see commonj.sdo.XSDHelper#define(InputStream, String) + */ + @Test + public void testDuplicateDefineWithLocation() { + try { + XSDHelper xsdHelper = getScope().getXSDHelper(); + List types = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertTrue("XSDHelper.define() did not create the expected number of Types", types.size() > 0); + // redefine type + List duplicateTypes = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals("XSDHelper.define() did not create the expected number of Types", 0, duplicateTypes.size()); + + } catch (Exception e) { + e.printStackTrace(); + fail("Exception caught" + e.toString()); + } + } + + /** + * Verifies the performance of XSDHelper.generate for dynamic SDOs with no XSD model.<p/> + * Could improve this by postconditions on generated schema. + * @see commonj.sdo.XSDHelper#generate(InputStream, String) + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=53">2.1 spec section 3.13.2</a> + * @see <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1#page=56">2.1 spec section 4</a> + */ + @Test + public void testXSDGeneration_DynamicSDOType() { + try { + boolean exceptionCaught = false; + + // test for dynamic SDOs that have no XSD model. Here the testcase + // succeeds only if the + // xsd is generated by XSDHelper in which case xsd must not be null + XSDHelper xsdHelper = getScope().getXSDHelper(); + DataObject quoteType = getScope().getDataFactory().create("commonj.sdo", "Type"); + quoteType.set("uri", "http://www.example.com/dynamic"); + quoteType.set("name", "DynamicQuote"); + + TypeHelper th = getScope().getTypeHelper(); + DataObject aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "symbol"); + aProperty.set("type", th.getType("commonj.sdo", "String")); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "price"); + aProperty.set("type", th.getType("commonj.sdo", "Decimal")); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "volume"); + aProperty.set("type", th.getType("commonj.sdo", "Double")); + + th.define(quoteType); + + Type dynamicQuoteType = th.getType("http://www.example.com/dynamic", "DynamicQuote"); + + Vector types = new Vector(); + types.add(dynamicQuoteType); + String xsd = null; + + try { + xsd = xsdHelper.generate(types); + assertNotNull("XSDHelper.generate() did not complete as expected for dynamic SDOs with no XSD model. Exception was thrown", + xsd); + } catch (IllegalArgumentException e) { + fail("XSDHelper.generate() did not complete as expected for dynamic SDOs with no XSD model. Exception was thrown : " + e + .toString()); + } catch (Exception e) { + fail("Exception caught when generating a schema"); + } + + } catch (Exception e) { + e.printStackTrace(); + fail("Exception caught" + e.toString()); + } + } + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/package.html b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/package.html new file mode 100644 index 0000000000..b9f484db9d --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/general/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 test cases for other general test. +</body> +</html> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/package.html b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/package.html new file mode 100644 index 0000000000..3c54a95eb0 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/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 base class of non-paramatized test cases. +</body> +</html> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java new file mode 100644 index 0000000000..af586ee358 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java @@ -0,0 +1,542 @@ +/* + * 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.scenarios; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +import test.sdo21.framework.junit3_8.CTSTestCase; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; + +/** + * Test cases for the DataObject SDO implementation. + */ +public class DataObjectListTest extends CTSTestCase { + + /** + * Number of iterations for data type tests (sets and retrieves random + * values for each data type) + */ + + public static final int DATA_TYPE_ITERATIONS = 10; + private static int unique = 0; + + public DataObjectListTest(String title) { + super(title); + } + + public void setUp() throws Exception { + super.setUp(); + } + + /** + * Helper function for converions tests. + */ + private DataObject createType(String uri, String name) { + DataObject newType = DataFactory.INSTANCE.create("commonj.sdo", "Type"); + newType.set("uri", uri); + newType.set("name", name); + return newType; + } + + /** + * Helper function for converions tests. Creates a new type property with + * unique name and data hold property + * + * @return the property DataObject. + */ + private DataObject createTestObjectType() { + String uri = "http://example.com/DataObjectImplTest/" + unique; + String name = "DataObjectImplTest" + unique; + unique++; + // create new DataType + DataObject newType = createType(uri, name); + + // define the type + TypeHelper types = TypeHelper.INSTANCE; + types.define(newType); + return newType; + } + + /** + * Helper function. + */ + private Type getNewTestType() { + String uri = "http://example.com/DataObjectImplTest/" + (unique - 1); + String name = "DataObjectImplTest" + (unique - 1); + + return TypeHelper.INSTANCE.getType(uri, name); + } + + /** + * Helper function. Creates a new DataObject with unique Name and URI + * + * @return the created DataObject. + */ + private DataObject createTestObject() { + String uri = "http://example.com/DataObjectImplTest/" + (unique - 1); + String name = "DataObjectImplTest" + (unique - 1); + + // create DataObject with new Type + DataObject newObj = DataFactory.INSTANCE.create(uri, name); + return newObj; + } + + /** + * See SDO Spec 2.1.0 3.1.13 DataObject Accessor Exceptions General + * get(String path) returns null if path does not exist + */ + public void testGetInvalidInstanceProperty() { + createTestObjectType(); + + DataObject testObj = createTestObject(); + assertNotNull(testObj); + commonj.sdo.Property property = testObj.getInstanceProperty("nonexistentProperty"); + assertNull("testObj.getInstanceProperty(\"nonexistentProperty\") should return null", property); + } + + private void createTestObjectTypes() { + Type typeCheck = TypeHelper.INSTANCE.getType("", "catalog2"); + if (typeCheck == null) { + /* + * create type system catalog2 - product2:DataObject[isMany:true] + * product2 - nameTest:String my guess is that the intention is + * catalog2 - product2:product2(isMany:true) - nameTest:String + */ + DataObject newType = createType("", "catalog2"); + + TypeHelper types = TypeHelper.INSTANCE; + + DataObject newType2 = createType("", "product2"); + + Property xmlElementProp = getScope().getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false); + DataObject property = newType2.createDataObject("property"); + property.set("name", "name"); + property.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "String")); + property.setBoolean(xmlElementProp, false); + + + Type nt2 = types.define(newType2); + + DataObject property2 = newType.createDataObject("property"); + property2.set("name", "product2"); + property2.set("type", nt2); + property2.setBoolean("many", true); + + types.define(newType); + + } + } + + private XMLDocument loadDocFromString(String strXML) { + createTestObjectTypes(); + return XMLHelper.INSTANCE.load(strXML); + } + + private List createTestObj(XMLDocument doc) { + return doc.getRootObject().getList("product2"); + } + + + public void testClear() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + + assertEquals(2, listTest.size()); + listTest.clear(); + assertEquals(0, listTest.size()); + } + + public void testIsEmpty() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + + assertEquals(2, listTest.size()); + assertFalse(listTest.isEmpty()); + + XMLDocument doc2 = loadDocFromString("<catalog2></catalog2>"); + List listTest2 = createTestObj(doc2); + assertNotNull(listTest2); + assertEquals(0, listTest2.size()); + assertTrue(listTest2.isEmpty()); + } + + public void testToArray() { + String xmldoc = + "<catalog2><product2 name=\"name1\"/><product2 name=\"name2\"/></catalog2>"; + // "<catalog2><product2 nameTest=\"name1\"/><product2 + // nameTest=\"name2\"/></catalog2>" + XMLDocument doc = loadDocFromString(xmldoc); + List listTest = createTestObj(doc); + assertNotNull(listTest); + + Object[] objArray = listTest.toArray(); + + assertNotNull(objArray); + assertEquals(2, objArray.length); + // assertEquals("name1",((DataObject)objArray[0]).getString("nameTest")); + assertEquals("name2", ((DataObject)objArray[1]).getString("name")); + } + + public void testAddNull() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + + try { + listTest.add(null); + fail("no exception were thrown"); + } + // TODO investigate interoperability issue + catch (java.lang.NullPointerException e) { + // RogueWave success + } catch (IllegalArgumentException e) { + // Tuscany success + } + } + + public void testAddObject() { + XMLDocument doc = loadDocFromString("<catalog2></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(0, listTest.size()); + + DataObject doInsert = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doInsert); + doInsert.setString("name", "aname"); + listTest.add(0, doInsert); + + assertEquals(1, listTest.size()); + DataObject doRes = (DataObject)listTest.get(0); + assertEquals("aname", doRes.getString("name")); + } + + public void testAddAll() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject doInsert1 = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doInsert1); + doInsert1.setString("name", "aname1"); + + DataObject doInsert2 = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doInsert2); + doInsert2.setString("name", "aname2"); + + ArrayList arraylist2 = new ArrayList(); + arraylist2.add(doInsert1); + arraylist2.add(doInsert2); + + listTest.addAll(0, arraylist2); + + assertEquals(4, listTest.size()); + DataObject doRes = (DataObject)listTest.get(0); + assertEquals("aname1", doRes.getString("name")); + } + + public void testAddAllCollection() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject doInsert1 = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doInsert1); + doInsert1.setString("name", "aname1"); + + DataObject doInsert2 = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doInsert2); + doInsert2.setString("name", "aname2"); + + ArrayList arraylist2 = new ArrayList(); + arraylist2.add(doInsert1); + arraylist2.add(doInsert2); + + boolean bRes = listTest.addAll(arraylist2); + + assertTrue(bRes); + assertEquals(4, listTest.size()); + DataObject doRes = (DataObject)listTest.get(2); + assertEquals("aname1", doRes.getString("name")); + } + + public void testAddAllCollectionEmpty() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + ArrayList arraylist2 = new ArrayList(); + + boolean bRes = listTest.addAll(arraylist2); + + assertFalse(bRes); + assertEquals(2, listTest.size()); + } + + public void testIndexOf() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + int nIdx = listTest.indexOf(do1); + + assertEquals(1, nIdx); + } + + public void testLastIndexOf() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + int nIdx = listTest.lastIndexOf(do1); + + assertEquals(1, nIdx); + } + + public void testContains() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + boolean bRes = listTest.contains(do1); + + assertTrue(bRes); + + DataObject doTest = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doTest); + + bRes = listTest.contains(doTest); + + assertFalse(bRes); + } + + public void testRemoveObject() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + boolean bRes = listTest.remove(do1); + assertTrue(bRes); + assertEquals(1, listTest.size()); + + DataObject doTest = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doTest); + + bRes = listTest.remove(doTest); + assertFalse(bRes); + assertEquals(1, listTest.size()); + } + + public void testContainsAll() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + ArrayList arraylist1 = new ArrayList(); + arraylist1.add(do1); + + boolean bRes = listTest.containsAll(arraylist1); + + assertTrue(bRes); + + DataObject doTest = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doTest); + arraylist1.add(doTest); + + bRes = listTest.containsAll(arraylist1); + + assertFalse(bRes); + } + + public void testRemoveAll() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + ArrayList arraylist1 = new ArrayList(); + arraylist1.add(do1); + + boolean bRes = listTest.removeAll(arraylist1); + + assertTrue(bRes); + assertEquals(1, listTest.size()); + } + + public void testRetainAll() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + ArrayList arraylist1 = new ArrayList(); + arraylist1.add(do1); + + boolean bRes = listTest.retainAll(arraylist1); + + assertTrue(bRes); + assertEquals(1, listTest.size()); + } + + public void testIterator() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + Iterator iterRes = listTest.iterator(); + + assertNotNull(iterRes); + DataObject doRes = (DataObject)iterRes.next(); + assertNotNull(doRes); + } + + public void testSubList() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(3, listTest.size()); + + List listRes = listTest.subList(0, 1); + + assertNotNull(listRes); + assertEquals("listTest.subList(0,1)", 1, listRes.size()); + DataObject doRes = (DataObject)listRes.get(0); + assertNotNull(doRes); + } + + public void testListIterator() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + ListIterator iterRes = listTest.listIterator(); + + assertNotNull(iterRes); + DataObject doRes = (DataObject)iterRes.next(); + assertNotNull(doRes); + } + + public void testListIteratorIndex() { + XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + ListIterator iterRes = listTest.listIterator(0); + + assertNotNull(iterRes); + DataObject doRes = (DataObject)iterRes.next(); + assertNotNull(doRes); + } + + public void testSetIndexObject() { + XMLDocument doc = + loadDocFromString("<catalog2><product2 name=\"aname1\"/><product2 name=\"aname2\"/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject doTest = DataFactory.INSTANCE.create("", "product2"); + assertNotNull(doTest); + doTest.setString("name", "aname3"); + + Object objRes = listTest.set(0, doTest); + + assertNotNull(objRes); + assertTrue(objRes instanceof DataObject); + } + + public void testToArrayObject() { + XMLDocument doc = + loadDocFromString("<catalog2><product2 name=\"aname1\"/><product2 name=\"aname2\"/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + DataObject do1 = (DataObject)listTest.get(1); + assertNotNull(do1); + + ArrayList arraylist2 = new ArrayList(); + + Object[] objRes = listTest.toArray(arraylist2.toArray()); + + assertNotNull(objRes); + assertEquals(2, objRes.length); + } + + public void testToString() { + XMLDocument doc = + loadDocFromString("<catalog2><product2 name=\"aname1\"/><product2 name=\"aname2\"/></catalog2>"); + List listTest = createTestObj(doc); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + + String strRes = listTest.toString(); + + assertNotNull(strRes); + assertTrue(strRes.length() > 0); + // assertEquals("List: [DataObjectImpl[ <sss> ]]",strRes); + } + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java new file mode 100644 index 0000000000..4b734a2ee3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java @@ -0,0 +1,207 @@ +/** + * + * 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.util; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +import test.sdo21.framework.TestHelper; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; + +public class CTSUtil { + /** + * Convenience method for creating a unique name that can be used for a + * property or type. + * + * @return String containing a unique name + */ + public static DataObject createTypeDef(String uri, String name, boolean open, + HelperContext helperContext) { + DataObject typeDef = helperContext.getDataFactory().create("commonj.sdo", + "Type"); + typeDef.set("uri", uri); + typeDef.set("name", name); + typeDef.set("open", Boolean.valueOf(open)); + return typeDef; + } + + public static DataObject createPropertyDef(DataObject typeDef, String propertyName, + Type type, boolean isMany, boolean isContainment) { + DataObject propertyDef = typeDef.createDataObject("property"); + propertyDef.set("name", propertyName); + propertyDef.set("type", type); + propertyDef.set("many", isMany); + propertyDef.set("containment", isContainment); + return propertyDef; + } + + public static DataObject createPropertyDef(DataObject typeDef, String propertyName, + String typeName, boolean isMany, boolean isContainment, + HelperContext helperContext) { + int pos = typeName.indexOf('#'); + String uri = ""; + String name; + if (pos > 0) { + uri = typeName.substring(0, pos); + name = typeName.substring(pos + 1); + } else { + name = typeName; + } + Type propertyType = helperContext.getTypeHelper().getType(uri, name); + return createPropertyDef(typeDef, propertyName, propertyType, isMany, + isContainment); + } + + public static String createUniqueName() { + return "name-" + System.currentTimeMillis() + "-" + + ((int) (1000 * Math.random())); + } + + /** + * areEqualTypes is used to determine of two Types are equivalent even if + * not identically equal. The names of the Types are compared, as well as + * the Types of each of the Properties making up the Type. + * + * @param type1 + * @param type2 + * @return + */ + public static boolean areEqualTypes(Type type1, Type type2) { + List properties1, properties2; + Property property1, property2; + int size = 0, j = 0, k; + boolean found; + + // Equivalent Types have the same name + + if (!(type1.getName().equals(type2.getName()))) + return false; + + // Equivalent Types have the same number of Properties + + properties1 = type1.getProperties(); + properties2 = type2.getProperties(); + size = properties1.size(); + + if (size != properties2.size()) + return false; + + // Equivalent Types have Properties of the same name and Type + + for (int i = 0; i < size; i++) { + property1 = (Property)properties1.get(i); + k = 0; + found = false; + + while (k < size && !found) { + // j is used to prevent the initial Properties in properties2 + // from being checked every time + // j is particularly useful when the Types have Properties in + // the order + + property2 = (Property)properties2.get((k + j) % size); + + if (property1.getName().equals(property2.getName())) { + j++; + found = true; + + // Should not use recursion here to compare the Types of the + // Properties, because + // it is possible that a Type may recursively contain + // itself. + + if (!(property1.getType().getName().equals(property2.getType().getName()))) + return false; + } + k++; + } + if (!found) + return false; + } + return true; + } + + /** + * Uses the XMLHelper to serialize the input DataObject + * + * @param dataObject + * @param baos + * @param helperContexgt + * @throws IOException + */ + public static void serializeDataObjectXML(DataObject dataObject, ByteArrayOutputStream baos, HelperContext helperContext) throws IOException { + Type type = dataObject.getType(); + helperContext.getXMLHelper().save(dataObject, type.getURI(), type.getName(), baos); + } + + /** + * Uses the XMLHelper to deserialize the input XML file + * + * @param bais + * @param helperContext + * @return + * @throws IOException + * @throws ClassNotFoundException + */ + public static DataObject deserializeDataObjectXML(ByteArrayInputStream bais, HelperContext helperContext) throws IOException, ClassNotFoundException { + return helperContext.getXMLHelper().load(bais).getRootObject(); + } + + /** + * Uses Java serialization to serialize the input DataObject + * + * @param dataObject + * @param baos + * @param helperContext + * @throws IOException + */ + public static void serializeDataObjectJava(TestHelper testHelper, DataObject dataObject, ByteArrayOutputStream baos, HelperContext helperContext) throws IOException { + ObjectOutputStream out = testHelper.createObjectOutputStream(baos, helperContext); + out.writeObject(dataObject); + out.close(); + } + + /** + * Uses Java deserialization to deserialize the input XML file + * + * @param bais + * @param helperContext + * @return + * @throws IOException + * @throws ClassNotFoundException + */ + public static DataObject deserializeDataObjectJava(TestHelper testHelper, ByteArrayInputStream bais, HelperContext helperContext) throws IOException, ClassNotFoundException { + ObjectInputStream input = testHelper.createObjectInputStream(bais, helperContext); + DataObject dataObject = (DataObject)input.readObject(); + input.close(); + return dataObject; + } + + + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/XMLDifferenceException.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/XMLDifferenceException.java new file mode 100644 index 0000000000..67bd0daea9 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/XMLDifferenceException.java @@ -0,0 +1,35 @@ +/** + * + * 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.util; + +public class XMLDifferenceException extends Exception { + + public XMLDifferenceException(String message) { + super(message); + } + + public XMLDifferenceException(String message, Throwable cause) { + super(message, cause); + } + + public XMLDifferenceException(String difference, Object value1, Object value2) { + super( difference + ": " + value1 + " versus " + value2 ); + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/XMLEqualityChecker.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/XMLEqualityChecker.java new file mode 100644 index 0000000000..dee5f84ea9 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/util/XMLEqualityChecker.java @@ -0,0 +1,324 @@ +/** + * + * 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.util; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +/** + * Provides a series of methods for comparing output from the XMLHelper with an + * expected XML file. + */ +public class XMLEqualityChecker { + + private static final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance"; + + /** + * Places the nodes in nodeList into a indexed list. + * + * @param nodeList + * @param nodes + */ + private static void getAllNodes(NodeList nodeList, List nodes) { + int length = nodeList.getLength(); + if (length == 0) + return; + + for (int i = 0; i < length; i++) { + Node node = nodeList.item(i); + nodes.add(node); + getAllNodes(node.getChildNodes(), nodes); + } // for + } + + /** + * Compares two NamedNodeMap instances and throws an exception if they are not equivalent. + * + * @param mapA + * @param mapB + */ + private static void compareNamedNodeMap(NamedNodeMap mapA, NamedNodeMap mapB) throws XMLDifferenceException { + if (mapA == null) { + if (mapB == null) { + return; + } + throw new XMLDifferenceException( "mapA was null, mapB wasn't" ); + } + if (mapA.getLength() != mapB.getLength()) { + throw new XMLDifferenceException( "map length", mapA.getLength(), mapB.getLength() ); + } + for (int i = 0; i < mapA.getLength(); i++) { + Node trialNode = mapA.item(i); + if (trialNode == null) { + throw new XMLDifferenceException("mapB did not contain value at index " + i); + } + if (trialNode.getNodeName().startsWith("xmlns:")) { + // ignore namespace declarations since these will be checked on each element + // using the namespace + continue; + } + Node checkNode = mapB.getNamedItem(trialNode.getNodeName()); + if (checkNode == null) { + throw new XMLDifferenceException("mapB did not contain value named '" + trialNode.getNodeName() + "'"); + } + compareNode(trialNode, checkNode); + } + } + + /** + * Compares two Node instances and throws an exception if they are not equivalent. + * + * @param nodeA + * @param nodeB + */ + private static void compareNode(Node nodeA, Node nodeB) throws XMLDifferenceException { + if (nodeA == null) { + if (nodeB == null) { + return; + } + throw new XMLDifferenceException( "nodeA was null, nodeB wasn't" ); + } + // following is intended to provide same function as 1.5 isEqualNode() + if (nodeA.getNodeType() != nodeB.getNodeType()) { + throw new XMLDifferenceException( "node type", nodeA.getNodeType(), nodeB.getNodeType() ); + } + if (!equalString(nodeA.getLocalName(), nodeB.getLocalName())) { + throw new XMLDifferenceException( "local name", nodeA.getLocalName(), nodeB.getLocalName() ); + } + if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) { + throw new XMLDifferenceException( "namespace URI", nodeA.getNamespaceURI(), nodeB.getNamespaceURI() ); + } + + // special handling for xsi:type + if (XSI_NAMESPACE_URI.equals(nodeA.getNamespaceURI()) + && nodeA.getLocalName().equals("type")) { + + // because the gold xml file might use a different namespace prefix + // than the sdo implementation under test, we need to ignore the + // prefix used in any xsi:type attribute + + String nodeValueA = nodeA.getNodeValue(); + String nodeValueB = nodeB.getNodeValue(); + + int posA = nodeValueA.indexOf(':'); + int posB = nodeValueB.indexOf(':'); + + if (posA != -1 && posB != -1 && nodeValueA.substring(posA+1).equals(nodeValueB.substring(posB+1))) { + // the type name does match + } + else { + if (!equalString(nodeA.getNodeValue(), nodeB.getNodeValue())) { + throw new XMLDifferenceException ("node value", nodeA.getNodeValue(), nodeB.getNodeValue() ); + } + } + } + else { + if (!equalString(nodeA.getNodeValue(), nodeB.getNodeValue())) { + throw new XMLDifferenceException( + "value of node '" + nodeA.getLocalName() + "' in namespace '" + nodeA.getNamespaceURI() + "'", + nodeA.getNodeValue(), nodeB.getNodeValue() ); + } + + compareNamedNodeMap(nodeA.getAttributes(), nodeB.getAttributes()); + compareNodeList( nodeA.getChildNodes(), nodeB.getChildNodes()); + if (nodeA.getNodeType() == Node.DOCUMENT_TYPE_NODE) { + DocumentType documentTypeA = (DocumentType)nodeA; + DocumentType documentTypeB = (DocumentType)nodeB; + if (!equalString(documentTypeA.getPublicId(), documentTypeB.getPublicId())) { + throw new XMLDifferenceException( "public ID", documentTypeA.getPublicId(), documentTypeB.getPublicId() ); + } + if (!equalString(documentTypeA.getSystemId(), documentTypeB.getSystemId())) { + throw new XMLDifferenceException( "system ID", documentTypeA.getSystemId(), documentTypeB.getSystemId() ); + } + if (!equalString(documentTypeA.getInternalSubset(), documentTypeB.getInternalSubset())) { + throw new XMLDifferenceException( "internal subset", documentTypeA.getInternalSubset(), documentTypeB.getInternalSubset() ); + } + compareNamedNodeMap(documentTypeA.getEntities(), documentTypeB.getEntities()); + compareNamedNodeMap(documentTypeA.getNotations(), documentTypeB.getNotations()); + } + } + } + + /** + * Compares two NodeList instances and throws an exception if they are not equivalent. + * + * @param nodeListA + * @param nodeListB + */ + private static void compareNodeList(NodeList nodeListA, NodeList nodeListB) throws XMLDifferenceException { + if (nodeListA == null) { + if (nodeListB == null) { + return; + } + throw new XMLDifferenceException( "nodeListA was null, nodeListB wasn't" ); + } + compareNodes(nodeListA, nodeListB); + } + + /** + * Returns true of the two Strings are equivalent, false otherwise. + * + * @param stringA + * @param stringB + */ + private static boolean equalString(String stringA, String stringB) { + if (stringA == null) { + if (stringB == null) { + return true; + } + return false; + } + return stringA.equals(stringB); + } + + /** + * Returns true if the two NodeLists are equivalent, false otherwise. + * + * @param sourceNodeList + * @param targetNodeList + */ + private static void compareNodes(NodeList sourceNodeList, NodeList targetNodeList) + throws XMLDifferenceException { + + ArrayList sourceNodes = new ArrayList(); + ArrayList targetNodes = new ArrayList(); + + getAllNodes(sourceNodeList, sourceNodes); + getAllNodes(targetNodeList, targetNodes); + + int sourceLength = sourceNodes.size(); + int targetLength = targetNodes.size(); + + if (sourceLength != targetLength) { + throw new XMLDifferenceException( + "node count", + sourceLength, + targetLength + ); + } + + for (int i = 0; i < sourceLength; i++) { + Node sourceNode = (Node)sourceNodes.get(i); + Node targetNode = (Node)targetNodes.get(i); + + compareNode(sourceNode, targetNode); + } // for + } + + /** + * Throws exception if the two XML files are not equivalent. + * Accepts as input two URLs which identify the XML files, and calls + * equalXMLFiles(InputStream, InputStream). + * + * @param source + * @param target + */ + public static void compareXmlFiles(URL source, URL target) + throws XMLDifferenceException, IOException { + compareXmlFiles(source.openStream(), target.openStream()); + } + + /** + * Throws exception if the two XML files are not equivalent. + * Accepts as input an InputStream and a URL which identify the XML files, + * and calls equalXMLFiles(InputStream, InputStream). + * + * @param sourceStream + * @param target + */ + public static void compareXmlFiles(InputStream sourceStream, URL target) + throws XMLDifferenceException, IOException { + compareXmlFiles(sourceStream, target.openStream()); + } + + /** + * Throws exception if the two XML files are not equivalent. + * Accepts as input a URL and an InputStream which identify the XML files, + * and calls equalXMLFiles(InputStream, InputStream). + * + * @param source + * @param targetStream + */ + public static void compareXmlFiles(URL source, InputStream targetStream) + throws XMLDifferenceException, IOException { + compareXmlFiles(source.openStream(), targetStream); + } + + /** + * Throws exception if the two XML files are not equivalent. + * Accepts as input two InputStreams which identify the XML files. + * + * @param sourceStream + * @param targetStream + */ + public static void compareXmlFiles(InputStream sourceStream, InputStream targetStream) + throws XMLDifferenceException, IOException { + + DocumentBuilder builder; + Document sourceDocument; + Document targetDocument; + + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + builder = factory.newDocumentBuilder(); + sourceDocument = builder.parse(sourceStream); + targetDocument = builder.parse(targetStream); + } catch (IOException ie) { + throw ie; + } catch (Exception e) { + throw new XMLDifferenceException( "Failed to parse files", e ); + } + + sourceDocument.normalize(); + targetDocument.normalize(); + + /* + * remove comment when migrated to Java 1.5 if + * (!sourceDocument.getXmlVersion().equals(targetDocument.getXmlVersion())) + * return false; String sourceXmlEncoding = + * sourceDocument.getXmlEncoding(); String targetXmlEncoding = + * targetDocument.getXmlEncoding(); if (sourceXmlEncoding != null && + * targetXmlEncoding != null && + * sourceXmlEncoding.equalsIgnoreCase(targetXmlEncoding)) { // continue } + * else { return false; } + */ + + NodeList sourceNodes = sourceDocument.getChildNodes(); + NodeList targetNodes = targetDocument.getChildNodes(); + + compareNodes(sourceNodes, targetNodes); + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDBaseTestCase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDBaseTestCase.java new file mode 100644 index 0000000000..c903fe6e63 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDBaseTestCase.java @@ -0,0 +1,126 @@ +/* + * 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 junit.framework.TestCase; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Iterator; +import java.net.URL; + +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.XSDHelper; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.Type; +import commonj.sdo.Property; +import test.sdo21.CTSSuite; +import test.sdo21.framework.CTSTestCase; +import test.sdo21.framework.TestHelper; + +import org.junit.After; +import org.junit.Before; +import static org.junit.Assert.*; + +/** + * Base class for all XSD tests. + */ +public class XSDBaseTestCase extends CTSTestCase { + + protected TestHelper testHelper; + protected XSDHelper xsdHelper; + protected TypeHelper typeHelper; + protected DataFactory dataFactory; + + @Before + public void setUp() throws Exception { + super.setUp(); + testHelper = getTestHelper(); + xsdHelper = getScope().getXSDHelper(); + typeHelper = getScope().getTypeHelper(); + dataFactory = getScope().getDataFactory(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Parse an XSD file. + */ + protected List define(String filename) throws IOException { + + URL url = getClass().getResource(filename); + if (url == null) { + throw new RuntimeException("Could not locate " + filename); + } + InputStream inputStream = url.openStream(); + XSDHelper xsdHelper = getScope().getXSDHelper(); + List typeList = xsdHelper.define(inputStream, url.toString()); + inputStream.close(); + return typeList; + } + + protected void assertBaseTypeExists(Type type, String baseTypeName) { + boolean found = false; + Iterator iter = type.getBaseTypes().iterator(); + while (!found && iter.hasNext()) { + String s = (String) iter.next(); + if (s.equals(baseTypeName)) { + found = true; + } + } + if (!found) { + fail("Type '" + type.getName() + "' should have base type '" + baseTypeName + "'"); + } + } + + protected void assertPropertyExists(Type type, String propertyName, String propertyType, boolean isContainment, boolean isMany) { + Property p = type.getProperty(propertyName); + assertNotNull("property '" + propertyName + "'", p); + assertEquals("propertyType", propertyType, p.getType().getName()); + assertEquals("isContainment", isContainment, p.isContainment()); + assertEquals("isMany", isMany, p.isMany()); + } + + protected void assertPropertyExists(Type type, String propertyName, String propertyType, boolean isContainment, boolean isMany, boolean isNullable) { + Property p = type.getProperty(propertyName); + assertNotNull("property '" + propertyName + "'", p); + assertEquals("propertyType", propertyType, p.getType().getName()); + assertEquals("isContainment", isContainment, p.isContainment()); + assertEquals("isMany", isMany, p.isMany()); + assertEquals("isNullable", isNullable, p.isNullable()); + } + + public Type getType(List types, String name) { + Iterator it = types.iterator(); + while (it.hasNext()) { + Type t = (Type) it.next(); + if (t.getName().equals(name)) { + return t; + } + } + return null; + } + +} 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() ); + } +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java new file mode 100644 index 0000000000..ad1b446c3a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java @@ -0,0 +1,863 @@ +/* + * 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 java.io.IOException; + +import commonj.sdo.Type; +import commonj.sdo.Property; +import commonj.sdo.DataObject; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class XSDComplexTypeTest extends XSDBaseTestCase { + + /** + * <complexType> containing other elements. + * + * @throws Exception + */ + @Test + public void testTC128ComplexTypeWithElement() throws Exception { + + // parse the schema + List types = define("/complexType/cT_01.xsd"); + + Type type = (Type) types.get(0); + assertFalse(type.isSequenced()); + assertFalse(type.isOpen()); + assertFalse(type.isDataType()); + assertFalse(type.isAbstract()); + assertEquals("cT_01", type.getName()); + + assertPropertyExists(type, "id", "Int", false, false); + assertPropertyExists(type, "name", "String", false, false); + } + + /** + * <complexType> with abstract="true". + * + * @throws Exception + */ + @Test public void testTC129ComplexTypeAbstractTrue() throws Exception { + + List types = define("/complexType/cT_02.xsd"); + + Type type = (Type) types.get(0); + assertFalse(type.isSequenced()); + assertEquals("cT_02", type.getName()); + assertTrue(type.isAbstract()); + + assertPropertyExists(type, "id", "Int", false, false); + assertFalse(type.getProperty("id").isReadOnly() ); + assertPropertyExists(type, "name", "String", false, false); + assertFalse(type.getProperty("name").isReadOnly() ); + } + + /** + * <complexType> extending another <complexType>. + * + * @throws Exception + */ + @Test public void testTC130ComplexTypeExtendingComplexType() throws Exception { + + List types = define("/complexType/cT_03.xsd"); + assertTrue(types.size() >= 2); + + // parent + Type parentType = getType(types, "cT_03_parent"); + + List properties = parentType.getDeclaredProperties(); + assertEquals(1, properties.size()); + + Property p1 = (Property) properties.get(0); + + assertEquals("id", p1.getName()); + assertEquals("Int", p1.getType().getName()); + + // child + Type childType = getType(types, "cT_03_child"); + + List baseTypes = childType.getBaseTypes(); + assertEquals(1, baseTypes.size()); + Type baseType = (Type) baseTypes.get(0); + assertEquals("cT_03_parent", baseType.getName()); + + properties = childType.getProperties(); + assertEquals(2, properties.size()); + assertEquals(1, childType.getDeclaredProperties().size() ); + + //verify name and type of Properties + // base properties appear first, derived properties are appended + Property childTypeProp1 = (Property) properties.get(0); + assertEquals("id", childTypeProp1.getName()); + assertEquals("Int", childTypeProp1.getType().getName()); + + Property childTypeProp2 = (Property) properties.get(1); + assertEquals("name", childTypeProp2.getName()); + assertEquals("String", childTypeProp2.getType().getName()); + } + + /** + * <complexType> derived from <complexType> with block="#all" (should not affect SDO Types generated). + * + * @throws Exception + */ + @Test public void testTC131ComplexTypeBlockAll() throws Exception { + List types = define("/complexType/cT_04.xsd"); + assertTrue(types.size() >= 2); + + // parent + Type parentType = getType(types, "cT_04_parent"); + + List properties = parentType.getDeclaredProperties(); + assertEquals(1, properties.size()); + + Property p1 = (Property) properties.get(0); + + assertEquals("id", p1.getName()); + assertEquals("Int", p1.getType().getName()); + + // child + Type childType = getType(types, "cT_04_child"); + + List baseTypes = childType.getBaseTypes(); + assertEquals(1, baseTypes.size()); + Type baseType = (Type) baseTypes.get(0); + assertEquals("cT_04_parent", baseType.getName()); + + properties = childType.getProperties(); + assertEquals(2, properties.size()); + assertEquals(1, childType.getDeclaredProperties().size() ); + + //verify name and type of Properties + // base properties appear first, derived properties are appended + Property childTypeProp1 = (Property) properties.get(0); + assertEquals("id", childTypeProp1.getName()); + assertEquals("Int", childTypeProp1.getType().getName()); + + Property childTypeProp2 = (Property) properties.get(1); + assertEquals("name", childTypeProp2.getName()); + assertEquals("String", childTypeProp2.getType().getName()); + } + + /** + * <complexType> containing <group> containing <sequence>. + * + * @throws Exception + */ + @Test public void testTC132ComplexTypeGroupWithSequence() throws Exception { + List types = define("/complexType/cT_05.xsd"); + + Type type = (Type) types.get(0); + assertEquals("cT_05", type.getName()); + assertFalse(type.isAbstract()); + + assertPropertyExists(type, "id", "Int", false, false); + assertFalse(type.getProperty("id").isReadOnly()); + assertPropertyExists(type, "name", "String", false, false); + assertFalse(type.getProperty("name").isReadOnly()); + } + + /** + * <element> name="cT_06" containing anonymous <complexType>. + * + * @throws Exception + */ + @Test public void testTC133ComplexTypeAnonymous() throws Exception { + List types = define("/complexType/cT_06.xsd"); + + // The spec maps the name of anonymous types to the name + // of their enclosing element. This is a broken method however, + // as it can conflict with same named types and other same + // named elements with anonymous types. So currently we are + // intentially non-compliant. using unique names for + // anonymous types + + Property property = typeHelper.getOpenContentProperty( "http://www.example.com/xsd/6/", + "cT_06" ); + Type type = property.getType(); + assertFalse(type.isAbstract()); + assertFalse(type.isSequenced()); + + assertPropertyExists(type, "id", "Int", false, false); + assertFalse(type.getProperty("id").isReadOnly()); + assertPropertyExists(type, "name", "String", false, false); + assertFalse(type.getProperty("name").isReadOnly()); + } + + /** + * <complexType> with name. + * + * @throws Exception + */ + @Test public void testTC134ComplexTypeNamed() throws Exception { + List types = define("/complexType/cT_07.xsd"); + + Type type = (Type) types.get(0); + assertEquals("cT_07", type.getName()); + assertFalse(type.isAbstract()); + assertFalse(type.isSequenced()); + + assertPropertyExists(type, "id", "Int", false, false); + assertFalse(type.getProperty("id").isReadOnly()); + assertPropertyExists(type, "name", "String", false, false); + assertFalse(type.getProperty("name").isReadOnly()); + } + + /** + * <complexType> with final="true" containing <complexContent> containing <extension> of a <complexType> with abstract="true". + * + * @throws Exception + */ + @Test public void testTC136ComplexTypeExtendAbstractTrue() throws Exception { + List types = define("/complexType/cT_09.xsd"); + assertTrue(types.size() >= 2); + + // parent + Type parentType = typeHelper.getType("http://www.example.com/xsd/9/", "cT_09_parent"); + + List properties = parentType.getDeclaredProperties(); + assertEquals(1, properties.size()); + + Property p1 = (Property) properties.get(0); + + assertEquals("id", p1.getName()); + assertEquals("Int", p1.getType().getName()); + + // child + Type childType = typeHelper.getType("http://www.example.com/xsd/9/", "cT_09_child"); + + List baseTypes = childType.getBaseTypes(); + assertEquals(1, baseTypes.size()); + Type baseType = (Type) baseTypes.get(0); + assertEquals("cT_09_parent", baseType.getName()); + + properties = childType.getDeclaredProperties(); + assertEquals(1, properties.size()); + assertEquals(2, childType.getProperties().size() ); + + Property p2 = (Property) properties.get(0); + + assertEquals("name", p2.getName()); + assertEquals("String", p2.getType().getName()); + } + + /** + * <complexType> containing <complexContent> containing <restriction> of a <complexType> with abstract="true". + * + * @throws Exception + */ + @Test public void testTC137ComplexTypeExtendWithRestriction() throws Exception { + List types = define("/complexType/cT_10.xsd"); + assertTrue(types.size() >= 2); + + // parent + Type parentType = getType(types, "cT_10_parent"); + + List properties = parentType.getDeclaredProperties(); + assertEquals(1, properties.size()); + + Property p1 = (Property) properties.get(0); + assertEquals("id", p1.getName()); + assertEquals("Int", p1.getType().getName()); + + // child + Type childType = getType(types, "cT_10_child"); + + List baseTypes = childType.getBaseTypes(); + assertEquals(1, baseTypes.size()); + Type baseType = (Type) baseTypes.get(0); + assertEquals("cT_10_parent", baseType.getName()); + + properties = childType.getDeclaredProperties(); + assertEquals(1, properties.size()); + + Property p2 = (Property) properties.get(0); + assertEquals("name", p2.getName()); + assertEquals("String", p2.getType().getName()); + } + + /** + * <complexType> containing <complexContent> containing <extension> of a <complexType> with abstract="true". + * + * @throws Exception + */ + @Test public void testTC138ComplexTypeExtend() throws Exception { + List types = define("/complexType/cT_11.xsd"); + assertTrue(types.size() >= 2); + + // parent + Type parentType = getType(types, "cT_11_parent"); + + List properties = parentType.getDeclaredProperties(); + assertEquals(1, properties.size()); + + Property p1 = (Property) properties.get(0); + + assertEquals("id", p1.getName()); + assertEquals("Int", p1.getType().getName()); + + // child + Type childType = getType(types, "cT_11_child"); + + List baseTypes = childType.getBaseTypes(); + assertEquals(1, baseTypes.size()); + Type baseType = (Type) baseTypes.get(0); + assertEquals("cT_11_parent", baseType.getName()); + + properties = childType.getDeclaredProperties(); + assertEquals(1, properties.size()); + + Property p2 = (Property) properties.get(0); + + assertEquals("name", p2.getName()); + assertEquals("String", p2.getType().getName()); + } + + /** + * <complexType> containing <simpleContent> containing <extension>. + * + * @throws Exception + */ + @Test public void testTC143ComplexTypeSimpleContent() throws Exception { + List types = define("/complexType/cT_18.xsd"); + + Type type = typeHelper.getType("http://www.example.com/xsd/18/", "cT_18"); + + // 10.8. Corner cases + // ... + // 5. In some cases it is not possible to maintain an SDO base + // relationship when one exists in schema. This can happen for + // example when complex types extend simple types + // + // So a complexType extending a simple type doesn't have an SDO + // base type set + + List baseTypes = type.getBaseTypes(); + assertEquals(0, baseTypes.size()); + + // however complex types with simple content get a special + // property named "value" to represent their content + // p100, box 3 of the latest C++ 2.1 draft + // Complex Type extending a SimpleType + // <complexType name=[NAME]> + // <simpleContent> + // <extension + // base=[BASE]/> + // </simpleContent> + // </complexType> + // + // Type name=[NAME] + // uri=[URI] + // Property: + // name="value" type=[BASE] + // Properties are created for attribute + // declarations. + + Property valueProperty = type.getProperty("value"); + Type valueType = valueProperty.getType(); + assertEquals("String", valueType.getName()); + assertEquals("commonj.sdo", valueType.getURI()); + } + + /** + * <complexType> containing <simpleContent> containing <extension> containing <attribute>. + * + * @throws Exception + */ + @Test public void test_cT_19() throws Exception { + List types = define("/complexType/cT_19.xsd"); + + // parent + Type type = getType(types, "cT_19"); + + // 10.8. Corner cases + // ... + // 5. In some cases it is not possible to maintain an SDO base + // relationship when one exists in schema. This can happen for + // example when complex types extend simple types + // + // So a complexType extending a simple type doesn't have an SDO + // base type set + + List baseTypes = type.getBaseTypes(); + assertEquals(0, baseTypes.size()); + + List properties = type.getDeclaredProperties(); + assertEquals(2, properties.size()); + + Property p1 = type.getProperty( "lang" ); + assertEquals("String", p1.getType().getName()); + + // however complex types with simple content get a special + // property named "value" to represent their content + // p100, box 3 of the latest C++ 2.1 draft + // Complex Type extending a SimpleType + // <complexType name=[NAME]> + // <simpleContent> + // <extension + // base=[BASE]/> + // </simpleContent> + // </complexType> + // + // Type name=[NAME] + // uri=[URI] + // Property: + // name="value" type=[BASE] + // Properties are created for attribute + // declarations. + + Property valueProperty = type.getProperty("value"); + Type valueType = valueProperty.getType(); + assertEquals("String", valueType.getName()); + assertEquals("commonj.sdo", valueType.getURI()); + } + + /** + * <complexType> containing <simpleContent> containing <extension> containing <attribute>. + * + * @throws Exception + */ + @Test public void test_cT_22() throws Exception { + List types = define("/complexType/cT_22.xsd"); + + Type type = getType(types, "cT_22"); + assertFalse(type.isSequenced()); + + // 10.8. Corner cases + // ... + // 5. In some cases it is not possible to maintain an SDO base + // relationship when one exists in schema. This can happen for + // example when complex types extend simple types + // + // So a complexType extending a simple type doesn't have an SDO + // base type set + + List baseTypes = type.getBaseTypes(); + assertEquals(0, baseTypes.size()); + + List properties = type.getDeclaredProperties(); + assertEquals(2, properties.size()); + + Property p1 = type.getProperty( "lang" ); + assertEquals("String", p1.getType().getName()); + + // however complex types with simple content get a special + // property named "value" to represent their content + // p100, box 3 of the latest C++ 2.1 draft + // Complex Type extending a SimpleType + // <complexType name=[NAME]> + // <simpleContent> + // <extension + // base=[BASE]/> + // </simpleContent> + // </complexType> + // + // Type name=[NAME] + // uri=[URI] + // Property: + // name="value" type=[BASE] + // Properties are created for attribute + // declarations. + + Property valueProperty = type.getProperty("value"); + Type valueType = valueProperty.getType(); + assertEquals("String", valueType.getName()); + assertEquals("commonj.sdo", valueType.getURI()); + } + + /** + * <complexType> containing <simpleContent> containing <extension> containing <attribute> + * containing <simpleType> containing <restriction>. + * + * @throws Exception + */ + @Test public void test_cT_23() throws Exception { + List types = define("/complexType/cT_23.xsd"); + // two types are output the one for the complex type + // and the simple type + assertTrue(types.size() >= 2); + Type type = getType(types, "cT_23"); + assertFalse(type.isSequenced()); + + // 10.8. Corner cases + // ... + // 5. In some cases it is not possible to maintain an SDO base + // relationship when one exists in schema. This can happen for + // example when complex types extend simple types + // + // So a complexType extending a simple type doesn't have an SDO + // base type set + + List baseTypes = type.getBaseTypes(); + assertEquals(0, baseTypes.size()); + + List properties = type.getDeclaredProperties(); + assertEquals(2, properties.size()); + + Property p1 = type.getProperty( "lang" ); + assertNotNull( p1 ); + + // the actual type here for the lang attribute will be + // the anonymous simple type, which as it's base will + // be commonj.sdo#String + Type langBaseType = (Type)p1.getType().getBaseTypes().get(0); + assertEquals("String", langBaseType.getName()); + + // however complex types with simple content get a special + // property named "value" to represent their content + // p100, box 3 of the latest C++ 2.1 draft + // Complex Type extending a SimpleType + // <complexType name=[NAME]> + // <simpleContent> + // <extension + // base=[BASE]/> + // </simpleContent> + // </complexType> + // + // Type name=[NAME] + // uri=[URI] + // Property: + // name="value" type=[BASE] + // Properties are created for attribute + // declarations. + + Property valueProperty = type.getProperty("value"); + Type valueType = valueProperty.getType(); + assertEquals("String", valueType.getName()); + assertEquals("commonj.sdo", valueType.getURI()); + } + + /** + * <complexType> containing <all> containing <element> with minOccurs="1", maxOccurs="1". + * + * @throws Exception + */ + @Test public void testTC300ComplexTypeContainingAllGroupWithElements() throws Exception { + List types = define("/complexType/cT_24.xsd"); + Type type = getType(types, "cT_24"); + assertPropertyExists(type, "p1", "String", false, false); + } + + /** + * <complexType> containing <sequence> containing <element> with minOccurs="1", maxOccurs="1". + * + * @throws Exception + */ + @Test public void test_cT_25() throws Exception { + List types = define("/complexType/cT_25.xsd"); + Type type = getType(types, "cT_25"); + assertPropertyExists(type, "p1", "String", false, false); + } + + /** + * <complexType> containing <sequence> containing <element> with minOccurs="0", maxOccurs="unbounded". + * + * @throws Exception + */ + @Test public void test_cT_26() throws Exception { + List types = define("/complexType/cT_26.xsd"); + Type type = getType(types, "cT_26"); + assertPropertyExists(type, "p1", "String", false, true); + } + + /** + * <complexType> containing <sequence> containing <element> with minOccurs="1", maxOccurs="unbounded". + * + * @throws Exception + */ + @Test public void testTC299ComplexTypeContainingUnboundedElement() throws Exception { + List types = define("/complexType/cT_27.xsd"); + Type type = typeHelper.getType("http://www.example.com/xsd/27/", "cT_27"); + assertPropertyExists(type, "p1", "String", false, true); + } + + /** + * <complexType> containing an <element> for each XSD type supported by SDO. + * + * @throws Exception + */ + @Test public void testTC297ComplexTypeContainingElementsOfAllTypes() throws Exception { + List types = define("/complexType/cT_28.xsd"); + + Type type = getType(types, "cT_28"); + assertFalse(type.isSequenced()); + assertEquals( 44, type.getProperties().size() ); + assertPropertyExists(type, "type_date", "YearMonthDay", false, false); + assertPropertyExists(type, "type_dateTime", "DateTime", false, false); + assertPropertyExists(type, "type_decimal", "Decimal", false, false); + assertPropertyExists(type, "type_double", "Double", false, false); + assertPropertyExists(type, "type_duration", "Duration", false, false); + assertPropertyExists(type, "type_float", "Float", false, false); + assertPropertyExists(type, "type_gDay", "Day", false, false); + assertPropertyExists(type, "type_gMonth", "Month", false, false); + assertPropertyExists(type, "type_gMonthDay", "MonthDay", false, false); + assertPropertyExists(type, "type_gYear", "Year", false, false); + assertPropertyExists(type, "type_gYearMonth", "YearMonth", false, false); + assertPropertyExists(type, "type_int", "Int", false, false); + assertPropertyExists(type, "type_integer", "Integer", false, false); + assertPropertyExists(type, "type_long", "Long", false, false); + assertPropertyExists(type, "type_negativeInteger", "Integer", false, false); + assertPropertyExists(type, "type_nonNegativeInteger", "Integer", false, false); + assertPropertyExists(type, "type_nonPositiveInteger", "Integer", false, false); + assertPropertyExists(type, "type_positiveInteger", "Integer", false, false); + assertPropertyExists(type, "type_short", "Short", false, false); + assertPropertyExists(type, "type_string", "String", false, false); + assertPropertyExists(type, "type_time", "Time", false, false); + assertPropertyExists(type, "type_unsignedByte", "Short", false, false); + assertPropertyExists(type, "type_unsignedInt", "Long", false, false); + assertPropertyExists(type, "type_unsignedLong", "Integer", false, false); + assertPropertyExists(type, "type_unsignedShort", "Int", false, false); + assertPropertyExists(type, "type_anyType", "DataObject", true, false); + assertPropertyExists(type, "type_anyURI", "URI", false, false); + assertPropertyExists(type, "type_base64Binary", "Bytes", false, false); + assertPropertyExists(type, "type_byte", "Byte", false, false); + assertPropertyExists(type, "type_ENTITY", "String", false, false); + assertPropertyExists(type, "type_hexBinary", "Bytes", false, false); + assertPropertyExists(type, "type_ID", "String", false, false); + assertPropertyExists(type, "type_IDREF", "String", false, false); + assertPropertyExists(type, "type_language", "String", false, false); + assertPropertyExists(type, "type_Name", "String", false, false); + assertPropertyExists(type, "type_NCName", "String", false, false); + assertPropertyExists(type, "type_QName", "URI", false, false); + assertPropertyExists(type, "type_token", "String", false, false); + assertPropertyExists(type, "type_NMTOKEN", "String", false, false); + assertPropertyExists(type, "type_NMTOKENS", "Strings", false, false); + assertPropertyExists(type, "type_IDREFS", "Strings", false, false); + assertPropertyExists(type, "type_ENTITIES", "Strings", false, false); + assertPropertyExists(type, "type_anySimpleType", "Object", false, false); + } + + /** + * <complexType> containing an <attribute> for each XSD type supported by SDO. + * + * @throws Exception + */ + @Test public void test_cT_29() throws Exception { + List types = define("/complexType/cT_29.xsd"); + + Type type = getType(types, "cT_29"); + assertFalse(type.isSequenced()); + assertPropertyExists(type, "type_date", "YearMonthDay", false, false); + assertPropertyExists(type, "type_dateTime", "DateTime", false, false); + assertPropertyExists(type, "type_decimal", "Decimal", false, false); + assertPropertyExists(type, "type_double", "Double", false, false); + assertPropertyExists(type, "type_duration", "Duration", false, false); + assertPropertyExists(type, "type_float", "Float", false, false); + assertPropertyExists(type, "type_gDay", "Day", false, false); + assertPropertyExists(type, "type_gMonth", "Month", false, false); + assertPropertyExists(type, "type_gMonthDay", "MonthDay", false, false); + assertPropertyExists(type, "type_gYear", "Year", false, false); + assertPropertyExists(type, "type_gYearMonth", "YearMonth", false, false); + assertPropertyExists(type, "type_int", "Int", false, false); + assertPropertyExists(type, "type_integer", "Integer", false, false); + assertPropertyExists(type, "type_long", "Long", false, false); + assertPropertyExists(type, "type_negativeInteger", "Integer", false, false); + assertPropertyExists(type, "type_nonNegativeInteger", "Integer", false, false); + assertPropertyExists(type, "type_nonPositiveInteger", "Integer", false, false); + assertPropertyExists(type, "type_positiveInteger", "Integer", false, false); + assertPropertyExists(type, "type_short", "Short", false, false); + assertPropertyExists(type, "type_string", "String", false, false); + assertPropertyExists(type, "type_time", "Time", false, false); + assertPropertyExists(type, "type_unsignedByte", "Short", false, false); + assertPropertyExists(type, "type_unsignedInt", "Long", false, false); + assertPropertyExists(type, "type_unsignedLong", "Integer", false, false); + assertPropertyExists(type, "type_unsignedShort", "Int", false, false); + assertPropertyExists(type, "type_anyURI", "URI", false, false); + assertPropertyExists(type, "type_base64Binary", "Bytes", false, false); + assertPropertyExists(type, "type_byte", "Byte", false, false); + assertPropertyExists(type, "type_ENTITIES", "Strings", false, false); + assertPropertyExists(type, "type_ENTITY", "String", false, false); + assertPropertyExists(type, "type_hexBinary", "Bytes", false, false); + assertPropertyExists(type, "type_ID", "String", false, false); + assertPropertyExists(type, "type_IDREF", "String", false, false); + assertPropertyExists(type, "type_IDREFS", "Strings", false, false); + assertPropertyExists(type, "type_language", "String", false, false); + assertPropertyExists(type, "type_Name", "String", false, false); + assertPropertyExists(type, "type_NMTOKEN", "String", false, false); + assertPropertyExists(type, "type_NMTOKENS", "Strings", false, false); + assertPropertyExists(type, "type_QName", "URI", false, false); + assertPropertyExists(type, "type_token", "String", false, false); + assertPropertyExists(type, "type_NCName", "String", false, false); + assertPropertyExists(type, "type_anySimpleType", "Object", false, false); + } + + /** + * <complexType> containing a <sequence> which contains a <group> reference and an <element>. The <group> + * also contains a <sequence>. + * + * @throws Exception + */ + @Test public void test_cT_30() throws Exception { + List types = define("/complexType/cT_30.xsd"); + + Type type = getType(types, "cT_30"); + assertFalse(type.isSequenced()); + assertPropertyExists(type, "p1", "String", false, false); + assertPropertyExists(type, "p2", "String", false, false); + assertPropertyExists(type, "p3", "Int", false, false); + } + + /** + * <complexContent> using <extension> to extend another <complexContent>. The derived <complexContent> + * references a <group> which contains a <sequence>. + * + * @throws Exception + */ + @Test public void test_cT_31() throws Exception { + List types = define("/complexType/cT_31.xsd"); + assertTrue(types.size() >= 2); + + Type type = getType(types, "cT_31"); + assertFalse(type.isSequenced()); + assertPropertyExists(type, "p1", "String", false, false); + assertPropertyExists(type, "p2", "String", false, false); + assertPropertyExists(type, "p3", "Int", false, false); + assertPropertyExists(type, "p4", "String", false, false); + assertPropertyExists(type, "p5", "String", false, false); + } + + /** + * <complexType> with mixed="true". Must create SDO Type with sequenced="true". + * + * @throws Exception + */ + @Test public void test_cT_42() throws Exception { + List types = define("/complexType/cT_42.xsd"); + + Type type = getType(types, "cT_42"); + assertTrue(type.isSequenced()); + assertPropertyExists(type, "id", "Int", false, false); + assertPropertyExists(type, "name", "String", false, false); + } + + + /** + * <complexType> containing <any> with maxOccurs="unbounded". Should map to SDO Type with + * sequenced="true" and no declared properties. + * + * @throws Exception + */ + @Test public void test_cT_43() throws Exception { + List types = define("/complexType/cT_43.xsd"); + + Type type = getType(types, "cT_43"); + assertTrue(type.isOpen()); + assertEquals(0, type.getProperties().size()); + } + + /** + * <complexType> containing <any> with maxOccurs="1". Should map to SDO Type with + * sequenced="false" and no declared properties. + * + * @throws Exception + */ + @Test public void test_cT_44() throws Exception { + List types = define("/complexType/cT_44.xsd"); + + Type type = getType(types, "cT_44"); + assertTrue(type.isOpen()); + assertFalse(type.isSequenced()); + assertEquals(0, type.getProperties().size()); + } + + /** + * <complexType> containing <anyAttribute> . Should map to SDO Type with + * no declared properties. + * + * @throws Exception + */ + @Test public void test_cT_45() throws Exception { + List types = define("/complexType/cT_45.xsd"); + + Type type = getType(types, "cT_45"); + assertTrue(type.isOpen()); + assertFalse(type.isSequenced()); + assertEquals(0, type.getProperties().size()); + } + + /** + * <complexType> containing element with nillable="true" + * + * @throws Exception + */ + @Test public void test_cT_46() throws Exception { + + List types = define("/complexType/cT_46.xsd"); + + Type type = (Type) types.get(0); + assertFalse(type.isSequenced()); + assertFalse(type.isOpen()); + assertFalse(type.isDataType()); + assertFalse(type.isAbstract()); + assertEquals("cT_46", type.getName()); + + assertPropertyExists(type, "id", "Int", false, false); + assertPropertyExists(type, "name", "String", false, false); + + assertEquals( false, type.getProperty("id").isNullable() ); + assertEquals( true, type.getProperty("name").isNullable() ); + } + + /** + * <complexType> containing an anySimpletype element + * + * @throws Exception + */ + @Test public void testTC298ComplexTypeSetAnySimpleTypeWithStringValue() throws Exception { + List types = define("/complexType/cT_47.xsd"); + + DataObject dobj = getScope().getDataFactory().create( "http://www.example.com/xsd/47/", "cT_47" ); + Property p = dobj.getProperty( "type_anySimpleType" ); + assertNotNull( p ); + + assertEquals( "commonj.sdo", p.getType().getURI() ); + assertEquals( "Object", p.getType().getName() ); + + dobj.set( "type_anySimpleType", "foo" ); + assertEquals( "foo", dobj.get( "type_anySimpleType") ); + } + + @Test public void test_cT_48() throws IOException { + List types = define("/complexType/cT_48.xsd"); + assertTrue(types.size() >= 4); + + Type t1 = getType(types, "complextype1"); + Property p1 = t1.getProperty("person"); + assertNotNull(p1); + + Type t2 = getType(types, "complextype2"); + Property p2 = t2.getProperty("person"); + assertNotNull(p2); + + // although the 2.1 spec says that the name of the anonymous types should be the same as the name of the + // enclosing element or attribute, this would result in a name clash so we need to ensure that the type + // names are not the same + String typeName1 = p1.getType().getName(); + String typeName2 = p2.getType().getName(); + assertFalse( typeName1.equals(typeName2) ); + } + +} + + diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDSimpleTypeTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDSimpleTypeTest.java new file mode 100644 index 0000000000..dfeb5cccc1 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDSimpleTypeTest.java @@ -0,0 +1,364 @@ +/* + * 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 java.io.File; + +import commonj.sdo.Type; +import commonj.sdo.Property; +import commonj.sdo.DataObject; +import commonj.sdo.DataGraph; + +import org.junit.Test; +import org.junit.Ignore; +import static org.junit.Assert.*; + + +public class XSDSimpleTypeTest extends XSDBaseTestCase { + + /** + * <simpleType> with a restriction from type xs:string + * + * @throws Exception + */ + @Test + public void testRestriction() throws Exception { + List types = define("/simpleType/restriction.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type = getType(types, "simpleTypeRestriction"); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(1, type.getBaseTypes().size()); + Type baseType = (Type) type.getBaseTypes().get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("String", baseType.getName()); + } + + /** + * <element> using anonymous <simpleType>. We expect the SDO Type to have the same name as the element + * as per page 80 of the Java spec. + */ + @Test + public void testAnonOpenContentProperty() throws Exception { + List types = define("/simpleType/anonymous.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + // get open content property defined by global element in XSD + String uri = "http://www.example.com/simpleType/anonymous"; + Property property = typeHelper.getOpenContentProperty(uri, "simpleTypeAnon"); + + assertNotNull(property); + + // The spec maps the name of anonymous types to the name + // of their enclosing element. This is a broken method however, + // as it can conflict with same named types and other same + // named elements with anonymous types. So currently we are + // intentially non-compliant. using unique names for + // anonymous types + + Type type = property.getType(); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(1, type.getBaseTypes().size()); + Type baseType = (Type) type.getBaseTypes().get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("String", baseType.getName()); + } + + /** + * <simpleType> with final="list" + * + * @throws Exception + */ + @Test + public void testFinalList() throws Exception { + List types = define("/simpleType/finalList.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type = getType(types, "simpleTypeFinalList"); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(1, type.getBaseTypes().size()); + + Type baseType = (Type) type.getBaseTypes().get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("String", baseType.getName()); + } + + /** + * <simpleType> with final="union" + * + * @throws Exception + */ + @Test + public void testFinalUnion() throws Exception { + List types = define("/simpleType/finalUnion.xsd"); + + Type type = getType(types, "simpleTypeFinalUnion"); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(1, type.getBaseTypes().size()); + + Type baseType = (Type) type.getBaseTypes().get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("String", baseType.getName()); + } + + /** + * <simpleType> with final="restriction" + * + * @throws Exception + */ + @Test + public void testFinalRestriction() throws Exception { + List types = define("/simpleType/finalRestriction.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type = getType(types, "simpleTypeFinalRestriction"); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(1, type.getBaseTypes().size()); + + Type baseType = (Type) type.getBaseTypes().get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("String", baseType.getName()); + } + + /** + * @throws Exception + */ + @Test + @Ignore + public void testDerivedType() throws Exception { + List types = define("/simpleType/derived.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type0 = getType(types, "derivedType"); + Type type1 = getType(types, "baseType"); + + assertEquals("baseType", type1.getName()); + assertEquals("derivedType", type0.getName()); + + assertTrue(type0.isDataType()); + assertTrue(type1.isDataType()); + assertFalse(type0.isOpen()); + assertFalse(type0.isSequenced()); + assertEquals(0, type0.getProperties().size()); + assertEquals(1, type0.getBaseTypes().size()); + + List baseTypes = type0.getBaseTypes(); + assertEquals(1, baseTypes.size()); + + Type baseType = (Type) baseTypes.get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("Integer", baseType.getName()); + } + + /** + * @throws Exception + */ + @Test + @Ignore + public void testDerivedType2() throws Exception { + List types = define("/simpleType/derived2.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type0 = getType(types, "baseType"); + Type type1 = getType(types, "derivedType"); + + assertEquals("baseType", type0.getName()); + assertEquals("derivedType", type1.getName()); + + assertTrue(type0.isDataType()); + assertTrue(type1.isDataType()); + assertFalse(type0.isOpen()); + assertFalse(type0.isSequenced()); + assertEquals(0, type0.getProperties().size()); + assertEquals(1, type0.getBaseTypes().size()); + + List baseTypes = type0.getBaseTypes(); + assertEquals(1, baseTypes.size()); + + Type baseType = (Type) baseTypes.get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("Integer", baseType.getName()); + + List derivedTypes = type1.getBaseTypes(); + assertEquals(1, derivedTypes.size()); + Type derivedType = (Type) derivedTypes.get(0); + + assertEquals("Integer", derivedType.getName()); + } + + @Test + public void testDerivedUnionType() throws Exception { + List types = define("/simpleType/derivedUnion.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type0 = getType(types, "fontbystringname"); + Type type1 = getType(types, "fontbynumber"); + + assertEquals("fontbynumber", type1.getName()); + assertEquals("fontbystringname", type0.getName()); + + assertTrue(type0.isDataType()); + assertTrue(type1.isDataType()); + + assertFalse(type0.isOpen()); + assertFalse(type0.isSequenced()); + assertEquals(0, type0.getProperties().size()); + assertEquals(1, type0.getBaseTypes().size()); + + //Get the first union type and check + List basetypes1 = type0.getBaseTypes(); + assertEquals(1, basetypes1.size()); + Type basetype1 = (Type) basetypes1.get(0); + + assertEquals(basetype1.getURI(), "commonj.sdo"); + assertEquals(basetype1.getName(), "String"); + + //Get the second union type and check + List basetypes2 = type1.getBaseTypes(); + assertEquals(1, basetypes2.size()); + Type basetype2 = (Type) basetypes2.get(0); + + assertEquals(basetype2.getName(), "Integer"); + } + + /** + * <simpleType> containing <annotation> (no effect on SDO type but want to make + * sure we can parse it ok) + * + * @throws Exception + */ + @Test + public void testAnnotation() throws Exception { + List types = define("/simpleType/annotation.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type = getType(types, "simpleTypeAnnotated"); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(1, type.getBaseTypes().size()); + + Type baseType = (Type) type.getBaseTypes().get(0); + assertEquals("commonj.sdo", baseType.getURI()); + assertEquals("String", baseType.getName()); + } + + /** + * <simpleType> containing <list> + * + * @throws Exception + */ + @Test + public void testTC200SimpleType() throws Exception { + List types = define("/simpleType/list.xsd"); + + Type type = getType(types, "simpleTypeList"); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(0, type.getBaseTypes().size()); + } + + @Test + public void testEnumeration() throws Exception { + List types = define("/simpleType/enumeration.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type thing = getType(types, "thing"); + Property colorofthing = thing.getProperty("colorofthing"); + Property sizeofthing = thing.getProperty("sizeofthing"); + + assertEquals("thing", thing.getName()); + assertEquals("colorofthing", colorofthing.getName()); + assertEquals("sizeofthing", sizeofthing.getName()); + + DataObject dobj = dataFactory.create(thing.getURI(), thing.getName()); + dobj.setInt("sizeofthing", 2); + dobj.setString("colorofthing", "red"); + + assertEquals("red", dobj.getString("colorofthing")); + assertEquals(2, dobj.getInt("sizeofthing")); + } + + /** + * <simpleType> containing <union> + * + * @throws Exception + */ + @Test + public void testUnion() throws Exception { + List types = define("/simpleType/union.xsd"); + + // at least one type should have been returned + assertTrue(types.size() > 0); + + Type type = getType(types, "simpleTypeUnion"); + assertEquals(false, type.isAbstract()); + assertEquals(true, type.isDataType()); + assertEquals(false, type.isOpen()); + assertEquals(false, type.isSequenced()); + assertEquals(0, type.getProperties().size()); + assertEquals(0, type.getBaseTypes().size()); + } + +} diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/api_test.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/api_test.xsd new file mode 100644 index 0000000000..c740060161 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/api_test.xsd @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<xsd:schema xmlns:sdo="commonj.sdo" xmlns:sdoXML="commonj.sdo/xml" xmlns:api="http://www.example.com/api_test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/api_test"> + <!-- <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/> --> + + <xsd:element name="apiTestElem" type="api:APITest"/> + + <xsd:complexType name="APITest"> + <xsd:sequence> + <xsd:element name="stringVal" type="xsd:string"/> + <xsd:element name="booleanVal" type="xsd:boolean"/> + <xsd:element name="booleanVal2" type="xsd:boolean"/> + <xsd:element name="byteVal" type="xsd:byte"/> + <xsd:element name="stringVal2" type="xsd:string"/> + <xsd:element name="decimalVal" type="xsd:decimal"/> + <xsd:element name="decimalVal2" sdo:aliasName="dec2" type="xsd:decimal"/> + <xsd:element name="intVal" type="xsd:int"/> + <xsd:element name="floatVal" type="xsd:float"/> + <xsd:element name="doubleVal" type="xsd:double"/> + <xsd:element name="dateVal" type="xsd:dateTime"/> + <xsd:element name="shortVal" type="xsd:short"/> + <xsd:element name="longVal" type="xsd:long"/> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="containMany" type="api:APITest"/> + <xsd:element name="bytesVal" type="xsd:hexBinary"/> + <xsd:element name="integerVal" type="xsd:integer"/> + <xsd:element name="charVal" type="api:char"/> + <xsd:element name="readOnlyVal" type="xsd:string" sdoXML:readOnly="true"/> + <xsd:element name="sequencedElem" type="api:Sequenced"/> + <xsd:element name="extendedElem" type="api:Extended"/> + <xsd:element name="openElem" type="api:Open"/> + <xsd:element name="contain" type="api:APITest"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="Sequenced" mixed="true"> + <xsd:sequence> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Numbers" type="xsd:int"/> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Letters" type="xsd:string"/> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="containMany" type="api:Sequenced"/> + <xsd:element name="contain" type="api:Sequenced"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="Open"> + <xsd:sequence> + <xsd:element name="defined" type="xsd:string"/> + <xsd:any maxOccurs="unbounded" namespace="##any"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:simpleType name="char"> + <xsd:restriction base="xsd:string"> + <xsd:length value="1"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:complexType abstract="true" name="Abstract"> + <xsd:sequence> + <xsd:element name="firstName" type="xsd:string"/> + <xsd:element name="lastName" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="Extended" sdo:aliasName="Ext2"> + <xsd:complexContent> + <xsd:extension base="api:Abstract"> + <xsd:sequence> + <xsd:element name="nickName" type="xsd:string"/> + <xsd:element name="middleName" type="xsd:string"/> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> + +</xsd:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC224.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC224.xsd new file mode 100644 index 0000000000..3851b9b837 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC224.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:TC224="http://www.example.com/TC224" targetNamespace="http://www.example.com/TC224"> + <xs:element name="rootElement"> + <xs:annotation> + <xs:documentation>Comment describing your root element</xs:documentation> + </xs:annotation> + </xs:element> + <xs:complexType name="choiceType"> + <xs:choice> + <xs:element name="red"/> + <xs:element name="green"/> + <xs:element name="blue"/> + </xs:choice> + </xs:complexType> +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC225.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC225.xsd new file mode 100644 index 0000000000..c3b675faa1 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC225.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:TC225="http://www.example.com/TC225" targetNamespace="http://www.example.com/TC225"> + <xs:element name="rootElement"> + <xs:annotation> + <xs:documentation>Comment describing your root element</xs:documentation> + </xs:annotation> + </xs:element> + <xs:complexType name="choiceType"> + <xs:choice maxOccurs="unbounded"> + <xs:element name="red"/> + <xs:element name="green"/> + <xs:element name="blue"/> + </xs:choice> + </xs:complexType> +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC226.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC226.xsd new file mode 100644 index 0000000000..984f0e6a32 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC226.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:TC226="http://www.example.com/TC226" targetNamespace="http://www.example.com/TC226"> + <xs:element name="rootElement"> + <xs:annotation> + <xs:documentation>Comment describing your root element</xs:documentation> + </xs:annotation> + </xs:element> + <xs:complexType name="choiceType"> + <xs:choice> + <xs:element name="red" type="xs:string"/> + <xs:element name="green"/> + <xs:element name="blue"/> + </xs:choice> + </xs:complexType> +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC227.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC227.xsd new file mode 100644 index 0000000000..734c2763fd --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/choice/TC227.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:TC227="http://www.example.com/TC227" targetNamespace="http://www.example.com/TC227"> + <xs:element name="rootElement"> + <xs:annotation> + <xs:documentation>Comment describing your root element</xs:documentation> + </xs:annotation> + </xs:element> + <xs:complexType name="choiceType"> + <xs:choice maxOccurs="5"> + <xs:element name="red"/> + <xs:element name="green"/> + <xs:element name="blue"/> + </xs:choice> + </xs:complexType> +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_01.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_01.xsd new file mode 100644 index 0000000000..bc66ce6bb5 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_01.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/1/"> + <xs:complexType name="cT_01"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_02.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_02.xsd new file mode 100644 index 0000000000..4f3f47d1bd --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_02.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/2/"> + <xs:complexType name="cT_02" abstract="true"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_03.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_03.xsd new file mode 100644 index 0000000000..58046c76e4 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_03.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/3/" xmlns:tns="http://www.example.com/xsd/3/"> + <xs:complexType name="cT_03_parent"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="cT_03_child" > + <xs:complexContent> + <xs:extension base="tns:cT_03_parent"> + <xs:sequence> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_04.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_04.xsd new file mode 100644 index 0000000000..9bfec9f0a7 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_04.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/4/" xmlns:tns="http://www.example.com/xsd/4/"> + <xs:complexType name="cT_04_parent" block="#all"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="cT_04_child" > + <xs:complexContent> + <xs:extension base="tns:cT_04_parent"> + <xs:sequence> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_05.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_05.xsd new file mode 100644 index 0000000000..56b2f0f0fa --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_05.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/5/" xmlns:tns="http://www.example.com/xsd/5/"> + + <xs:group name="cT_05_group"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:group> + + <xs:complexType name="cT_05"> + <xs:sequence> + <xs:group ref="tns:cT_05_group" /> + </xs:sequence> + </xs:complexType> + +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_06.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_06.xsd new file mode 100644 index 0000000000..5b2362a06f --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_06.xsd @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/6/"> + <xs:element name="cT_06"> + <xs:complexType> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_07.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_07.xsd new file mode 100644 index 0000000000..7848ce0caa --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_07.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/7/"> + <xs:complexType name="cT_07"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_09.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_09.xsd new file mode 100644 index 0000000000..be81c20542 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_09.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/9/" xmlns:tns="http://www.example.com/xsd/9/"> + <xs:complexType name="cT_09_parent" abstract="true"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="cT_09_child" final="#all"> + <xs:complexContent> + <xs:extension base="tns:cT_09_parent"> + <xs:sequence> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_10.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_10.xsd new file mode 100644 index 0000000000..b484871a75 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_10.xsd @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/10/" xmlns:tns="http://www.example.com/xsd/10/"> + <xs:complexType name="cT_10_parent"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="cT_10_child" > + <xs:complexContent> + <xs:restriction base="tns:cT_10_parent"> + <xs:sequence> + <xs:element name="id" type="xs:int" minOccurs="1" maxOccurs="1" /> + <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1" /> + </xs:sequence> + </xs:restriction> + </xs:complexContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_10_b.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_10_b.xsd new file mode 100644 index 0000000000..91a5ea2971 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_10_b.xsd @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.com/xsd/10b/" targetNamespace="http://www.example.com/xsd/10b/"> +<xs:complexType name="address_10b"> + <xs:sequence> + <xs:element name="street" type="xs:string" /> + <xs:element name="city" type="xs:string" /> + <xs:element name="zipcode" type="xs:integer" /> + <xs:element name="country" type="xs:string" /> + </xs:sequence> +</xs:complexType> + +<xs:complexType name="USAddress_10b"> + <xs:complexContent> + <xs:restriction base="tns:address_10b"> + <xs:sequence> + <xs:element name="street" type="xs:string" /> + <xs:element name="city" type="xs:string" /> + <xs:element name="zipcode" type="xs:integer" /> + <xs:element name="country" type="xs:string" fixed="US" /> + </xs:sequence> + </xs:restriction> + </xs:complexContent> +</xs:complexType> + +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_11.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_11.xsd new file mode 100644 index 0000000000..19ac8da8ed --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_11.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/11/" xmlns:tns="http://www.example.com/xsd/11/"> + <xs:complexType name="cT_11_parent" abstract="true"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="cT_11_child"> + <xs:complexContent> + <xs:extension base="tns:cT_11_parent"> + <xs:sequence> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_11_b.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_11_b.xsd new file mode 100644 index 0000000000..146f2acbb8 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_11_b.xsd @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.com/xsd/11b/" targetNamespace="http://www.example.com/xsd/11b/"> +<xs:complexType name="address_11b" abstract="true"> + <xs:sequence> + <xs:element name="street" type="xs:string" /> + <xs:element name="city" type="xs:string" /> + </xs:sequence> +</xs:complexType> + +<xs:complexType name="USAddress_11b"> + <xs:complexContent> + <xs:extension base="tns:address_11b"> + <xs:sequence> + <xs:element name="zipcode" type="xs:integer" /> + <xs:element name="country" type="xs:string" fixed="US" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> +</xs:complexType> + +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_17.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_17.xsd new file mode 100644 index 0000000000..cb3c68f8aa --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_17.xsd @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/17/"> + <xs:complexType name="cT_18"> + <xs:simpleContent> + <xs:restriction base="xs:string" /> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_18.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_18.xsd new file mode 100644 index 0000000000..116782df54 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_18.xsd @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.example.com/xsd/18/" + xmlns:tns="http://www.example.com/xsd/18/"> + <xs:element name="cT_18" type="tns:cT_18"/> + <xs:complexType name="cT_18"> + <xs:simpleContent> + <xs:extension base="xs:string" /> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_18a.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_18a.xsd new file mode 100644 index 0000000000..c1f0a46710 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_18a.xsd @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.example.com/xsd/18a/" + xmlns:tns="http://www.example.com/xsd/18a/"> + <xs:element name="cT_18a" type="tns:cT_18a"/> + <xs:complexType name="cT_18a"> + <xs:simpleContent> + <xs:extension base="xs:dateTime" /> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_19.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_19.xsd new file mode 100644 index 0000000000..039f80b492 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_19.xsd @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/19/"> + <xs:complexType name="cT_19"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="lang" type="xs:string"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_20.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_20.xsd new file mode 100644 index 0000000000..903c4caa85 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_20.xsd @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<!-- complexType with simpleContent with restriction with attribute --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/20/"> + <xs:complexType name="cT_20"> + <xs:simpleContent> + <xs:restriction base="xs:string"> + <xs:attribute name="lang" type="xs:string" /> + </xs:restriction> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_21.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_21.xsd new file mode 100644 index 0000000000..87b6d0025f --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_21.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<!-- complexType with simpleContent with restriction with attribute with simpleType --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/21/"> + <xs:complexType name="cT_21"> + <xs:simpleContent> + <xs:restriction base="xs:string"> + <xs:attribute name="lang"> + <xs:simpleType> + <xs:restriction base="xs:string" /> + </xs:simpleType> + </xs:attribute> + </xs:restriction> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_22.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_22.xsd new file mode 100644 index 0000000000..e332046a09 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_22.xsd @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<!-- complexType with simpleContent with extension with attribute --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/22/"> + <xs:complexType name="cT_22"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="lang" type="xs:string" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_23.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_23.xsd new file mode 100644 index 0000000000..a0a6e55830 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_23.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<!-- complexType with simpleContent with extension with attribute with simpleType --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/23/"> + <xs:complexType name="cT_23"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="lang"> + <xs:simpleType> + <xs:restriction base="xs:string" /> + </xs:simpleType> + </xs:attribute> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_24.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_24.xsd new file mode 100644 index 0000000000..a100f0bfbf --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_24.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/24/"> + <xs:complexType name="cT_24"> + <xs:all> + <xs:element name="p1" maxOccurs="1" minOccurs="1" type="xs:string" /> + </xs:all> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_25.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_25.xsd new file mode 100644 index 0000000000..f8b471934a --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_25.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/25/"> + <xs:complexType name="cT_25"> + <xs:sequence> + <xs:element name="p1" maxOccurs="1" minOccurs="1" type="xs:string" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_26.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_26.xsd new file mode 100644 index 0000000000..355f23afd3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_26.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/26/"> + <xs:complexType name="cT_26"> + <xs:sequence> + <xs:element name="p1" maxOccurs="unbounded" minOccurs="0" type="xs:string" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_27.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_27.xsd new file mode 100644 index 0000000000..f233e0e421 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_27.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/27/"> + <xs:complexType name="cT_27"> + <xs:sequence> + <xs:element name="p1" maxOccurs="unbounded" minOccurs="1" type="xs:string" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_28.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_28.xsd new file mode 100644 index 0000000000..2a0bfb7732 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_28.xsd @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<!-- complexType containing an element for each supported data type --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/28/"> + <xs:complexType name="cT_28"> + <xs:sequence> + <xs:element name="type_anySimpleType" type="xs:anySimpleType" /> + <xs:element name="type_anyType" type="xs:anyType" /> + <xs:element name="type_anyURI" type="xs:anyURI" /> + <xs:element name="type_base64Binary" type="xs:base64Binary" /> + <xs:element name="type_boolean" type="xs:boolean" /> + <xs:element name="type_byte" type="xs:byte" /> + <xs:element name="type_date" type="xs:date" /> + <xs:element name="type_dateTime" type="xs:dateTime" /> + <xs:element name="type_decimal" type="xs:decimal" /> + <xs:element name="type_double" type="xs:double" /> + <xs:element name="type_duration" type="xs:duration" /> + <xs:element name="type_ENTITIES" type="xs:ENTITIES" /> + <xs:element name="type_ENTITY" type="xs:ENTITY" /> + <xs:element name="type_float" type="xs:float" /> + <xs:element name="type_gDay" type="xs:gDay" /> + <xs:element name="type_gMonth" type="xs:gMonth" /> + <xs:element name="type_gMonthDay" type="xs:gMonthDay" /> + <xs:element name="type_gYear" type="xs:gYear" /> + <xs:element name="type_gYearMonth" type="xs:gYearMonth" /> + <xs:element name="type_hexBinary" type="xs:hexBinary" /> + <xs:element name="type_ID" type="xs:ID" /> + <xs:element name="type_IDREF" type="xs:IDREF" /> + <xs:element name="type_IDREFS" type="xs:IDREFS" /> + <xs:element name="type_int" type="xs:int" /> + <xs:element name="type_integer" type="xs:integer" /> + <xs:element name="type_language" type="xs:language" /> + <xs:element name="type_long" type="xs:long" /> + <xs:element name="type_Name" type="xs:Name" /> + <xs:element name="type_NCName" type="xs:NCName" /> + <xs:element name="type_negativeInteger" type="xs:negativeInteger" /> + <xs:element name="type_NMTOKEN" type="xs:NMTOKEN" /> + <xs:element name="type_NMTOKENS" type="xs:NMTOKENS" /> + <xs:element name="type_nonNegativeInteger" type="xs:nonNegativeInteger" /> + <xs:element name="type_nonPositiveInteger" type="xs:nonPositiveInteger" /> + <xs:element name="type_QName" type="xs:QName" /> + <xs:element name="type_positiveInteger" type="xs:positiveInteger" /> + <xs:element name="type_short" type="xs:short" /> + <xs:element name="type_string" type="xs:string" /> + <xs:element name="type_time" type="xs:time" /> + <xs:element name="type_token" type="xs:token" /> + <xs:element name="type_unsignedByte" type="xs:unsignedByte" /> + <xs:element name="type_unsignedInt" type="xs:unsignedInt" /> + <xs:element name="type_unsignedLong" type="xs:unsignedLong" /> + <xs:element name="type_unsignedShort" type="xs:unsignedShort" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_29.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_29.xsd new file mode 100644 index 0000000000..ede07debb1 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_29.xsd @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<!-- complexType containing an attribute for each supported data type --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/29/"> + <xs:complexType name="cT_29"> + <xs:attribute name="type_anySimpleType" type="xs:anySimpleType" /> + <xs:attribute name="type_anyURI" type="xs:anyURI" /> + <xs:attribute name="type_base64Binary" type="xs:base64Binary" /> + <xs:attribute name="type_boolean" type="xs:boolean" /> + <xs:attribute name="type_byte" type="xs:byte" /> + <xs:attribute name="type_date" type="xs:date" /> + <xs:attribute name="type_dateTime" type="xs:dateTime" /> + <xs:attribute name="type_decimal" type="xs:decimal" /> + <xs:attribute name="type_double" type="xs:double" /> + <xs:attribute name="type_duration" type="xs:duration" /> + <xs:attribute name="type_ENTITIES" type="xs:ENTITIES" /> + <xs:attribute name="type_ENTITY" type="xs:ENTITY" /> + <xs:attribute name="type_float" type="xs:float" /> + <xs:attribute name="type_gDay" type="xs:gDay" /> + <xs:attribute name="type_gMonth" type="xs:gMonth" /> + <xs:attribute name="type_gMonthDay" type="xs:gMonthDay" /> + <xs:attribute name="type_gYear" type="xs:gYear" /> + <xs:attribute name="type_gYearMonth" type="xs:gYearMonth" /> + <xs:attribute name="type_hexBinary" type="xs:hexBinary" /> + <xs:attribute name="type_ID" type="xs:ID" /> + <xs:attribute name="type_IDREF" type="xs:IDREF" /> + <xs:attribute name="type_IDREFS" type="xs:IDREFS" /> + <xs:attribute name="type_int" type="xs:int" /> + <xs:attribute name="type_integer" type="xs:integer" /> + <xs:attribute name="type_language" type="xs:language" /> + <xs:attribute name="type_long" type="xs:long" /> + <xs:attribute name="type_Name" type="xs:Name" /> + <xs:attribute name="type_NCName" type="xs:NCName" /> + <xs:attribute name="type_negativeInteger" type="xs:negativeInteger" /> + <xs:attribute name="type_NMTOKEN" type="xs:NMTOKEN" /> + <xs:attribute name="type_NMTOKENS" type="xs:NMTOKENS" /> + <xs:attribute name="type_nonNegativeInteger" type="xs:nonNegativeInteger" /> + <xs:attribute name="type_nonPositiveInteger" type="xs:nonPositiveInteger" /> + <xs:attribute name="type_QName" type="xs:QName" /> + <xs:attribute name="type_positiveInteger" type="xs:positiveInteger" /> + <xs:attribute name="type_short" type="xs:short" /> + <xs:attribute name="type_string" type="xs:string" /> + <xs:attribute name="type_time" type="xs:time" /> + <xs:attribute name="type_token" type="xs:token" /> + <xs:attribute name="type_unsignedByte" type="xs:unsignedByte" /> + <xs:attribute name="type_unsignedInt" type="xs:unsignedInt" /> + <xs:attribute name="type_unsignedLong" type="xs:unsignedLong" /> + <xs:attribute name="type_unsignedShort" type="xs:unsignedShort" /> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_30.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_30.xsd new file mode 100644 index 0000000000..bc9dae00e4 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_30.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/30/" xmlns:tns="http://www.example.com/xsd/30/"> + <xs:group name="cT_30_group"> + <xs:sequence> + <xs:element name="p1" type="xs:string" /> + <xs:element name="p2" type="xs:string" /> + </xs:sequence> + </xs:group> + <xs:complexType name="cT_30"> + <xs:sequence> + <xs:group ref="tns:cT_30_group" /> + <xs:element name="p3" type="xs:int" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_31.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_31.xsd new file mode 100644 index 0000000000..d5450624d1 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_31.xsd @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/31/" xmlns:tns="http://www.example.com/xsd/31/"> + <xs:group name="cT_31_group"> + <xs:sequence> + <xs:element name="p1" type="xs:string" /> + <xs:element name="p2" type="xs:string" /> + </xs:sequence> + </xs:group> + <xs:complexType name="cT_31_parent"> + <xs:sequence> + <xs:element name="p4" type="xs:string" /> + <xs:element name="p5" type="xs:string" /> + </xs:sequence> + </xs:complexType> + <xs:complexType name="cT_31"> + <xs:complexContent> + <xs:extension base="tns:cT_31_parent"> + <xs:sequence> + <xs:group ref="tns:cT_31_group" /> + <xs:element name="p3" type="xs:int" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_32.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_32.xsd new file mode 100644 index 0000000000..ca7e155748 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_32.xsd @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/32/" xmlns:tns="http://www.example.com/xsd/32/"> + <xs:group name="cT_32_group"> + <xs:sequence> + <xs:element name="p1" type="xs:string" /> + <xs:element name="p2" type="xs:string" /> + </xs:sequence> + </xs:group> + <xs:complexType name="cT_32_parent"> + <xs:sequence> + <xs:element name="p4" type="xs:string" /> + <xs:element name="p5" type="xs:string" /> + </xs:sequence> + </xs:complexType> + <xs:complexType name="cT_32"> + <xs:complexContent> + <xs:restriction base="tns:cT_32_parent"> + <xs:sequence> + <xs:group ref="tns:cT_32_group" /> + <xs:element name="p3" type="xs:int" /> + </xs:sequence> + </xs:restriction> + </xs:complexContent> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_42.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_42.xsd new file mode 100644 index 0000000000..89cb8e2bc4 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_42.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/42/"> + <xs:complexType name="cT_42" mixed="true"> + <xs:all> + <xs:element name="id" type="xs:int"/> + <xs:element name="name" type="xs:string"/> + </xs:all> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_43.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_43.xsd new file mode 100644 index 0000000000..faed49cc6b --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_43.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/43/"> + <xs:complexType name="cT_43"> + <xs:sequence> + <xs:any maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_44.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_44.xsd new file mode 100644 index 0000000000..da9040ab7d --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_44.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/44/"> + <xs:complexType name="cT_44"> + <xs:sequence> + <xs:any maxOccurs="1" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_45.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_45.xsd new file mode 100644 index 0000000000..f4d3b88ca0 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_45.xsd @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/45/"> + <xs:complexType name="cT_45"> + <xs:anyAttribute /> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_46.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_46.xsd new file mode 100644 index 0000000000..237296a1fb --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_46.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/46/"> + <xs:complexType name="cT_46"> + <xs:sequence> + <xs:element name="id" type="xs:int" /> + <xs:element name="name" type="xs:string" nillable="true"/> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_47.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_47.xsd new file mode 100644 index 0000000000..18b06c6b8c --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_47.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<!-- complexType containing an anySimpletype element --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/47/"> + <xs:complexType name="cT_47"> + <xs:sequence> + <xs:element name="type_anySimpleType" type="xs:anySimpleType" /> + </xs:sequence> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_48.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_48.xsd new file mode 100644 index 0000000000..617ebf5d01 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_48.xsd @@ -0,0 +1,49 @@ +<?xml version="1.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. + --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/xsd/48/"> + + <!-- this schema contains two anonymous types contained within "person" elements --> + + <xsd:complexType name="complextype1"> + <xsd:sequence> + <xsd:element name="person"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="first-name" type="xsd:string"/> + <xsd:element name="last-name" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="complextype2"> + <xsd:sequence> + <xsd:element name="person"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="identifier" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_49.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_49.xsd new file mode 100644 index 0000000000..f11e5474ef --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/complexType/cT_49.xsd @@ -0,0 +1,72 @@ +<?xml version="1.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. + --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.example.com/xsd/49/" + xmlns:tns="http://www.example.com/xsd/49/"> + + + <xsd:complexType name="Base"> + <xsd:sequence> + <xsd:element name="A" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="Derived1"> + <xsd:complexContent> + <xsd:extension base="tns:Base"> + <xsd:sequence> + <xsd:element name="B" type="xsd:string"/> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> + + <xsd:complexType name="Derived2"> + <xsd:complexContent> + <xsd:extension base="tns:Derived1"> + <xsd:sequence> + <xsd:element name="C" type="xsd:string"/> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> + + <xsd:element name="base" type="tns:Base"/> + + <xsd:complexType name="RootType"> + <xsd:sequence> + <xsd:element name="base" type="tns:Base"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="root" type="tns:RootType"/> + + <xsd:complexType name="RootListType"> + <xsd:sequence> + <xsd:element name="base" type="tns:Base" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="rootList" type="tns:RootListType"/> + +</xsd:schema> + + + diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/customer1.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/customer1.xml new file mode 100644 index 0000000000..5a29e30a3c --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/customer1.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="ASCII"?> +<customer:Customer + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:customer="http://example.com/customer" + xsi:type="customer:Customer" + custNum="1" + firstName="John" + lastName="Adams"/>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/customer2.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/customer2.xml new file mode 100644 index 0000000000..e9ebb92677 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/customer2.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="ASCII"?> +<customer:Customer + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:customer="http://example.com/customer" + xsi:type="customer:Customer" + custNum="2" + firstName="Jeremy" + lastName="Pavick"/>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema.xsd new file mode 100644 index 0000000000..03c0ff49f6 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema.xsd @@ -0,0 +1,199 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<xsd:schema + targetNamespace="http://www.example.com/dynamicTypesFromSchema" + xmlns:dtfs="http://www.example.com/dynamicTypesFromSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <!-- + elements and types for testElement0 + provides examples of using XML Schema primitive datatypes (see 3.2 of XML Schema Part 2) + (QName and NOTATION omitted as they are not appropriate as types for element content.) + --> + + <xsd:complexType name="TestType0" mixed="true"> + <xsd:sequence> + <xsd:element name="string" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="boolean" minOccurs="0" maxOccurs="unbounded" type="xsd:boolean"/> + <xsd:element name="decimal" minOccurs="0" maxOccurs="unbounded" type="xsd:decimal"/> + <xsd:element name="float" minOccurs="0" maxOccurs="unbounded" type="xsd:float"/> + <xsd:element name="double" minOccurs="0" maxOccurs="unbounded" type="xsd:double"/> + <xsd:element name="duration" minOccurs="0" maxOccurs="unbounded" type="xsd:duration"/> + <xsd:element name="dateTime" minOccurs="0" maxOccurs="unbounded" type="xsd:dateTime"/> + <xsd:element name="time" minOccurs="0" maxOccurs="unbounded" type="xsd:time"/> + <xsd:element name="date" minOccurs="0" maxOccurs="unbounded" type="xsd:date"/> + <xsd:element name="gYearMonth" minOccurs="0" maxOccurs="unbounded" type="xsd:gYearMonth"/> + <xsd:element name="gYear" minOccurs="0" maxOccurs="unbounded" type="xsd:gYear"/> + <xsd:element name="gMonthDay" minOccurs="0" maxOccurs="unbounded" type="xsd:gMonthDay"/> + <xsd:element name="gDay" minOccurs="0" maxOccurs="unbounded" type="xsd:gDay"/> + <xsd:element name="gMonth" minOccurs="0" maxOccurs="unbounded" type="xsd:gMonth"/> + <xsd:element name="hexBinary" minOccurs="0" maxOccurs="unbounded" type="xsd:hexBinary"/> + <xsd:element name="base64Binary" minOccurs="0" maxOccurs="unbounded" type="xsd:base64Binary"/> + <xsd:element name="anyURI" minOccurs="0" maxOccurs="unbounded" type="xsd:anyURI"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="testElement0" type="dtfs:TestType0"/> + + <!-- + elements and types for testElement1 + provides examples of using XML Schema derived datatypes (see 3.3 of XML Schema Part 2) + (ENTITY and ENTITIES omitted as they are not appropriate as types for element content.) + --> + + <xsd:complexType name="TestType1" mixed="true"> + <xsd:sequence> + <xsd:element name="normalizedString" minOccurs="0" maxOccurs="unbounded" type="xsd:normalizedString"/> + <xsd:element name="token" minOccurs="0" maxOccurs="unbounded" type="xsd:token"/> + <xsd:element name="language" minOccurs="0" maxOccurs="unbounded" type="xsd:language"/> + <xsd:element name="NMTOKEN" minOccurs="0" maxOccurs="unbounded" type="xsd:NMTOKEN"/> + <xsd:element name="NMTOKENS" minOccurs="0" maxOccurs="unbounded" type="xsd:NMTOKENS"/> + <xsd:element name="Name" minOccurs="0" maxOccurs="unbounded" type="xsd:Name"/> + <xsd:element name="NCName" minOccurs="0" maxOccurs="unbounded" type="xsd:NCName"/> + <xsd:element name="ID" minOccurs="0" maxOccurs="unbounded" type="xsd:ID"/> + <xsd:element name="IDREF" minOccurs="0" maxOccurs="unbounded" type="xsd:IDREF"/> + <xsd:element name="IDREFS" minOccurs="0" maxOccurs="unbounded" type="xsd:IDREFS"/> + <xsd:element name="integer" minOccurs="0" maxOccurs="unbounded" type="xsd:integer"/> + <xsd:element name="nonPositiveInteger" minOccurs="0" maxOccurs="unbounded" type="xsd:nonPositiveInteger"/> + <xsd:element name="negativeInteger" minOccurs="0" maxOccurs="unbounded" type="xsd:negativeInteger"/> + <xsd:element name="long" minOccurs="0" maxOccurs="unbounded" type="xsd:long"/> + <xsd:element name="int" minOccurs="0" maxOccurs="unbounded" type="xsd:int"/> + <xsd:element name="short" minOccurs="0" maxOccurs="unbounded" type="xsd:short"/> + <xsd:element name="byte" minOccurs="0" maxOccurs="unbounded" type="xsd:byte"/> + <xsd:element name="nonNegativeInteger" minOccurs="0" maxOccurs="unbounded" type="xsd:nonNegativeInteger"/> + <xsd:element name="unsignedLong" minOccurs="0" maxOccurs="unbounded" type="xsd:unsignedLong"/> + <xsd:element name="unsignedInt" minOccurs="0" maxOccurs="unbounded" type="xsd:unsignedInt"/> + <xsd:element name="unsignedShort" minOccurs="0" maxOccurs="unbounded" type="xsd:unsignedShort"/> + <xsd:element name="unsignedByte" minOccurs="0" maxOccurs="unbounded" type="xsd:unsignedByte"/> + <xsd:element name="positiveInteger" minOccurs="0" maxOccurs="unbounded" type="xsd:positiveInteger"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="testElement1" type="dtfs:TestType1"/> + + <!-- + elements and types for testElement2 + provides examples of deriving new types by restriction + --> + + <xsd:simpleType name="month"> + <xsd:restriction base="xsd:int"> + <xsd:minInclusive value="1"/> + <xsd:maxInclusive value="12"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="status"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="unspecified"/> + <xsd:enumeration value="Good"/> + <xsd:enumeration value="Indifferent"/> + <xsd:enumeration value="Bad"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="smallOddNumber"> + <xsd:restriction base="xsd:int"> + <xsd:enumeration value="1"/> + <xsd:enumeration value="3"/> + <xsd:enumeration value="5"/> + <xsd:enumeration value="7"/> + <xsd:enumeration value="9"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="oddOrEvenDigits"> + <xsd:restriction base="xsd:int"> + <xsd:pattern value="[13579]*"/> + <xsd:pattern value="[02468]*"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="evenNumberOfOddOrEvenDigits"> + <xsd:restriction base="dtfs:oddOrEvenDigits"> + <xsd:pattern value="(..)*"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="smallBigDecimal"> + <xsd:restriction base="xsd:decimal"> + <xsd:totalDigits value="10"/> + <xsd:fractionDigits value="2"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="smallBigInteger"> + <xsd:restriction base="xsd:integer"> + <xsd:totalDigits value="10"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="smallInt"> + <xsd:restriction base="xsd:int"> + <xsd:totalDigits value="2"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="monthList"> + <xsd:list itemType="dtfs:month"/> + </xsd:simpleType> + + <xsd:simpleType name="statusOrMonthList"> + <xsd:union memberTypes="dtfs:status dtfs:monthList"/> + </xsd:simpleType> + + <xsd:complexType name="Address"> + <xsd:attribute name="ip" type="xsd:ID"/> + </xsd:complexType> + + <xsd:complexType name="Component"> + <xsd:sequence> + <xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="from" use="required" type="xsd:IDREF"/> + <xsd:attribute name="to" use="required" type="xsd:IDREFS"/> + <xsd:attribute name="cc" type="xsd:IDREFS"/> + <xsd:attribute name="bcc" type="xsd:IDREFS"/> + <xsd:attribute name="status" type="dtfs:status"/> + </xsd:complexType> + + <xsd:complexType name="TestType2" mixed="true"> + <xsd:sequence> + <xsd:element name="smallBigDecimal" minOccurs="0" type="dtfs:smallBigDecimal"/> + <xsd:element name="smallBigInteger" minOccurs="0" type="dtfs:smallBigInteger"/> + <xsd:element name="smallInt" minOccurs="0" type="dtfs:smallInt"/> + <xsd:element name="wierdNumber" minOccurs="0" type="dtfs:evenNumberOfOddOrEvenDigits" default="11"/> + <xsd:element name="smallOddNumber" minOccurs="0" type="dtfs:smallOddNumber"/> + <xsd:element name="headerValue" nillable="true" minOccurs="0" type="xsd:int"/> + <xsd:element name="overallStatus" nillable="true" minOccurs="0" type="dtfs:status"/> + <xsd:element name="addresses" minOccurs="1" maxOccurs="unbounded" type="dtfs:Address"/> + <xsd:element name="components" minOccurs="1" maxOccurs="unbounded" type="dtfs:Component"/> + <xsd:element name="item" type="xsd:IDREF"/> + <xsd:element name="items" maxOccurs="unbounded" type="xsd:IDREF"/> + <xsd:element name="cluster" type="xsd:IDREFS"/> + <xsd:element name="clusters" maxOccurs="unbounded" type="xsd:IDREFS"/> + <xsd:element name="statusOrMonthList" minOccurs="0" maxOccurs="unbounded" type="dtfs:statusOrMonthList"/> + <xsd:element ref="dtfs:nCName" minOccurs="0" maxOccurs="unbounded"/> + <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="nCName" type="xsd:NCName"/> + + <xsd:element name="testElement2" type="dtfs:TestType2"/> + +</xsd:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema0.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema0.xml new file mode 100644 index 0000000000..9231f057cf --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema0.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<dtfs:testElement0 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:dtfs="http://www.example.com/dynamicTypesFromSchema" + xsi:schemaLocation="http://www.example.com/dynamicTypesFromSchema dynamicTypesFromSchema.xsd"> + <string>This is a string. Multiple spaces are preserved.</string> + <boolean>true</boolean> + <boolean>false</boolean> + <boolean>true</boolean> + <boolean>1</boolean> + <boolean>0</boolean> + <decimal>-1.23</decimal> + <decimal>12678967.543233</decimal> + <decimal>+100000.00</decimal> + <decimal>210</decimal> + <float>0</float> + <float>-0</float> +<!-- <float>INF</float> --> + <float>NaN</float> +<!-- <float>-INF</float> --> + <float>-1E4</float> + <float>1267.43233E12</float> + <float>12.78e-2</float> + <float>12</float> + <double>0</double> + <double>-0</double> +<!-- <double>INF</double> --> + <double>NaN</double> +<!-- <double>-INF</double> --> + <double>-1E4</double> + <double>1267.43233E200</double> + <double>12.78e-150</double> + <double>12</double> + <duration>P1Y2M3DT10H30M5S</duration> + <duration>-P120D</duration> + <dateTime>1999-05-31T13:20:00-05:00</dateTime> + <dateTime>2000-01-20T12:00:00</dateTime> + <dateTime>2000-01-20T12:00:00Z</dateTime> + <time>13:20:00-05:00</time> + <time>12:00:00</time> + <time>12:00:00Z</time> + <date>2007-02-01</date> + <date>1990-12-31</date> + <date>1990-12-31-05:00</date> + <date>1990-12-31Z</date> + <gYearMonth>1990-12</gYearMonth> + <gYearMonth>1990-12-05:00</gYearMonth> + <gYearMonth>1990-12Z</gYearMonth> + <gYear>1990</gYear> + <gYear>1990-05:00</gYear> + <gYear>1990Z</gYear> + <gMonthDay>--12-31</gMonthDay> + <gMonthDay>--12-31-05:00</gMonthDay> + <gMonthDay>--12-31Z</gMonthDay> + <gDay>---31</gDay> + <gDay>---31-05:00</gDay> + <gDay>---31Z</gDay> + <gMonth>--12--</gMonth> + <gMonth>--12---05:00</gMonth> + <gMonth>--12--Z</gMonth> + <hexBinary>0FB7</hexBinary> + <base64Binary>GpM7</base64Binary> + <anyURI>http://www.example.com/dynamicTypesFromSchema</anyURI> +</dtfs:testElement0> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema1.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema1.xml new file mode 100644 index 0000000000..f7f059fc21 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema1.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<dtfs:testElement1 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:dtfs="http://www.example.com/dynamicTypesFromSchema" + xsi:schemaLocation="http://www.example.com/dynamicTypesFromSchema dynamicTypesFromSchema.xsd"> + <normalizedString>a string without CR or TAB characters</normalizedString> + <token>a normalizedString without leading or trailing or multiple internal blanks</token> + <language>en-US</language> + <NMTOKEN>a-sequeunce:of.XML_NameChar_characters</NMTOKEN> + <NMTOKENS>one or more NMTOKEN items separated with single spaces</NMTOKENS> + <Name>A_letter_underscore_or_colon_optionally_followed_by_NameChar_characters</Name> + <NCName>a_Name_without_colons</NCName> + <ID>an_NCName_for_ID_attribute</ID> + <IDREF>an_NCName_for_ID_attribute</IDREF> + <IDREFS>an_NCName_for_ID_attribute an_NCName_for_ID_attribute</IDREFS> + <integer>92233720368547758079223372036854775807</integer> + <integer>0</integer> + <integer>-92233720368547758089223372036854775808</integer> + <nonPositiveInteger>0</nonPositiveInteger> + <nonPositiveInteger>-92233720368547758089223372036854775808</nonPositiveInteger> + <negativeInteger>-1</negativeInteger> + <negativeInteger>-92233720368547758089223372036854775808</negativeInteger> + <long>9223372036854775807</long> + <long>0</long> + <long>-9223372036854775808</long> + <int>2147483647</int> + <int>1</int> + <int>-2147483648</int> + <short>32767</short> + <short>0</short> + <short>-32768</short> + <byte>127</byte> + <byte>0</byte> + <byte>-128</byte> + <nonNegativeInteger>92233720368547758079223372036854775807</nonNegativeInteger> + <nonNegativeInteger>0</nonNegativeInteger> + <unsignedLong>18446744073709551615</unsignedLong> + <unsignedLong>0</unsignedLong> + <unsignedInt>4294967295</unsignedInt> + <unsignedInt>0</unsignedInt> + <unsignedShort>65535</unsignedShort> + <unsignedShort>0</unsignedShort> + <unsignedByte>255</unsignedByte> + <unsignedByte>0</unsignedByte> + <positiveInteger>92233720368547758079223372036854775807</positiveInteger> + <positiveInteger>1</positiveInteger> +</dtfs:testElement1> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema2.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema2.xml new file mode 100644 index 0000000000..f13f9554fc --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/dynamicTypesFromSchema2.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<dtfs:testElement2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:dtfs="http://www.example.com/dynamicTypesFromSchema" + xmlns:notest="http://www.example.com/notChecked" + xsi:schemaLocation="http://www.example.com/dynamicTypesFromSchema dynamicTypesFromSchema.xsd"> + <smallBigDecimal>99999999.88</smallBigDecimal> + <smallBigInteger>8888888888</smallBigInteger> + <smallInt>77</smallInt> + <wierdNumber>1111</wierdNumber> + <smallOddNumber>3</smallOddNumber> + <headerValue xsi:nil="true"/> + <overallStatus xsi:nil="true"/> + <addresses ip="IP.255.255.255.0"/> + <addresses ip="IP.255.255.255.1"/> + <addresses ip="IP.255.255.255.255"/> + <components from="IP.255.255.255.255" status="Good" to="IP.255.255.255.255"/> + <components from="IP.255.255.255.255" status="Indifferent" to="IP.255.255.255.0"/> + <components cc="IP.255.255.255.1" from="IP.255.255.255.255" status="Bad" + to="IP.255.255.255.255"/> + <components bcc="IP.255.255.255.1" from="IP.255.255.255.255" status="unspecified" + to="IP.255.255.255.255"/> + <item>IP.255.255.255.0</item> + <items>IP.255.255.255.1</items> + <items>IP.255.255.255.255</items> + <cluster>IP.255.255.255.0 IP.255.255.255.1</cluster> + <clusters>IP.255.255.255.0 IP.255.255.255.1</clusters> + <clusters>IP.255.255.255.0 IP.255.255.255.1</clusters> + <statusOrMonthList>1 5 12</statusOrMonthList> + <statusOrMonthList>Indifferent</statusOrMonthList> + <dtfs:nCName>A_Non_Colon_Name</dtfs:nCName> + <notest:otherTag statusOrMonthList="1 7 25">The testing of this element is lax.</notest:otherTag> +</dtfs:testElement2> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/mixed2.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/mixed2.xml new file mode 100644 index 0000000000..d95d179478 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/mixed2.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="ASCII"?> +<mixed:mixedStockQuote + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:mixed="http://www.example.com/mixed" + xsi:type="mixed:MixedQuote"> + <symbol>fbnt</symbol> + <companyName>FlyByNightTechnology</companyName> + some text + <quotes><price>2000.0</price></quotes> + more text + <price>1000.0</price> +</mixed:mixedStockQuote>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/mixedopen.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/mixedopen.xml new file mode 100644 index 0000000000..21a62ef2d0 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/mixedopen.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="ASCII"?> +<mixed:mixedOpenStockQuote + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:mixed="http://www.example.com/mixed" + xmlns:open="http://www.example.com/open" + xsi:type="mixed:MixedOpenQuote"> + <open:symbol>fbnt</open:symbol> + <companyName>FlyByNightTechnology</companyName> + some text + <quotes><price>2000.0</price></quotes> + more text + <price>1000.0</price> +</mixed:mixedOpenStockQuote> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/open.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/open.xsd new file mode 100644 index 0000000000..9a52536efe --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/open.xsd @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. + --> +<xsd:schema xmlns:open="http://www.example.com/open" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/open"> + + <xsd:element name="openStockQuote" type="open:OpenQuote"/> + + <xsd:element name="price" type="xsd:decimal"/> + + <xsd:element name="company"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="name" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="OpenQuote"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:any maxOccurs="unbounded" namespace="##any"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="OpenQuote2"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:any maxOccurs="1" namespace="##any"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/openContentProperty.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/openContentProperty.xml new file mode 100644 index 0000000000..68f4c116eb --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/openContentProperty.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="ASCII"?> +<open:openStockQuote xmlns:open="http://www.example.com/open"> + <symbol>s1</symbol> + <open:company> + <name>FlyByNightTechnology</name> + </open:company> + <open:price>1000.0</open:price> + <open:highPrice>1100.0</open:highPrice> + <open:mutualFundQuote> + <symbol>mutual-1</symbol> + </open:mutualFundQuote> +</open:openStockQuote>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/sampleSDOSchema/Person.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/sampleSDOSchema/Person.xsd new file mode 100644 index 0000000000..6993508285 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/sampleSDOSchema/Person.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:person="http://www.example.com/person" + xmlns:sdo="commonj.sdo" + targetNamespace="http://www.example.com/person"> + + <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/> + + + +</xsd:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simple.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simple.xsd new file mode 100644 index 0000000000..5310f7e1f3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simple.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<xsd:schema + targetNamespace="http://www.example.com/simple" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:simple="http://www.example.com/simple"> + + <xsd:element name="stockQuote" type="simple:Quote"/> + + <xsd:complexType name="Quote"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:element name="companyName" type="xsd:string"/> + <xsd:element name="price" type="xsd:decimal"/> + <xsd:element name="open1" type="xsd:decimal"/> + <xsd:element name="high" type="xsd:decimal"/> + <xsd:element name="low" type="xsd:decimal"/> + <xsd:element name="volume" type="xsd:double"/> + <xsd:element name="change1" type="xsd:double"/> + <xsd:element name="quotes" type="simple:Quote" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/annotation.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/annotation.xsd new file mode 100644 index 0000000000..3da238c980 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/annotation.xsd @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/annotation/"> + <xs:simpleType name="simpleTypeAnnotated"> + <xs:annotation> + <xs:documentation>This is a test case for simpleType containing an annotation</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:length value="50" /> + </xs:restriction> + </xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/anonymous.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/anonymous.xsd new file mode 100644 index 0000000000..7cd7bf8413 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/anonymous.xsd @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/anonymous"> + <xs:element name="simpleTypeAnon"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:length value="50" /> + </xs:restriction> + </xs:simpleType> + </xs:element> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derived.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derived.xsd new file mode 100644 index 0000000000..7bf074f700 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derived.xsd @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.example.com/simpleType/derived" targetNamespace="http://www.example.com/simpleType/derived"> + <xs:simpleType name="baseType"> + <xs:restriction base="xs:integer"> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="derivedType"> + <xs:restriction base="ns1:baseType"/> + </xs:simpleType> +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derived2.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derived2.xsd new file mode 100644 index 0000000000..41efe54e70 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derived2.xsd @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.example.com/simpleType/derived2" targetNamespace="http://www.example.com/simpleType/derived2"> + <xs:simpleType name="baseType" final="list"> + <xs:restriction base="xs:integer"> + + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="derivedType"> + <xs:restriction base="ns1:baseType"/> + </xs:simpleType> +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derivedUnion.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derivedUnion.xsd new file mode 100644 index 0000000000..101115e8fd --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/derivedUnion.xsd @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.example.com/simpleType/derivedUnion" targetNamespace="http://www.example.com/simpleType/derivedUnion"> + <xs:attribute name="fontsize"> + <xs:simpleType> + <xs:union memberTypes="ns1:fontbynumber ns1:fontbystringname" /> + </xs:simpleType> +</xs:attribute> + +<xs:simpleType name="fontbynumber"> + <xs:restriction base="xs:positiveInteger"> + <xs:maxInclusive value="72"/> + </xs:restriction> +</xs:simpleType> + +<xs:simpleType name="fontbystringname"> + <xs:restriction base="xs:string"> + <xs:enumeration value="small"/> + <xs:enumeration value="medium"/> + <xs:enumeration value="large"/> + </xs:restriction> +</xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/enumeration.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/enumeration.xsd new file mode 100644 index 0000000000..cadffc1a78 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/enumeration.xsd @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.example.com/simpleType/enumeration" targetNamespace="http://www.example.com/simpleType/enumeration"> + <xs:element name="thing" type="ns1:thing"/> + <xs:complexType name="thing"> + <xs:sequence> + <xs:element name="sizeofthing"> + <xs:simpleType> + <xs:restriction base="ns1:size"/> + </xs:simpleType> + </xs:element> + <xs:element name="colorofthing"> + <xs:simpleType> + <xs:restriction base="ns1:color"/> + </xs:simpleType> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="color" id="clr"> + <xs:restriction base="xs:string"> + <xs:enumeration value="red"/> + <xs:enumeration value="green"/> + <xs:enumeration value="blue"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="size"> + <xs:restriction base="xs:integer"> + <xs:minInclusive value="1" fixed="true"/> + <xs:maxInclusive value="10" fixed="true"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalList.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalList.xsd new file mode 100644 index 0000000000..7575a3c6c9 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalList.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/finalList"> + <xs:simpleType name="simpleTypeFinalList" final="list"> + <xs:restriction base="xs:string"> + <xs:length value="50" /> + </xs:restriction> + </xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalRestriction.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalRestriction.xsd new file mode 100644 index 0000000000..ca35b1c488 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalRestriction.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/finalRestriction"> + <xs:simpleType name="simpleTypeFinalRestriction" final="restriction"> + <xs:restriction base="xs:string"> + <xs:length value="50" /> + </xs:restriction> + </xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalUnion.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalUnion.xsd new file mode 100644 index 0000000000..ce28a8d50d --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/finalUnion.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/finalUnion"> + <xs:simpleType name="simpleTypeFinalUnion" final="union"> + <xs:restriction base="xs:string"> + <xs:length value="50" /> + </xs:restriction> + </xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/list.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/list.xsd new file mode 100644 index 0000000000..aeaf934ad4 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/list.xsd @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/list"> + <xs:simpleType name="simpleTypeList"> + <xs:list itemType="xs:string" /> + </xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/restriction.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/restriction.xsd new file mode 100644 index 0000000000..45670e9084 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/restriction.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/restriction"> + <xs:simpleType name="simpleTypeRestriction"> + <xs:restriction base="xs:string"> + <xs:length value="50" /> + </xs:restriction> + </xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/union.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/union.xsd new file mode 100644 index 0000000000..394b802c00 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleType/union.xsd @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + * 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. + --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simpleType/union"> + <xs:simpleType name="simpleTypeUnion"> + <xs:union memberTypes="xs:int xs:string" /> + </xs:simpleType> +</xs:schema>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummary.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummary.xml new file mode 100644 index 0000000000..2f29fc00f0 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummary.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="ASCII"?> +<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS"> + <symbol>FBNT</symbol> + <companyName>FlyByNightTechnology</companyName> + <price>999.0</price> + <volume>1000.0</volume> + <quotes> + <price>1500.0</price> + </quotes> + <quotes> + <price>2500.0</price> + </quotes> + <quotes> + <price>3000.0</price> + </quotes> + <quotes> + <price>4000.0</price> + </quotes> + <changes create="#//quotes[3] #//quotes[4]" delete="#//changes/stockQuote[1]/quotes[2]" logging="false" xmlns:sdo="commonj.sdo"> + <cs:stockQuote sdo:ref="#/stockQuote" sdo:unset="volume"> + <symbol>fbnt</symbol> + <price>1000.0</price> + <quotes sdo:ref="#//quotes[1]" /> + <quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes> + <quotes sdo:ref="#//quotes[2]" /> + </cs:stockQuote> + </changes> +</cs:stockQuote>
\ No newline at end of file diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummary.xsd b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummary.xsd new file mode 100644 index 0000000000..1df0f69196 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummary.xsd @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + --> +<xsd:schema xmlns:sdo="commonj.sdo" xmlns:cs="http://www.example.com/simpleCS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://www.example.com/simpleCS"> + + + <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/> + + <xsd:complexType name="RootQuote"> + <xsd:complexContent> + <xsd:extension base="cs:Quote"> + <xsd:sequence> + <xsd:element name="changes" type="sdo:ChangeSummaryType"/> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> + + </xsd:complexType> + + <xsd:element name="stockQuote" type="cs:RootQuote"/> + + <xsd:complexType name="Quote"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:element name="companyName" type="xsd:string"/> + <xsd:element name="price" type="xsd:decimal"/> + <xsd:element name="open1" type="xsd:decimal"/> + <xsd:element name="high" type="xsd:decimal"/> + <xsd:element name="low" type="xsd:decimal"/> + <xsd:element name="volume" type="xsd:double"/> + <xsd:element name="change1" type="xsd:double"/> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes" type="cs:Quote"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummaryUndone.xml b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummaryUndone.xml new file mode 100644 index 0000000000..a9c675b6c3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/resources/simpleWithChangeSummaryUndone.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="ASCII"?> +<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS"> + <symbol>fbnt</symbol> + <companyName>FlyByNightTechnology</companyName> + <price>1000.0</price> + <quotes> + <price>1500.0</price> + </quotes> + <quotes> + <price>2000.0</price> + <quotes> + <price>2000.99</price> + </quotes> + </quotes> + <quotes> + <price>2500.0</price> + </quotes> + <changes logging="false" /> +</cs:stockQuote>
\ No newline at end of file |