summaryrefslogtreecommitdiffstats
path: root/sdo-java/branches/emf-2.5/tools-test/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'sdo-java/branches/emf-2.5/tools-test/src/test/java')
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/AllTests.java57
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java131
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java99
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java96
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java115
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java102
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InternalInElementTestCase.java63
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ListWithDefaultTestCase.java53
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java86
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java75
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java110
-rw-r--r--sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SubstitutionWithExtensionValuesTestCase.java155
12 files changed, 1142 insertions, 0 deletions
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/AllTests.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
new file mode 100644
index 0000000000..7c10cb2c62
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/AllTests.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.
+ */
+
+package org.apache.tuscany.sdo.test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class AllTests extends TestCase {
+
+
+ public static TestSuite suite() {
+
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(ChangeSummaryGenTestCase.class);
+ suite.addTestSuite(ExtensibleTestCase.class);
+ suite.addTestSuite(GenPatternsTestCase.class);
+ suite.addTestSuite(InheritanceTestCase.class);
+ suite.addTestSuite(OpenContentTestCase.class);
+ suite.addTestSuite(SimpleStaticTestCase.class);
+ suite.addTestSuite(MixedTypesTestCase.class);
+ suite.addTestSuite(DataObjectGetListTestCase.class);
+ suite.addTestSuite(ListWithDefaultTestCase.class);
+ suite.addTestSuite(SubstitutionWithExtensionValuesTestCase.class);
+ suite.addTestSuite(InternalInElementTestCase.class);
+ return suite;
+ }
+
+
+
+ /**
+ * Runs the test suite using the textual runner.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+}
+
+
+
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java
new file mode 100644
index 0000000000..37759458b9
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java
@@ -0,0 +1,131 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import junit.framework.TestCase;
+
+import com.example.customer.Account;
+import com.example.customer.Customer;
+import com.example.customer.CustomerFactory;
+import com.example.simple.cs.CSFactory;
+import com.example.simple.cs.Quote;
+import com.example.simple.cs.QuoteBase;
+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 ChangeSummaryGenTestCase extends TestCase {
+
+ public void testMixedQuoteType() throws IOException {
+ QuoteBase quote = CSFactory.INSTANCE.createQuoteBase();
+ DataObject dQuote = (DataObject)quote;
+
+ // ChangeSummary csp = quote.getChanges();
+ ChangeSummary cs = dQuote.getChangeSummary();
+ ChangeSummary csp = quote.getChanges();
+ cs.beginLogging();
+
+ assertSame(cs, csp);
+
+ quote.setSymbol("fbnt");
+ quote.setCompanyName("FlyByNightTechnology");
+ quote.setPrice(new BigDecimal("1000.0"));
+ quote.setOpen1(new BigDecimal("1000.0"));
+ quote.setHigh(new BigDecimal("1000.0"));
+ quote.setLow(new BigDecimal("1000.0"));
+ quote.setVolume(1000);
+ quote.setChange1(1000);
+
+ List quotes = quote.getQuotes();
+ Quote innerQuote = CSFactory.INSTANCE.createQuote();
+
+ quotes.add(innerQuote);
+ innerQuote.setPrice(new BigDecimal("2000.0"));
+
+ cs.endLogging();
+
+ //XMLHelper.INSTANCE.save(dQuote, "http://www.example.com/simpleCS", "quoteBase", System.out);
+
+ cs.undoChanges();
+
+ //System.out.println("\nAfter Undo Changes:");
+ //XMLHelper.INSTANCE.save(dQuote, "http://www.example.com/simpleCS", "quoteBase", System.out);
+ }
+
+ public void testChangeSummaryOnDatagraphWithContainmentStatic() throws Exception {
+
+ HelperContext hc = HelperProvider.getDefaultContext();
+ CustomerFactory.INSTANCE.register(hc);
+
+ Type customerType = hc.getTypeHelper().getType(Customer.class);
+ DataGraph dataGraph = SDOUtil.createDataGraph();
+ Customer customer = (Customer) dataGraph.createRootObject(customerType);
+
+ Account account = CustomerFactory.INSTANCE.createAccount();
+ customer.setAccount(account);
+ customer.setFirstName("John");
+ customer.getAccount().setAccountNum(1234);
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ SDOUtil.saveDataGraph(dataGraph, outputStream, null);
+ DataGraph loadDataGraph = SDOUtil.loadDataGraph(new ByteArrayInputStream(outputStream.toByteArray()), null);
+
+ loadDataGraph.getChangeSummary().beginLogging();
+
+ customer = (Customer) loadDataGraph.getRootObject();
+ customer.getAccount().setAccountNum(987);
+
+ loadDataGraph.getChangeSummary().endLogging();
+
+ List changedDataObjects = loadDataGraph.getChangeSummary().getChangedDataObjects();
+ assertEquals("in fact 1 Object was changed in the code", 1, changedDataObjects.size());
+ }
+
+ public void testChangeSummaryOnDataGraphWithIntAndFloat() throws Exception {
+
+ HelperContext hc = HelperProvider.getDefaultContext();
+ CustomerFactory factory = CustomerFactory.INSTANCE;
+ factory.register(hc);
+ Customer customer = factory.createCustomer();
+ Account account = factory.createAccount();
+ customer.setAccount(account);
+ DataObject customerDO = (DataObject) customer;
+ DataGraph dg = SDOUtil.createDataGraph();
+ SDOUtil.setRootObject(dg, customerDO);
+ dg.getChangeSummary().beginLogging();
+ dg.getRootObject().getDataObject(0).delete();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.saveDataGraph(dg, baos, null);
+ }
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java
new file mode 100644
index 0000000000..b6650cade3
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java
@@ -0,0 +1,99 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.get.list.ListFactory;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import junit.framework.TestCase;
+
+public class DataObjectGetListTestCase extends TestCase {
+ private HelperContext hc;
+ private DataObject companyDataObject;
+
+ private final String TEST_NAMESPACE = "http://www.example.com/getList";
+
+
+ /**
+ * Test DataObject.getList() on open type
+ */
+ public void testUnknownPropertyOnOpenType() throws IOException {
+ String companyName = companyDataObject.getString("openCompany/company");
+ assertEquals(companyName, "OpenCompany");
+ List unknownProperty = companyDataObject.getList("openCompany/unknownProperty");
+ assertNotNull(unknownProperty);
+ assertTrue(unknownProperty instanceof List);
+
+ List unknownProperty2 = companyDataObject.getList("openCompany/unknownProperty");
+ assertNotNull(unknownProperty2);
+ assertTrue(unknownProperty2 instanceof List);
+
+ // unknownProperty and unknownProperty2 are in fact the same value for the same property
+
+ unknownProperty.add("employee1");
+ assertTrue(unknownProperty.size() == 1);
+
+ unknownProperty2.add("employee2");
+ assertTrue(unknownProperty2.size() == 2);
+
+ unknownProperty.remove(0);
+ assertTrue(unknownProperty.size() == 1);
+
+ assertEquals(unknownProperty.get(0), "employee2");
+ }
+
+ /**
+ * Test DataObject.getList() on non-open type
+ */
+ public void testUnknownPropertyOnClosedType() throws IOException {
+ String companyName = companyDataObject.getString("closeCompany/company");
+ assertEquals(companyName, "CloseCompany");
+ List unknownProperty = companyDataObject.getList("closeCompany/unknownProperty");
+ assertNotNull(unknownProperty);
+ assertTrue(unknownProperty instanceof List);
+
+ try {
+ unknownProperty.add("employee1");
+ fail("An exception should have been thrown.");
+ }
+ catch (Exception e) {
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hc = SDOUtil.createHelperContext();
+ ListFactory.INSTANCE.register(hc);
+
+ companyDataObject = hc.getDataFactory().create(TEST_NAMESPACE, "Company");
+ DataObject openCompany = companyDataObject.createDataObject("openCompany");
+ openCompany.setString("company", "OpenCompany");
+ DataObject closeCompany = companyDataObject.createDataObject("closeCompany");
+ closeCompany.setString("company", "CloseCompany");
+ }
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
new file mode 100644
index 0000000000..c9cc384beb
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
@@ -0,0 +1,96 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.extensible.customer.CustomerFactory;
+import com.example.extensible.customer.CustomersType;
+import com.example.extensible.customer.InfoType;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+public class ExtensibleTestCase extends TestCase {
+
+ private final String[] MODELS = new String[] {
+ "/extensible/nonamespace.xsd",
+ "/extensible/infostreet.xsd",
+ "/extensible/infozipcode.xsd"
+ };
+
+ private final String CUSTOMERS_XML = "/extensible/customers.xml";
+ private final String INFOSTREET_XML = "/extensible/infostreet.xml";
+ private final String INFOZIPCODE_XML = "/extensible/infozipcode.xml";
+
+ private HelperContext scope;
+
+ public void testCustomersLoad() throws IOException {
+ XMLDocument doc = scope.getXMLHelper().load(
+ getClass().getResourceAsStream(CUSTOMERS_XML));
+ assertEquals("customers", doc.getRootElementName());
+ assertTrue("RootObject of " + CUSTOMERS_XML + " should be instanceof CustomersType",
+ doc.getRootObject() instanceof CustomersType);
+ String strdoc = scope.getXMLHelper().save(
+ doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName());
+ assertTrue(strdoc.indexOf("<street>341 Duckworth Way</street>") != -1);
+ }
+
+ public void testInfoLoad() throws IOException {
+ String[] infoXmls = new String[] {INFOSTREET_XML, INFOZIPCODE_XML};
+ for (int i = 0; i < infoXmls.length; i++) {
+ String infoXml = infoXmls[i];
+ XMLDocument doc = scope.getXMLHelper().load(
+ getClass().getResourceAsStream(infoXml));
+ assertEquals("info", doc.getRootElementName());
+ assertTrue("RootObject of " + infoXml + " should be instanceof InfoType",
+ doc.getRootObject() instanceof InfoType);
+ String strdoc = scope.getXMLHelper().save(
+ doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName());
+ String elementName = (i == 0) ? "street" : "zipcode";
+ String valuePrefix = "21043";
+ assertTrue(strdoc.indexOf("<" + elementName + ">") != -1);
+ assertTrue(strdoc.indexOf("</" + elementName + ">") != -1);
+ assertTrue(strdoc.indexOf(">" + valuePrefix) != -1);
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scope = SDOUtil.createHelperContext();
+
+ CustomerFactory.INSTANCE.register(scope);
+
+ // Populate the meta data for the models
+ for (int i = 0; i < MODELS.length; i++) {
+ String model = MODELS[i];
+ URL url = getClass().getResource(model);
+ InputStream inputStream = url.openStream();
+ scope.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ }
+ }
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
new file mode 100644
index 0000000000..e63697738e
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
@@ -0,0 +1,115 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.math.BigDecimal;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.simple.SimpleFactory;
+import commonj.sdo.helper.HelperContext;
+
+
+public class GenPatternsTestCase extends TestCase
+{
+ /**
+ * Simple Default Generation Pattern Static SDO 2.1 test.
+ */
+ public void testSimpleDefaultGeneratedClasses()
+ {
+ try
+ {
+ HelperContext scope = SDOUtil.createHelperContext();
+ com.example.simple.SimpleFactory.INSTANCE.register(scope);
+
+ com.example.simple.Quote quote =
+ (com.example.simple.Quote)scope.getDataFactory().create(com.example.simple.Quote.class);
+
+ quote.setSymbol("fbnt");
+ quote.setCompanyName("FlyByNightTechnology");
+ quote.setPrice(new BigDecimal("1000.0"));
+ quote.setOpen1(new BigDecimal("1000.0"));
+ quote.setHigh(new BigDecimal("1000.0"));
+ quote.setLow(new BigDecimal("1000.0"));
+ quote.setVolume(1000);
+ quote.setChange1(1000);
+
+ com.example.simple.Quote child =
+ (com.example.simple.Quote)scope.getDataFactory().create(com.example.simple.Quote.class);
+ quote.getQuotes().add(child);
+ child.setPrice(new BigDecimal("2000.0"));
+
+ //XMLHelper.INSTANCE.save((DataObject)quote, "http://www.example.com/simple", "stockQuote", System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Simple Default Generation Pattern Static SDO 2.1 test.
+ */
+ public void testSimpleNoInterfaceGeneratedClasses()
+ {
+ try
+ {
+ HelperContext scope = SDOUtil.createHelperContext();
+ com.example.noInterfaces.simple.SimpleFactory.INSTANCE.register(scope);
+
+ com.example.noInterfaces.simple.Quote quote =
+ (com.example.noInterfaces.simple.Quote)scope.getDataFactory().create(com.example.noInterfaces.simple.Quote.class);
+
+ quote.setSymbol("fbnt");
+ quote.setCompanyName("FlyByNightTechnology");
+ quote.setPrice(new BigDecimal("1000.0"));
+ quote.setOpen1(new BigDecimal("1000.0"));
+ quote.setHigh(new BigDecimal("1000.0"));
+ quote.setLow(new BigDecimal("1000.0"));
+ quote.setVolume(1000);
+ quote.setChange1(1000);
+
+ com.example.noInterfaces.simple.Quote child =
+ (com.example.noInterfaces.simple.Quote)scope.getDataFactory().create(com.example.noInterfaces.simple.Quote.class);
+ quote.getQuotes().add(child);
+ child.setPrice(new BigDecimal("2000.0"));
+
+ //XMLHelper.INSTANCE.save((DataObject)quote, "http://www.example.com/simple", "stockQuote", System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testFailureOnNullScope() {
+ try {
+ SimpleFactory.INSTANCE.register(null);
+ assertTrue("Should not be able to register in null scope", false);
+ }
+ catch (Exception e) {
+ // caught expected exception
+ }
+ }
+
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java
new file mode 100644
index 0000000000..0b291b3365
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.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.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.subgroup.A;
+import com.example.subgroup.B;
+import com.example.subgroup.Bprime;
+import com.example.subgroup.SubgroupFactory;
+import com.example.subgroup.impl.AImpl;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+public class InheritanceTestCase extends TestCase {
+
+ private HelperContext scope;
+
+ public void testSubGroupLoad() throws IOException {
+ XMLDocument doc = scope.getXMLHelper().load(
+ getClass().getResourceAsStream("/subgroup1.xml"));
+ assertEquals("a", doc.getRootElementName());
+ String strdoc = scope.getXMLHelper().save(
+ doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName());
+ assertTrue(strdoc.indexOf("<sg:imInTypeB>thisIsElB</sg:imInTypeB>") != -1);
+ }
+
+ public void testSubGroup_AcontainsB() {
+ A a = (A) scope.getDataFactory().create(A.class);
+ B b = (B) scope.getDataFactory().create(B.class);
+ b.setImInTypeB("thisIsElB");
+ a.setGe1(b);
+
+ assertSame(b, a.getGe1());
+ assertSame(b, ((AImpl) a).get(AImpl.GE1));
+
+ String doc = scope.getXMLHelper().save((DataObject) a,
+ "http://example.com/subgroup", "a");
+ assertTrue(doc.indexOf("<sg:imInTypeB>thisIsElB</sg:imInTypeB>") != -1);
+
+ }
+
+ public void testSubGroup_AcontainsBprime() {
+ A a = (A) scope.getDataFactory().create(A.class);
+ Bprime bp = (Bprime) scope.getDataFactory().create(Bprime.class);
+ bp.setImInTypeBprime("thisIsElBprime");
+ a.setGe1(bp);
+
+ assertSame(bp, a.getGe1());
+ assertSame(bp, ((AImpl) a).get(AImpl.GE1));
+
+ String doc = scope.getXMLHelper().save((DataObject) a,
+ "http://example.com/subgroup", "a");
+
+ assertTrue(doc.indexOf("<sg:imInTypeBprime>thisIsElBprime</sg:imInTypeBprime>") != -1);
+
+ }
+
+ public void testSubGroup_Bprime() {
+ Bprime bp = (Bprime) scope.getDataFactory().create(Bprime.class);
+ bp.setImInTypeB("bValue");
+ bp.setImInTypeBprime("bpvalue");
+ String doc = scope.getXMLHelper().save((DataObject) bp,
+ "http://example.com/subgroup", "bp");
+ assertTrue(doc.indexOf("<sg:imInTypeB>bValue</sg:imInTypeB>") != -1);
+ assertTrue(doc.indexOf("<sg:imInTypeBprime>bpvalue</sg:imInTypeBprime>") != -1);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scope = SDOUtil.createHelperContext();
+
+ SubgroupFactory.INSTANCE.register(scope);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InternalInElementTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InternalInElementTestCase.java
new file mode 100644
index 0000000000..dfa4b02221
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/InternalInElementTestCase.java
@@ -0,0 +1,63 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
+
+import com.example.internal.InternalFactory;
+import com.example.internal.Wrapper;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+
+public class InternalInElementTestCase extends TestCase {
+ HelperContext scope;
+
+ /*TUSCANy-1483 check correct code generation for internalAbc */
+ public void testPackageValidityWithInternalInElement() throws Exception {
+ //if dob is instantiated, it proves that the code got generated without any duplicates
+ //without the fix,
+ //public final static int INTERNAL_ABC = 1;
+ //public final static int INTERNAL_ABC = 0;
+ //was getting generated and so invalid java class WrapperImpl.java.
+ InternalFactory.INSTANCE.register(scope);
+ DataObject dob = scope.getDataFactory().create(Wrapper.class);
+
+ assertTrue(true);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scope = SDOUtil.createHelperContext();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ListWithDefaultTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ListWithDefaultTestCase.java
new file mode 100644
index 0000000000..59799bf23e
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/ListWithDefaultTestCase.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.example.address.with.list.LIFactory;
+import org.example.address.with.list.SubCategoryType;
+
+import commonj.sdo.helper.HelperContext;
+
+public class ListWithDefaultTestCase extends TestCase {
+ HelperContext scope = null;
+
+ public void testListWithDefault() {
+ SubCategoryType sct = (SubCategoryType)scope.getDataFactory().create(SubCategoryType.class);
+ List l = sct.getCategoryType();
+ assertTrue(l.size() == 1);
+ assertEquals((String)l.get(0), "myCat");
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scope = SDOUtil.createHelperContext();
+
+ LIFactory.INSTANCE.register(scope);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java
new file mode 100644
index 0000000000..e716076366
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java
@@ -0,0 +1,86 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.mixedtypes.statictypes.StatictypesFactory;
+import com.example.mixedtypes.statictypes.Address;
+import com.example.mixedtypes.statictypes.Customer;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+
+public class MixedTypesTestCase extends TestCase {
+
+ private final String[] MODELS = new String[] {
+ "/mixedTypesDynamic.xsd"
+ };
+
+ private final String NS_DYNAMIC = "http://www.example.com/mixedtypes/dynamictypes";
+
+ private HelperContext scope;
+
+ public void testSetDynamicToStatic() {
+ DataFactory factory = scope.getDataFactory();
+
+ DataObject staticCustomer = factory.create(Customer.class);
+ assertTrue("The account property type has to be abstract, pre condition to this test.",
+ staticCustomer.getInstanceProperty("account").getType().isAbstract());
+
+ DataObject dynamicSavingsAccount = factory.create(NS_DYNAMIC, "SavingsAccount");
+ staticCustomer.set("account", dynamicSavingsAccount);
+ assertNotNull("The account property in the static customer has to be set",
+ ((Customer)staticCustomer).getAccount());
+ }
+
+ public void testSetStaticToDynamic() {
+ DataFactory factory = scope.getDataFactory();
+
+ DataObject dynamicSavingsAccount = factory.create(NS_DYNAMIC, "SavingsAccount");
+ DataObject staticAddress = factory.create(Address.class);
+
+ dynamicSavingsAccount.set("alternateAddress", staticAddress);
+ assertTrue("The address property on the dynamic account object has to be set",
+ dynamicSavingsAccount.isSet("alternateAddress"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scope = SDOUtil.createHelperContext();
+
+ StatictypesFactory.INSTANCE.register(scope);
+
+ // Populate the meta data for the models
+ for (int i = 0; i < MODELS.length; i++) {
+ String model = MODELS[i];
+ URL url = getClass().getResource(model);
+ InputStream inputStream = url.openStream();
+ scope.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ }
+ }
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
new file mode 100644
index 0000000000..cff0c3ba85
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.open.OneElementAndAnyAttr;
+import com.example.open.OpenFactory;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.helper.HelperContext;
+
+
+public class OpenContentTestCase extends TestCase
+{
+
+ HelperContext scope;
+
+ public void testAnyAttribute() throws IOException
+ {
+
+ OpenFactory.INSTANCE.register(scope);
+ DataObject dob = scope.getDataFactory().create(OneElementAndAnyAttr.class);
+ OneElementAndAnyAttr staticDob = (OneElementAndAnyAttr)dob;
+
+ staticDob.setName("fred");
+
+ assertEquals(1, dob.getInstanceProperties().size());
+ Sequence s = ((OneElementAndAnyAttr)dob).getAnyAttribute();
+
+ assertFalse(dob.getType().isSequenced());
+ assertTrue(dob.getType().isOpen());
+ assertNull(dob.getSequence());
+
+ Property prop = scope.getTypeHelper().getOpenContentProperty("http://www.example.com/open", "globAttribute");
+ s.add(prop, "foo");
+ assertEquals(2, dob.getInstanceProperties().size());
+ assertTrue(dob.getInstanceProperties().contains(prop));
+
+ // scope.getXMLHelper().save((DataObject)dob, "http://www.example.com/open", "bar", System.out);
+ }
+
+ protected void setUp() throws Exception {
+ scope = SDOUtil.createHelperContext();
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
new file mode 100644
index 0000000000..c085245f13
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
@@ -0,0 +1,110 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.math.BigDecimal;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.dom.DOMSource;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.simple.Quote;
+import com.example.simple.SimpleFactory;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.impl.HelperProvider;
+
+
+public class SimpleStaticTestCase extends TestCase
+{
+
+ HelperContext scope;
+ /**
+ * Simple Static SDO 2 test.
+ */
+ public void testSimpleStatic()
+ {
+ try
+ {
+ Quote quote = SimpleFactory.INSTANCE.createQuote();
+
+ quote.setSymbol("fbnt");
+ quote.setCompanyName("FlyByNightTechnology");
+ quote.setPrice(new BigDecimal("1000.0"));
+ quote.setOpen1(new BigDecimal("1000.0"));
+ quote.setHigh(new BigDecimal("1000.0"));
+ quote.setLow(new BigDecimal("1000.0"));
+ quote.setVolume(1000);
+ quote.setChange1(1000);
+
+ //Quote child = (Quote)((DataObject)quote).createDataObject(8);
+ Quote child = SimpleFactory.INSTANCE.createQuote();
+ quote.getQuotes().add(child);
+ child.setPrice(new BigDecimal("2000.0"));
+
+ // scope.getXMLHelper().save((DataObject)quote, "http://www.example.com/simple", "stockQuote", System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testSimpleStaticViaDomSource() throws Exception {
+ // created for TUSCANY-2080
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ java.net.URL url = getClass().getResource("/stockquote.xml");
+ InputStream inputStream = url.openStream();
+ org.w3c.dom.Document dom = builder.parse(inputStream);
+
+ // Now load from dom to object
+ DOMSource source = new DOMSource(dom);
+
+ XMLDocument xml = scope.getXMLHelper().load(source, null, null);
+ assertTrue("Root element is not an instance of the generated class", xml
+ .getRootObject() instanceof Quote);
+
+ }
+
+ protected void setUp() throws Exception {
+ scope = SDOUtil.createHelperContext();
+ SimpleFactory.INSTANCE.register(scope);
+
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+}
diff --git a/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SubstitutionWithExtensionValuesTestCase.java b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SubstitutionWithExtensionValuesTestCase.java
new file mode 100644
index 0000000000..92cef546a6
--- /dev/null
+++ b/sdo-java/branches/emf-2.5/tools-test/src/test/java/org/apache/tuscany/sdo/test/SubstitutionWithExtensionValuesTestCase.java
@@ -0,0 +1,155 @@
+/**
+ *
+ * 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 org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+
+import com.example.substitution.ev.SEVFactory;
+import com.example.substitution.ev.impl.SEVFactoryImpl;
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.impl.HelperProvider;
+
+public final class SubstitutionWithExtensionValuesTestCase extends TestCase
+{
+ private static String sev2NamespaceURI;
+ private HelperContext hc;
+ private DataObject dataObject;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = HelperProvider.getDefaultContext();
+ registerSEV(hc, true);
+
+ InputStream inputStream = null;
+ URL url = getClass().getResource("/substitutionWithExtensionValues2.xsd");
+ inputStream = url.openStream();
+ List sev2TypeList = hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+
+ inputStream = getClass().getResourceAsStream("/substitutionWithExtensionValues1.xml");
+ dataObject = hc.getXMLHelper().load(inputStream).getRootObject();
+ inputStream.close();
+
+ if (sev2NamespaceURI == null)
+ {
+ sev2NamespaceURI = ((Type) sev2TypeList.get(0)).getURI();
+ }
+ }
+
+ private void registerSEV(HelperContext hc, boolean useStaticRegistration) throws IOException
+ {
+ if (useStaticRegistration)
+ {
+ SEVFactory.INSTANCE.register(hc);
+ }
+ else
+ {
+ InputStream inputStream = null;
+ URL url = getClass().getResource("/substitutionWithExtensionValues.xsd");
+ inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ }
+ }
+
+ public void testComplexTypeWithSubstitutionExtension() throws IOException
+ {
+ TypeHelper typeHelper = hc.getTypeHelper();
+
+ Type resultsType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "ResultsType");
+ Type results2Type = typeHelper.getType(sev2NamespaceURI, "Results2Type");
+ assertTrue("Results2 type does not report Results as a base type",
+ results2Type.getBaseTypes().contains(resultsType));
+
+ assertEquals("results.1/myResult.0/id has unexpected value",
+ "BBBBBBBBBBBBBBBBBBBB", dataObject.getString("results.1/myResult.0/id"));
+ }
+
+ public void testComplexTypeWithSimpleContentExtensionMetaData()
+ {
+ TypeHelper typeHelper = hc.getTypeHelper();
+
+ Type commentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "CommentType");
+ Type myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "MyCommentType");
+ Type _myCommentType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "_MyCommentType");
+ Type comment2Type = typeHelper.getType(sev2NamespaceURI, "Comment2Type");
+ Type _comment2Type = typeHelper.getType(sev2NamespaceURI, "_Comment2Type");
+ assertTrue("MyComment type does not report Comment as a base type",
+ myCommentType.getBaseTypes().contains(commentType));
+ assertTrue("Comment2 type does not report Comment as a base type",
+ comment2Type.getBaseTypes().contains(commentType));
+
+ // Test length facets - resort to EMF APIs until Tuscany SDO exposes these directly
+ ExtendedMetaData extendedMetaData = ExtendedMetaData.INSTANCE;
+
+ EStructuralFeature simpleFeature = null;
+ EDataType commentSimpleType = null;
+
+ // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
+ commentSimpleType = (EDataType) _myCommentType;
+ assertEquals(40, extendedMetaData.getMaxLengthFacet(commentSimpleType));
+
+ // FIXME Work-around EMF's lack of support for re-definable features - SEE TUSCANY-1832
+ commentSimpleType = (EDataType) _comment2Type;
+ assertEquals(20, extendedMetaData.getMaxLengthFacet(commentSimpleType));
+ }
+
+ public void testComplexTypeWithSimpleContentExtensionChangeSummary() throws IOException
+ {
+ DataGraph dg = SDOUtil.createDataGraph();
+ SDOUtil.setRootObject(dg, dataObject);
+ dg.getChangeSummary().beginLogging();
+ dataObject.getDataObject("results.1/myResult.0").delete();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.saveDataGraph(dg, baos, null);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ SDOUtil.loadDataGraph(bais, null, hc);
+ }
+
+ public void testSimpleTypeExtension()
+ {
+ TypeHelper typeHelper = hc.getTypeHelper();
+
+ Type asciiStringType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "AsciiStringType");
+ Type idType = typeHelper.getType(SEVFactoryImpl.NAMESPACE_URI, "IdType");
+ assertTrue("IdType does not report AsciiStringType as a base type",
+ idType.getBaseTypes().contains(asciiStringType));
+
+ Type id2Type = typeHelper.getType(sev2NamespaceURI, "Id2Type");
+ assertTrue("Id2Type does not report IdType as a base type",
+ id2Type.getBaseTypes().contains(idType));
+ }
+}