summaryrefslogtreecommitdiffstats
path: root/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-10 19:19:15 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-10 19:19:15 +0000
commitc993ba575bdd1530b7bbc0c6a19c32e66fce4b89 (patch)
tree94cfba65fe887c9017ea73727966d673e51d1ab7 /branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany
parentdc741421e88c3e4210b00f39877159c5117b99d3 (diff)
moving SDO branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834612 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany')
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java53
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java131
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/CreateTestClasses.java55
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java96
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java115
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java76
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java102
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java75
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java86
-rw-r--r--branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java288
10 files changed, 0 insertions, 1077 deletions
diff --git a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
deleted file mode 100644
index f54313e9bf..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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(GeneratedPackagesTestCase.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/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java
deleted file mode 100644
index f58d607cba..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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 testChangeSummaryOnDataGraphWithInt() 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/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/CreateTestClasses.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/CreateTestClasses.java
deleted file mode 100644
index 6d81ebaf77..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/CreateTestClasses.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import org.apache.tuscany.sdo.generate.JavaGenerator;
-import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
-
-/**
- * A utility class to regenerate the classes for the test cases
- */
-public class CreateTestClasses {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- CreateTestClasses ctc = new CreateTestClasses();
- ctc.run();
-
-
- }
-
- private void run() {
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/CustomerAccount.xsd").getFile(), null, "src/test/java/", null, null, 0);
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/extensible/customer.xsd").getFile(), null, "src/test/java/", null, null, 0);
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/open.xsd").getFile(), null, "src/test/java/", null, null, 0);
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/simpleWithChangeSummary.xsd").getFile(), "http://www.example.com/simpleCS", "src/test/java/", "com.example.simple.cs", "CS", 0);
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/simple.xsd").getFile(), null, "src/test/java/", null, null, 0);
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/simple.xsd").getFile(), null, "src/test/java/", "com.example.noInterfaces.simple", null, JavaGenerator.OPTION_NO_INTERFACES);
-
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/repeatingChoice.xsd").getFile(), null, "src/test/java/", null, null, 0);
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/sequences.xsd").getFile(), null, "src/test/java/", null, null, 0);
- XSD2JavaGenerator.generateFromXMLSchema(getClass().getResource("/subgroup.xsd").getFile(), null, "src/test/java/", null, null, 0);
-
- }
-
-}
diff --git a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
deleted file mode 100644
index be65951ba5..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
deleted file mode 100644
index 19fbc7b10e..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.math.BigDecimal;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.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/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
deleted file mode 100644
index 3e6267623c..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sdo.test;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
-
-import junit.framework.TestCase;
-
-
-public class GeneratedPackagesTestCase extends TestCase
-{
- static String expectedNamespace = "http://www.example.com/sequences";
-
- public void testPackageValidity()
- {
- XSD2JavaGenerator codeGen = new XSD2JavaGenerator();
- String [] genArgs = { "-schemaNamespace", "all", "-noGenerate", "src/test/resources/sequences.xsd" };
- codeGen.generateFromXMLSchema( genArgs );
- List packages = codeGen.getGeneratedPackageInfo();
-
- for (Iterator iter = packages.iterator(); iter.hasNext();)
- {
- XSD2JavaGenerator.GeneratedPackage packageInfo = (XSD2JavaGenerator.GeneratedPackage)iter.next();
- assertTrue(expectedNamespace.equals(packageInfo.getNamespace()));
-
- String name;
- boolean validatedDocRoot = false;
- boolean validatedMixedQuote = false;
- boolean validatedSymbol = false;
- for (Iterator iterClass = packageInfo.getClasses().iterator(); iterClass.hasNext();)
- {
- XSD2JavaGenerator.GeneratedPackage.PackageClassInfo classInfo = (XSD2JavaGenerator.GeneratedPackage.PackageClassInfo)iterClass.next();
- name = classInfo.getName();
-
- if( "MixedQuote".equals(name))
- {
- assertTrue("com.example.sequences.MixedQuote".equals(classInfo.getClassName()));
- validatedMixedQuote = true;
- }
- if( "".equals(name))
- {
- assertTrue("com.example.sequences.DocumentRoot".equals(classInfo.getClassName()));
- validatedDocRoot = true;
- }
- if( "symbol".equals(name))
- {
- assertTrue("java.lang.String".equals(classInfo.getClassName()));
- validatedSymbol = true;
- }
- }
- assertTrue(validatedMixedQuote);
- assertTrue(validatedDocRoot);
- assertTrue(validatedSymbol);
- }
- }
-}
diff --git a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java
deleted file mode 100644
index a971f79f0f..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.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/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
deleted file mode 100644
index f2b1bb08b8..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.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/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
deleted file mode 100644
index 207ccd4484..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.math.BigDecimal;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import com.example.simple.Quote;
-import com.example.simple.SimpleFactory;
-import com.example.simple.impl.SimpleFactoryImpl;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.helper.XMLHelper;
-
-
-public class SimpleStaticTestCase extends TestCase
-{
-
- HelperContext scope;
- /**
- * Simple Static SDO 2 test.
- */
- public void testSimpleStatic()
- {
- try
- {
- SimpleFactory.INSTANCE.register(scope);
- // System.out.println(SimpleFactoryImpl.PATTERN_VERSION);
-
- //Quote quote = (Quote)DataFactory.INSTANCE.create(Quote.class);
- 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();
- }
- }
-
- protected void setUp() throws Exception {
- scope = SDOUtil.createHelperContext();
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-
-}
diff --git a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
deleted file mode 100644
index 0ca49b6122..0000000000
--- a/branches/sdo-1.0-incubating/tools/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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 {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setIgnoringComments(true);
- builder = factory.newDocumentBuilder();
- //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);
- }
-}