summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test')
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java89
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java65
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java632
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java86
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java82
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java68
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java78
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java60
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java282
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java161
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java107
-rw-r--r--tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java61
12 files changed, 0 insertions, 1771 deletions
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java
deleted file mode 100644
index 4cc8c5e842..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import commonj.sdo.ChangeSummary;
-import commonj.sdo.DataGraph;
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.XSDHelper;
-
-
-public class ChangeSummaryTestCase extends TestCase {
- private final String TEST_MODEL = "/simple.xsd";
- private final String TEST_DATA = "/simplechangesummary.xml";
-
- /**
- * Simple ChangeSummary test.
- */
- public void testChangeSummary() throws IOException {
- // Create an empty data graph and add a root object, an instance of type Quote
- //
-
- DataGraph dataGraph = SDOUtil.createDataGraph();
- DataObject quote = dataGraph.createRootObject("http://www.example.com/simple", "Quote");
-
- // Begin logging changes
- //
- ChangeSummary changeSummary = dataGraph.getChangeSummary();
- changeSummary.beginLogging();
-
- // Modify the data graph in various fun and interesting ways
- //
- quote.setString("symbol", "fbnt");
- quote.setString("companyName", "FlyByNightTechnology");
- quote.setBigDecimal("price", new BigDecimal("1000.0"));
- quote.setBigDecimal("open1", new BigDecimal("1000.0"));
- quote.setBigDecimal("high", new BigDecimal("1000.0"));
- quote.setBigDecimal("low", new BigDecimal("1000.0"));
- quote.setDouble("volume", 1000);
- quote.setDouble("change1", 1000);
-
- DataObject child = quote.createDataObject("quotes");
- child.setBigDecimal("price", new BigDecimal("2000.0"));
-
- // Stop logging changes and print the resulting data graph to stdout
- //
- changeSummary.endLogging();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- SDOUtil.saveDataGraph(dataGraph, baos, null);
-
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- XSDHelper.INSTANCE.define(inputStream, url.toString());
- inputStream.close();
- }
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java
deleted file mode 100644
index faa8782a77..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import commonj.sdo.Type;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XSDHelper;
-
-
-public class DataTypeBaseTypeTestCase extends TestCase {
- private final String TEST_MODEL = "/datatype.xsd";
- private final String TEST_NAMESPACE = "http://www.example.com/datatype";
-
- public void testSimpleSDOType() throws IOException
- {
- Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOType");
- List baseTypes = type.getBaseTypes();
- assertTrue(baseTypes.size() == 1);
- }
-
- public void testSimpleSDOTypeInstanceClass() throws IOException
- {
- Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeInstanceClass");
- List baseTypes = type.getBaseTypes();
- assertTrue(baseTypes.size() == 0);
- }
-
- public void testSimpleSDOTypeExtendedInstanceClass() throws IOException
- {
- Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeExtendedInstanceClass");
- List baseTypes = type.getBaseTypes();
- assertTrue(baseTypes.size() == 1);
- }
-
- public void setUp() throws Exception
- {
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- XSDHelper.INSTANCE.define(inputStream, url.toString());
- inputStream.close();
- }
-
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
deleted file mode 100644
index b77b534be6..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
+++ /dev/null
@@ -1,632 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.math.BigDecimal;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Property;
-import commonj.sdo.Sequence;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-
-public class DefineTypeTestCase extends TestCase
-{
- private static final String CUSTOMER1_XML = "/customer1.xml";
- private static final String CUSTOMER2_XML = "/customer2.xml";
- private static final String OPEN_XML = "/open2.xml";
- private static final String MIXED_XML = "/mixed2.xml";
- private static final String MIXEDOPEN_XML = "/mixedopen.xml";
-
- public void testDefineTypeRoundTrip() throws Exception {
- TypeHelper types = SDOUtil.createTypeHelper();
- DataFactory factory = SDOUtil.createDataFactory(types);
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
- 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");
-
- // create a customer number property
- DataObject custNumProperty = customerType.createDataObject("property");
- custNumProperty.set("name", "custNum");
- custNumProperty.set("type", intType);
-
- // create a first name property
- DataObject firstNameProperty =
- customerType.createDataObject("property");
- firstNameProperty.set("name", "firstName");
- firstNameProperty.set("type", stringType);
-
- // create a last name property
- DataObject lastNameProperty = customerType.createDataObject("property");
- lastNameProperty.set("name", "lastName");
- lastNameProperty.set("type", stringType);
-
- 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);
- Type type = customer1.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertEquals(type.getProperty("custNum").getType(), intType);
- assertEquals(type.getProperty("firstName").getType(), stringType);
- assertEquals(type.getProperty("lastName").getType(), stringType);
-
- assertNotNull(customer2);
- type = customer2.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertEquals(type.getProperty("custNum").getType(), intType);
- assertEquals(type.getProperty("firstName").getType(), stringType);
- assertEquals(type.getProperty("lastName").getType(), stringType);
-
- baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer1,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER1_XML)));
-
- baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer2,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER2_XML)));
- }
-
- public void testDefineType() throws Exception
- {
- TypeHelper types = SDOUtil.createTypeHelper();
- DataFactory factory = SDOUtil.createDataFactory(types);
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
- 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");
-
- // create a customer number property
- DataObject custNumProperty = customerType.createDataObject("property");
- custNumProperty.set("name", "custNum");
- custNumProperty.set("type", intType);
-
- // create a first name property
- DataObject firstNameProperty =
- customerType.createDataObject("property");
- firstNameProperty.set("name", "firstName");
- firstNameProperty.set("type", stringType);
-
- // create a last name property
- DataObject lastNameProperty = customerType.createDataObject("property");
- lastNameProperty.set("name", "lastName");
- lastNameProperty.set("type", stringType);
-
- // 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);
- Type type = customer1.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertEquals(type.getProperty("custNum").getType(), intType);
- assertEquals(type.getProperty("firstName").getType(), stringType);
- assertEquals(type.getProperty("lastName").getType(), stringType);
-
- assertNotNull(customer2);
- type = customer2.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertEquals(type.getProperty("custNum").getType(), intType);
- assertEquals(type.getProperty("firstName").getType(), stringType);
- assertEquals(type.getProperty("lastName").getType(), stringType);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer1,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER1_XML)));
-
- baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer2,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER2_XML)));
- }
-
- public void testDefineDataType() throws Exception
- {
- TypeHelper types = SDOUtil.createTypeHelper();
- DataFactory factory = SDOUtil.createDataFactory(types);
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(types);
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
- Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false);
-
- // create a data types
- DataObject intType = factory.create("commonj.sdo", "Type");
- intType.set("uri", "http://example.com/customer");
- intType.set("name", "MyIntType");
- intType.setBoolean("dataType", true);
- intType.set(javaClassProperty, "int");
-
- DataObject stringType = factory.create("commonj.sdo", "Type");
- stringType.set("uri", "http://example.com/customer");
- stringType.set("name", "MyStringType");
- stringType.setBoolean("dataType", true);
- stringType.set(javaClassProperty, "java.lang.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");
-
- // create a customer number property
- DataObject custNumProperty = customerType.createDataObject("property");
- custNumProperty.set("name", "custNum");
- custNumProperty.set("type", intType);
-
- // create a first name property
- DataObject firstNameProperty =
- customerType.createDataObject("property");
- firstNameProperty.set("name", "firstName");
- firstNameProperty.set("type", stringType);
-
- // create a last name property
- DataObject lastNameProperty = customerType.createDataObject("property");
- lastNameProperty.set("name", "lastName");
- lastNameProperty.set("type", stringType);
-
- // 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);
- Type type = customer1.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
-
- type = type.getProperty("custNum").getType();
- assertEquals(type.getURI(), "http://example.com/customer");
- assertEquals(type.getName(), "MyIntType");
- assertTrue(type.isDataType());
-
- assertNotNull(customer2);
- type = customer2.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer1,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER1_XML)));
-
- baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer2,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER2_XML)));
- }
-
- public void testFastDefineType() throws Exception
- {
- TypeHelper types = SDOUtil.createTypeHelper();
- DataFactory factory = SDOUtil.createDataFactory(types);
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
- Type intType = types.getType("commonj.sdo", "Int");
- Type stringType = types.getType("commonj.sdo", "String");
-
- // create a new Type for Customers
- Type customerType = SDOUtil.createType(types, "http://example.com/customer", "Customer", false);
-
- // create a customer number property
- SDOUtil.createProperty(customerType, "custNum", intType);
-
- // create a first name property
- SDOUtil.createProperty(customerType, "firstName", stringType);
-
- // create a last name property
- SDOUtil.createProperty(customerType, "lastName", stringType);
-
- 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);
- Type type = customer1.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertEquals(type.getProperty("custNum").getType(), intType);
- assertEquals(type.getProperty("firstName").getType(), stringType);
- assertEquals(type.getProperty("lastName").getType(), stringType);
-
- assertNotNull(customer2);
- type = customer2.getType();
- assertNotNull(type.getProperty("custNum"));
- assertNotNull(type.getProperty("firstName"));
- assertNotNull(type.getProperty("lastName"));
- assertEquals(type.getProperty("custNum").getType(), intType);
- assertEquals(type.getProperty("firstName").getType(), stringType);
- assertEquals(type.getProperty("lastName").getType(), stringType);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer1,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER1_XML)));
-
- baos = new ByteArrayOutputStream();
- xmlHelper.save(
- customer2,
- "http://example.com/customer",
- "Customer", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(CUSTOMER2_XML)));
- }
-
- public void testDefineSequencedType() throws Exception
- {
-
- TypeHelper types = SDOUtil.createTypeHelper();
- DataFactory factory = SDOUtil.createDataFactory(types);
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
- 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.getType().isSequenced());
-
- Sequence sequence = quote.getSequence();
-
- sequence.add("\n ");
-
- quote.setString("symbol", "fbnt");
-
- sequence.add("\n ");
-
- quote.setString("companyName", "FlyByNightTechnology");
-
- sequence.add("\n some text\n ");
-
- DataObject child = quote.createDataObject("quotes");
- child.setBigDecimal("price", new BigDecimal("2000.0"));
-
- sequence.add("\n more text\n ");
-
- // quote.setBigDecimal("price", new BigDecimal("1000.0"));
- sequence.add("price", new BigDecimal("1000.0"));
-
- sequence.add("\n");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmlHelper.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos);
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXED_XML)));
- }
-
- public void testDefineSequencedOpenType() throws Exception
- {
-
- TypeHelper types = SDOUtil.createTypeHelper();
- DataFactory factory = SDOUtil.createDataFactory(types);
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
- 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 type
- DataObject globalType = factory.create("commonj.sdo", "Type");
- globalType.set("uri", "http://www.example.com/open");
- // Don't set the type's name - null is used for types containing global properties.
-
- DataObject symbolProperty = globalType.createDataObject("property");
- symbolProperty.set("name", "symbol");
- symbolProperty.set("type", stringType);
- symbolProperty.set("containment", Boolean.TRUE);
-
- types.define(globalType);
-
- DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote");
-
- assertTrue(quote.getType().isSequenced());
-
- Sequence sequence = quote.getSequence();
-
- sequence.add("\n ");
-
- Type definedGlobalType = types.getType("http://www.example.com/open", null);
-
- Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
- quote.setString(definedSymbolProperty, "fbnt");
-
- sequence.add("\n ");
-
- quote.setString("companyName", "FlyByNightTechnology");
-
- sequence.add("\n some text\n ");
-
- DataObject child = quote.createDataObject("quotes");
- child.setBigDecimal("price", new BigDecimal("2000.0"));
-
- sequence.add("\n more text\n ");
-
- // quote.setBigDecimal("price", new BigDecimal("1000.0"));
- sequence.add("price", new BigDecimal("1000.0"));
-
- sequence.add("\n");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos);
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXEDOPEN_XML)));
- }
-
-
- public void testDefineOpenType() throws Exception
- {
- TypeHelper types = SDOUtil.createTypeHelper();
- DataFactory factory = SDOUtil.createDataFactory(types);
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
- Type stringType = types.getType("commonj.sdo", "String");
- Type decimalType = types.getType("commonj.sdo", "Decimal");
-
- // Define a new open type - OpenQuote
- DataObject openQuoteType = factory.create("commonj.sdo", "Type");
- openQuoteType.set("uri", "http://www.example.com/open");
- openQuoteType.set("name", "OpenQuote");
- openQuoteType.set("open", Boolean.TRUE);
- openQuoteType.setBoolean("open", true);
-
- types.define(openQuoteType);
-
- // Define new type - CompanyType
- DataObject companyType = factory.create("commonj.sdo", "Type");
- companyType.set("uri", "http://www.example.com/open");
- companyType.set("name", "CompanyType");
-
- // Create CompanyType property - "name"
- DataObject nameProperty = companyType.createDataObject("property");
- nameProperty.set("name", "name");
- nameProperty.set("type", stringType);
- nameProperty.set("containment", Boolean.TRUE);
-
- types.define(companyType);
-
- // Define a global type
- DataObject globalType = factory.create("commonj.sdo", "Type");
- globalType.set("uri", "http://www.example.com/open");
- // Don't set the type's name - null is used for types containing global properties.
-
- DataObject symbolProperty = globalType.createDataObject("property");
- symbolProperty.set("name", "symbol");
- symbolProperty.set("type", stringType);
- symbolProperty.set("containment", Boolean.TRUE);
-
- // Define a global property - company
- DataObject companyProperty = globalType.createDataObject("property");
- companyProperty.set("name", "company");
- companyProperty.set("type", companyType);
- companyProperty.set("containment", Boolean.TRUE);
-
- // Define a global property - price
- DataObject priceProperty = globalType.createDataObject("property");
- priceProperty.set("name", "price");
- priceProperty.set("type", decimalType);
-
- types.define(globalType);
-
- // Create DataObject instances
- DataObject openQuote = factory.create("http://www.example.com/open", "OpenQuote");
-
- assertTrue(openQuote.getType().isOpen());
-
- // Get global type
- Type definedGlobalType = types.getType("http://www.example.com/open", null);
-
- Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
- openQuote.set(definedSymbolProperty, "s1");
-
- Property definedCompanyProperty = definedGlobalType.getProperty("company");
-
- DataObject company = openQuote.createDataObject(definedCompanyProperty);
- company.setString("name", "FlyByNightTechnology");
-
- Property definedPriceProperty = definedGlobalType.getProperty("price");
- openQuote.setBigDecimal(definedPriceProperty, new BigDecimal("1000.0"));
-
- assertEquals(definedPriceProperty.getType(), decimalType);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmlHelper.save(
- openQuote,
- "http://www.example.com/open",
- "openStockQuote", baos);
- assertTrue(
- TestUtil.equalXmlFiles(
- new ByteArrayInputStream(baos.toByteArray()),
- getClass().getResource(OPEN_XML)));
- }
-
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java
deleted file mode 100644
index e46f9858e2..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.URL;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Sequence;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-import junit.framework.TestCase;
-
-
-public class MixedTypeTestCase extends TestCase {
- private final String TEST_MODEL = "/mixed.xsd";
- private final String TEST_NAMESPACE = "http://www.example.com/mixed";
- private final String TEST_DATA = "/mixed.xml";
-
- /**
- * Sequenced type SDO 2 test.
- */
- public void testSequencedType() throws IOException {
- Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "MixedQuote");
- DataObject quote = DataFactory.INSTANCE.create(quoteType);
-
- Sequence sequence = quote.getSequence();
-
- sequence.add("\n ");
-
- quote.setString("symbol", "fbnt");
-
- sequence.add("\n ");
-
- quote.setString("companyName", "FlyByNightTechnology");
-
- sequence.add("\n some text\n ");
-
- DataObject child = quote.createDataObject("quotes");
- child.setBigDecimal("price", new BigDecimal("2000.0"));
-
- sequence.add("\n more text\n ");
-
- // quote.setBigDecimal("price", new BigDecimal("1000.0"));
- sequence.add("price", new BigDecimal("1000.0"));
-
- sequence.add("\n");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "mixedStockQuote", baos);
-
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- XSDHelper.INSTANCE.define(inputStream, url.toString());
- inputStream.close();
- }
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java
deleted file mode 100644
index 7e743e296a..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.util.Iterator;
-
-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.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-import junit.framework.TestCase;
-
-
-public class OpenTypeTestCase extends TestCase {
- private final String TEST_MODEL = "/open.xsd";
- private final String TEST_NAMESPACE = "http://www.example.com/open";
- private final String TEST_DATA = "/open.xml";
-
- /**
- * Open content SDO 2 test.
- */
- public void testOpenType() throws IOException {
- Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "OpenQuote");
- DataObject quote = DataFactory.INSTANCE.create(quoteType);
-
- quote.setString("symbol", "s1");
-
- for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) {
- Property property = (Property) iter.next();
- }
-
- Property companyProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "company", true);
- DataObject company = quote.createDataObject(companyProperty);
- company.setString("name", "FlyByNightTechnology");
-
- Property priceProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "price", true);
- quote.getList(priceProperty).add(new BigDecimal("1000.0"));
-
- for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) {
- Property property = (Property) iter.next();
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "openStockQuote", baos);
-
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- XSDHelper.INSTANCE.define(inputStream, url.toString());
- inputStream.close();
- }
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java
deleted file mode 100644
index 2e91a1a66f..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-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 commonj.sdo.DataObject;
-import commonj.sdo.helper.CopyHelper;
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-import junit.framework.TestCase;
-
-public class SimpleCopyTestCase extends TestCase {
-
- private final String TEST_MODEL = "/simple.xsd";
- private final String TEST_NAMESPACE = "http://www.example.com/simple";
- private final String QUOTE_XML = "/quote.xml";
- private final String SHALLOW_QUOTE_XML = "/shallowquote.xml";
-
- public void testSimpleCopy() throws IOException {
- XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML));
- DataObject sdo = doc.getRootObject();
-
- DataObject copiedSdo = CopyHelper.INSTANCE.copyShallow(sdo);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos);
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML)));
- assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML)));
-
- copiedSdo = CopyHelper.INSTANCE.copy(sdo);
-
- baos.reset();
- XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos);
- assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML)));
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML)));
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- XSDHelper.INSTANCE.define(inputStream, url.toString());
- inputStream.close();
- }
-
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java
deleted file mode 100644
index d86b793087..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-
-
-public class SimpleDynamicTestCase extends TestCase {
- private final String TEST_MODEL = "/simple.xsd";
- private final String TEST_NAMESPACE = "http://www.example.com/simple";
- private final String QUOTE_XML = "/quote.xml";
-
- /**
- * Simple Dynamic SDO 2 test.
- */
- public void testDynamic() throws IOException {
- Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "Quote");
- DataObject quote = DataFactory.INSTANCE.create(quoteType);
-
- quote.setString("symbol", "fbnt");
- quote.setString("companyName", "FlyByNightTechnology");
- quote.setBigDecimal("price", new BigDecimal("1000.0"));
- quote.setBigDecimal("open1", new BigDecimal("1000.0"));
- quote.setBigDecimal("high", new BigDecimal("1000.0"));
- quote.setBigDecimal("low", new BigDecimal("1000.0"));
- quote.setDouble("volume", 1000);
- quote.setDouble("change1", 1000);
-
- DataObject child = quote.createDataObject("quotes");
- child.setBigDecimal("price", new BigDecimal("2000.0"));
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "stockQuote", baos);
-
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML)));
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- XSDHelper.INSTANCE.define(inputStream, url.toString());
- inputStream.close();
- }
-
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java
deleted file mode 100644
index ac05b362d9..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.EqualityHelper;
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-import junit.framework.TestCase;
-
-public class SimpleEqualityTestCase extends TestCase {
- private static final String TEST_MODEL = "/simple.xsd";
- private static final String QUOTE_XML = "/quote.xml";
- private static final String SHALLOW_QUOTE_XML = "/shallowquote.xml";
-
- public void testEquality() throws IOException {
-
- XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML));
- DataObject sdo = doc.getRootObject();
-
- doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(SHALLOW_QUOTE_XML));
- DataObject shallowSdo = doc.getRootObject();
-
- boolean result = EqualityHelper.INSTANCE.equalShallow(sdo, shallowSdo);
- assertTrue(result);
-
- result = EqualityHelper.INSTANCE.equal(sdo, shallowSdo);
- assertFalse(result);
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- XSDHelper.INSTANCE.define(inputStream, url.toString());
- inputStream.close();
- }
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
deleted file mode 100644
index d2ac035e02..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-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;
-
-public class TestUtil
-{
- 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
- }
-
- private static boolean equalNamedNodeMap(NamedNodeMap mapA, NamedNodeMap mapB) {
- if (mapA == null) {
- if (mapB == null) {
- return true;
- }
- return false;
- }
- if (mapA.getLength() != mapB.getLength()) {
- return false;
- }
- for (int i = 0; i < mapA.getLength(); i++) {
- Node trialNode = mapA.item(i);
- if (trialNode == null) {
- return false;
- }
- Node checkNode = mapB.getNamedItem(trialNode.getNodeName());
- if (checkNode == null) {
- return false;
- }
- if (!equalNode(trialNode, checkNode)) {
- return false;
- }
- }
- return true;
- }
-
- private static boolean equalNode(Node nodeA, Node nodeB) {
- if (nodeA == null) {
- if (nodeB == null) {
- return true;
- }
- return false;
- }
- // following is intended to provide same function as 1.5 isEqualNode()
- if (nodeA.getNodeType() != nodeB.getNodeType()) {
- return false;
- }
- if (!equalString(nodeA.getNodeName(), nodeB.getNodeName())) {
- return false;
- }
- if (!equalString(nodeA.getLocalName(), nodeB.getLocalName())) {
- return false;
- }
- if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) {
- return false;
- }
- if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) {
- return false;
- }
- if (!equalString(nodeA.getPrefix(), nodeB.getPrefix())) {
- return false;
- }
- if (!equalString(nodeA.getNodeValue(), nodeB.getNodeValue())) {
- return false;
- }
- if (!equalNamedNodeMap(nodeA.getAttributes(), nodeB.getAttributes())) {
- return false;
- }
- if (!equalNodeList(nodeA.getChildNodes(), nodeB.getChildNodes())) {
- return false;
- }
- if (nodeA.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- DocumentType documentTypeA = (DocumentType) nodeA;
- DocumentType documentTypeB = (DocumentType) nodeB;
- if (!equalString(documentTypeA.getPublicId(), documentTypeB.getPublicId())) {
- return false;
- }
- if (!equalString(documentTypeA.getSystemId(), documentTypeB.getSystemId())) {
- return false;
- }
- if (!equalString(documentTypeA.getInternalSubset(), documentTypeB.getInternalSubset())) {
- return false;
- }
- if (!equalNamedNodeMap(documentTypeA.getEntities(), documentTypeB.getEntities())) {
- return false;
- }
- if (!equalNamedNodeMap(documentTypeA.getNotations(), documentTypeB.getNotations())) {
- return false;
- }
- }
- return true;
- }
-
- private static boolean equalNodeList(NodeList nodeListA, NodeList nodeListB) {
- if (nodeListA == null) {
- if (nodeListB == null) {
- return true;
- }
- return false;
- }
- return equalNodes(nodeListA, nodeListB);
- }
-
- private static boolean equalString(String stringA, String stringB) {
- if (stringA == null) {
- if (stringB == null) {
- return true;
- }
- return false;
- }
- return stringA.equals(stringB);
- }
-
- private static boolean equalNodes(NodeList sourceNodeList, NodeList targetNodeList)
- {
- 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)
- {
- return false;
- }
-
- for (int i=0; i<sourceLength; i++)
- {
- Node sourceNode = (Node)sourceNodes.get(i);
- Node targetNode = (Node)targetNodes.get(i);
-
- /* remove comment when migrated to Java 1.5
- if (!sourceNode.isEqualNode(targetNode))
- {
- return false;
- }
- */
- // following is intended as 1.4 equivalent of isEqualNode()
- if (!equalNode(sourceNode, targetNode))
- {
- return false;
- }
- } // for
-
- return true;
- }
-
- public static boolean equalXmlFiles(URL source, URL target)
- {
- try {
- return equalXmlFiles(source.openStream(), target.openStream());
- }
- catch (IOException e)
- {
- return false;
- }
- }
-
- public static boolean equalXmlFiles(InputStream sourceStream, URL target)
- {
- try {
- return equalXmlFiles(sourceStream, target.openStream());
- }
- catch (IOException e)
- {
- return false;
- }
- }
-
- public static boolean equalXmlFiles(URL source, InputStream targetStream)
- {
- try {
- return equalXmlFiles(source.openStream(), targetStream);
- }
- catch (IOException e)
- {
- return false;
- }
- }
-
- public static boolean equalXmlFiles(InputStream sourceStream, InputStream targetStream)
- {
- DocumentBuilder builder;
- Document sourceDocument;
- Document targetDocument;
-
- try {
- builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- sourceDocument = builder.parse(sourceStream);
- targetDocument = builder.parse(targetStream);
- }
- catch (FactoryConfigurationError fce) {
- return false;
- }
- catch (ParserConfigurationException ce) {
- return false;
- }
- catch (SAXException se)
- {
- return false;
- }
- catch (IOException ie)
- {
- return false;
- }
-
- 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();
-
- return equalNodes(sourceNodes, targetNodes);
- }
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java
deleted file mode 100644
index b14ae165dc..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-import commonj.sdo.Type;
-import commonj.sdo.helper.TypeHelper;
-
-public class TypeRoundTripTest extends TestCase {
-
- private static class Test {
- Type type;
- String value;
- Object obj;
- Comparator comp;
-
- Test(Type type, String value, Object obj) {
- this.type = type;
- this.value = value;
- this.obj = obj;
- }
-
- Test(Type type, String value, Object obj, Comparator comp) {
- this.type = type;
- this.value = value;
- this.obj = obj;
- this.comp = comp;
- }
- }
-
- private static class ListComparator implements Comparator {
- public int compare(Object list1, Object list2) {
- int answer = 1;
- if (list1 instanceof List && list2 instanceof List) {
- List l1 = (List) list1;
- List l2 = (List) list2;
- if (l1.size() == l2.size()) {
- for (int n = 0; n < l1.size(); n++) {
- if (!l1.get(n).equals(l2.get(n))) {
- answer = 0;
- break;
- }
- }
- } else {
- answer = 0;
- }
- } else {
- answer = 0;
- }
- return answer;
- }
- }
-
- private static class BytesComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- o2 = new String((byte[])o2);
- if (o1.equals(o2)) return 1;
- else return 0;
- }
- }
-
- private static class DateComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- int answer = 1;
- try {
- if (o1 instanceof String && o2 instanceof Date) {
- SimpleDateFormat sdf =
- new SimpleDateFormat("yyyy-MM-dd'Z'");
- o1 = sdf.parse((String)o1);
- if (!o1.equals(o2)) answer = 0;
- } else {
- answer = 0;
- }
- } catch (Exception e) {}
- return answer;
- }
- }
-
- public void testTypeRoundTrips() throws Exception {
- String URI = "commonj.sdo";
- TypeHelper types = TypeHelper.INSTANCE;
- List list = new ArrayList();
- list.add("foo");
- list.add("bar");
- list.add("test");
- Test[] tests = {
- new Test(types.getType(URI, "Boolean"), "true", new Boolean(true)),
- new Test(types.getType(URI, "Byte"), "49", new Byte((byte)49)),
- new Test(types.getType(URI, "Bytes"), "Zm9v", "foo", new BytesComparator()),
- new Test(types.getType(URI, "Character"), "a", new Character('a')),
- new Test(types.getType(URI, "Date"), "2005-12-12Z", "2005-12-12Z", new DateComparator()),
- new Test(types.getType(URI, "DateTime"), "2005-12-12T12:12:12Z", "2005-12-12T12:12:12Z"),
- new Test(types.getType(URI, "Day"), "---12", "---12"),
- new Test(types.getType(URI, "Decimal"), "12.12", new BigDecimal("12.12")),
- new Test(types.getType(URI, "Double"), "12.12", new Double(12.12)),
- new Test(types.getType(URI, "Duration"), "P5Y2M10D", "P5Y2M10D"),
- new Test(types.getType(URI, "Float"), "12.12", new Float(12.12f)),
- new Test(types.getType(URI, "Int"), "12", new Integer(12)),
- new Test(types.getType(URI, "Integer"), "12", new BigInteger("12")),
- new Test(types.getType(URI, "Long"), "12", new Long(12l)),
- new Test(types.getType(URI, "Month"), "--12", "--12"),
- new Test(types.getType(URI, "MonthDay"), "--12-12", "--12-12"),
- new Test(types.getType(URI, "Object"), "test", "test"),
- new Test(types.getType(URI, "Short"), "12", new Short((short)12)),
- new Test(types.getType(URI, "String"), "test", "test"),
- new Test(types.getType(URI, "Strings"), "foo bar test", list, new ListComparator()),
- new Test(types.getType(URI, "Time"), "12:12:12.12", "12:12:12.12"),
- new Test(types.getType(URI, "URI"), "http://example.org", "http://example.org"),
- new Test(types.getType(URI, "Year"), "2005", "2005"),
- new Test(types.getType(URI, "YearMonth"), "2005-12", "2005-12"),
- new Test(types.getType(URI, "YearMonthDay"), "2005-12-12", "2005-12-12")
- };
-
- for (int n = 0; n < tests.length; n++) {
- assertEquals(
- SDOUtil.convertToString(tests[n].type, SDOUtil.createFromString(tests[n].type, tests[n].value)),
- tests[n].value
- );
-
- //System.out.print(".");
-
- if (tests[n].comp == null) {
- assertEquals(
- SDOUtil.createFromString(tests[n].type, SDOUtil.convertToString(tests[n].type, tests[n].obj)),
- tests[n].obj
- );
- } else {
- String o1 = SDOUtil.convertToString(tests[n].type, tests[n].obj);
- Object o2 = SDOUtil.createFromString(tests[n].type, o1);
- assertEquals(tests[n].comp.compare(tests[n].obj, o2), 1);
- }
- }
-
- }
-
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java
deleted file mode 100644
index c4f2cc4586..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-
-
-public class XMLDocumentTestCase extends TestCase
-{
- private final String TEST_XML_DOCUMENT = "/XMLDocumentTestCase.xml";
-
- // remember that NS1... and NS2... items are expected in sorted order by name
- private final String NS1_SCHEMA_NAME = "http://www.example.com/open";
-
- private final String NS1_SCHEMA_LOCATION = "/open.xsd";
-
- private final String NS2_SCHEMA_NAME = "http://www.example.com/xmlDocumentSchemaLocation";
-
- private final String NS2_SCHEMA_LOCATION = "/XMLDocumentSchemaLocation.xsd";
-
- private final String NS_SET_NAME_LOCATION = "namespace schemaLocation";
-
- //private final String NNS_SCHEMA_LOCATION = "http://www.example.com/XMLDocumentNoNamespaceSchemaLocation.xsd";
- private final String NNS_SCHEMA_LOCATION = "/XMLDocumentNoNamespaceSchemaLocation.xsd";
-
- private final String NNS_SET_LOCATION = "noNamespaceSchemaLocation";
-
- /**
- * This method will load an xml document consisting of a xsi:schemaLocation and
- * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and
- * set the schemaLocation property.
- *
- * @throws IOException
- */
- public void testSchemaLocation() throws IOException
- {
- // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
- XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));
-
- // get the schemaLocation
- assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());
-
- // set the schemaLocation to another value and test to see if the value was set
- doc.setSchemaLocation(NS_SET_NAME_LOCATION);
- assertEquals(NS_SET_NAME_LOCATION, doc.getSchemaLocation());
-
- // remove the schemaLocation and ensure it returns null
- doc.setSchemaLocation(null);
- assertNull(doc.getSchemaLocation());
-
- // ensure changes to schemaLocation have not changed noNamespaceSchemaLocation
- assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());
- }
-
- /**
- * This method will load an xml document consisting of a xsi:schemaLocation and
- * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and
- * set the noNamespaceSchemaLocation property.
- *
- * @throws IOException
- */
- public void testNoNamespaceSchemaLocation() throws IOException
- {
- // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
- XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));
-
- // get the noNamespaceSchemaLocation
- assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());
-
- // set the noNameSpaceSchemaLocation to another value and test to see if the value was set
- doc.setNoNamespaceSchemaLocation(NNS_SET_LOCATION);
- assertEquals(NNS_SET_LOCATION, doc.getNoNamespaceSchemaLocation());
-
- // remove the noNameSpaceSchemaLocation and ensure it returns null
- doc.setNoNamespaceSchemaLocation(null);
- assertNull(doc.getNoNamespaceSchemaLocation());
-
- // ensure changes to noNameSpaceSchemaLocation have not changed schemaLocation
- assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
-}
diff --git a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java b/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java
deleted file mode 100644
index 16a2cbd195..0000000000
--- a/tags/java-M1-final/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import junit.framework.TestCase;
-
-import commonj.sdo.helper.XSDHelper;
-
-/**
- * @version $Rev$ $Date$
- */
-public class XSDHelperTestCase extends TestCase {
- private static final String TEST_MODEL = "/simple.xsd";
- private URL modelURL;
-
- public void testDefineWithLocation() throws IOException {
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper());
- List types = xsdHelper.define(modelURL.openStream(), modelURL.toString());
- assertEquals(2, types.size());
- }
-
- public void testDefineWithNoLocation() {
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper());
- List types = xsdHelper.define(getClass().getResourceAsStream(TEST_MODEL), null);
- assertEquals(2, types.size());
- }
-
- public void testDuplicateDefineWithLocation() throws IOException {
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper());
- List types = xsdHelper.define(modelURL.openStream(), modelURL.toString());
- assertEquals(2, types.size());
-
- List types2 = xsdHelper.define(modelURL.openStream(), modelURL.toString());
- assertEquals(0, types2.size());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- modelURL = getClass().getResource(TEST_MODEL);
- }
-}