Author: kelvingoodson
Date: Thu Aug 30 07:14:36 2007
New Revision: 571176
URL: http://svn.apache.org/viewvc?rev=571176&view=rev
Log:
TUSCANY-1399 more tests added -- had to add a duplicate of simple.xsd for
noInterfaces test case because maven presumes generation is not needed if one
set of outputs have already been generated from an input
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customer.xsd
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customers.xml
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xml
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xsd
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xml
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xsd
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/nonamespace.xsd
incubator/tuscany/java/sdo/toolsTest/src/main/resources/simpleNoIF.xsd
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
Modified:
incubator/tuscany/java/sdo/toolsTest/pom.xml
Modified: incubator/tuscany/java/sdo/toolsTest/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/pom.xml?rev=571176&r1=571175&r2=571176&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/pom.xml (original)
+++ incubator/tuscany/java/sdo/toolsTest/pom.xml Thu Aug 30 07:14:36 2007
@@ -81,10 +81,30 @@
</goals>
</execution>
<execution>
+ <id>simpleNoInterfaces</id>
+ <configuration>
+
<schemaFile>${basedir}/src/main/resources/simpleNoIF.xsd</schemaFile>
+
<javaPackage>com.example.noInterfaces.simple</javaPackage>
+ <noInterfaces>true</noInterfaces>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
<id>customer</id>
<configuration>
<schemaFile>${basedir}/src/main/resources/CustomerAccount.xsd</schemaFile>
<prefix>Customer</prefix>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>extensible</id>
+ <configuration>
+
<schemaFile>${basedir}/src/main/resources/extensible/customer.xsd</schemaFile>
</configuration>
<goals>
<goal>generate</goal>
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customer.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customer.xsd?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customer.xsd
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customer.xsd
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+ <xsd:schema xmlns="http://www.example.com/extensible/customer"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ targetNamespace="http://www.example.com/extensible/customer">
+
+ <xsd:complexType name="CustomersType">
+ <xsd:sequence>
+ <xsd:element name="customer" type="CustomerType"
maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="CustomerType">
+ <xsd:all>
+ <xsd:element name="name" type="CustNameType" />
+ <xsd:element name="number" type="xsd:integer" />
+ <xsd:element form="unqualified" name="info"
type="InfoType" />
+ </xsd:all>
+ </xsd:complexType>
+
+ <xsd:simpleType name="CustNameType">
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+
+ <xsd:complexType name="InfoType" />
+
+ <xsd:element name="customers" type="CustomersType" />
+ <xsd:element name="customer" type="CustomerType" />
+</xsd:schema>
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customers.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customers.xml?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customers.xml
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/customers.xml
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+ <customers xmlns="http://www.example.com/extensible/customer"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.example.com/extensible/customer
customer.xsd">
+ <customer>
+ <name>Pat Walmsley</name>
+ <info xsi:type="ns1:InfoType" xmlns=""
+
xmlns:ns1="http://www.example.com/extensible/info/zipcode">
+ <zipcode>21043</zipcode>
+ </info>
+ <number>15465</number>
+ </customer>
+ <customer>
+ <name>Priscilla Walmsley</name>
+ <number>15466</number>
+ <info xsi:type="ns1:InfoType" xmlns=""
+
xmlns:ns1="http://www.example.com/extensible/info/street">
+ <street>341 Duckworth Way</street>
+ </info>
+ </customer>
+</customers>
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xml?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xml
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xml
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+ <info xsi:type="ns1:InfoType" xmlns=""
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ns1="http://www.example.com/extensible/info/street">
+ <street>21043 Jones Way</street>
+</info>
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xsd?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xsd
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infostreet.xsd
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+ <xsd:schema xmlns="http://www.example.com/extensible/info/street"
+ xmlns:customer="http://www.example.com/extensible/customer"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="unqualified"
+ targetNamespace="http://www.example.com/extensible/info/street">
+ <xsd:import namespace="http://www.example.com/extensible/customer"
+ schemaLocation="customer.xsd" />
+ <xsd:complexType name="InfoType">
+ <xsd:complexContent>
+ <xsd:extension base="customer:InfoType">
+ <xsd:sequence>
+ <xsd:element name="street"
type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+</xsd:schema>
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xml?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xml
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xml
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+ <info xsi:type="ns1:InfoType" xmlns=""
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ns1="http://www.example.com/extensible/info/zipcode">
+ <zipcode>21043</zipcode>
+</info>
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xsd?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xsd
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/infozipcode.xsd
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+ <xsd:schema xmlns="http://www.example.com/extensible/info/zipcode"
+ xmlns:customer="http://www.example.com/extensible/customer"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="unqualified"
+ targetNamespace="http://www.example.com/extensible/info/zipcode">
+ <xsd:import namespace="http://www.example.com/extensible/customer"
+ schemaLocation="customer.xsd" />
+ <xsd:complexType name="InfoType">
+ <xsd:complexContent>
+ <xsd:extension base="customer:InfoType">
+ <xsd:sequence>
+ <xsd:element name="zipcode"
type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+</xsd:schema>
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/nonamespace.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/nonamespace.xsd?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/nonamespace.xsd
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/main/resources/extensible/nonamespace.xsd
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+ <xsd:schema xmlns:customer="http://www.example.com/extensible/customer"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:import namespace="http://www.example.com/extensible/customer"
+ schemaLocation="customer.xsd" />
+ <xsd:element name="info" type="customer:InfoType"></xsd:element>
+</xsd:schema>
Added: incubator/tuscany/java/sdo/toolsTest/src/main/resources/simpleNoIF.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/simpleNoIF.xsd?rev=571176&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/src/main/resources/simpleNoIF.xsd
(added)
+++ incubator/tuscany/java/sdo/toolsTest/src/main/resources/simpleNoIF.xsd Thu
Aug 30 07:14:36 2007
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<xsd:schema
+ targetNamespace="http://www.example.com/simple"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:simple="http://www.example.com/simple">
+
+ <xsd:element name="stockQuote" type="simple:Quote"/>
+
+ <xsd:complexType name="Quote">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string"/>
+ <xsd:element name="companyName" type="xsd:string"/>
+ <xsd:element name="price" type="xsd:decimal"/>
+ <xsd:element name="open1" type="xsd:decimal"/>
+ <xsd:element name="high" type="xsd:decimal"/>
+ <xsd:element name="low" type="xsd:decimal"/>
+ <xsd:element name="volume" type="xsd:double"/>
+ <xsd:element name="change1" type="xsd:double"/>
+ <xsd:element name="quotes" type="simple:Quote" minOccurs="0"
maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
Added:
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/ExtensibleTestCase.java
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,96 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.extensible.customer.CustomerFactory;
+import com.example.extensible.customer.CustomersType;
+import com.example.extensible.customer.InfoType;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+public class ExtensibleTestCase extends TestCase {
+
+ private final String[] MODELS = new String[] {
+ "/extensible/nonamespace.xsd",
+ "/extensible/infostreet.xsd",
+ "/extensible/infozipcode.xsd"
+ };
+
+ private final String CUSTOMERS_XML = "/extensible/customers.xml";
+ private final String INFOSTREET_XML = "/extensible/infostreet.xml";
+ private final String INFOZIPCODE_XML = "/extensible/infozipcode.xml";
+
+ private HelperContext scope;
+
+ public void testCustomersLoad() throws IOException {
+ XMLDocument doc = scope.getXMLHelper().load(
+ getClass().getResourceAsStream(CUSTOMERS_XML));
+ assertEquals("customers", doc.getRootElementName());
+ assertTrue("RootObject of " + CUSTOMERS_XML + " should be
instanceof CustomersType",
+ doc.getRootObject() instanceof CustomersType);
+ String strdoc = scope.getXMLHelper().save(
+ doc.getRootObject(), doc.getRootElementURI(),
doc.getRootElementName());
+ assertTrue(strdoc.indexOf("<street>341 Duckworth Way</street>")
!= -1);
+ }
+
+ public void testInfoLoad() throws IOException {
+ String[] infoXmls = new String[] {INFOSTREET_XML,
INFOZIPCODE_XML};
+ for (int i = 0; i < infoXmls.length; i++) {
+ String infoXml = infoXmls[i];
+ XMLDocument doc = scope.getXMLHelper().load(
+ getClass().getResourceAsStream(infoXml));
+ assertEquals("info", doc.getRootElementName());
+ assertTrue("RootObject of " + infoXml + " should be
instanceof InfoType",
+ doc.getRootObject() instanceof
InfoType);
+ String strdoc = scope.getXMLHelper().save(
+ doc.getRootObject(),
doc.getRootElementURI(), doc.getRootElementName());
+ String elementName = (i == 0) ? "street" : "zipcode";
+ String valuePrefix = "21043";
+ assertTrue(strdoc.indexOf("<" + elementName + ">") !=
-1);
+ assertTrue(strdoc.indexOf("</" + elementName + ">") !=
-1);
+ assertTrue(strdoc.indexOf(">" + valuePrefix) != -1);
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scope = SDOUtil.createHelperContext();
+
+ CustomerFactory.INSTANCE.register(scope);
+
+ // Populate the meta data for the models
+ for (int i = 0; i < MODELS.length; i++) {
+ String model = MODELS[i];
+ URL url = getClass().getResource(model);
+ InputStream inputStream = url.openStream();
+ scope.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ }
+ }
+
+}
Added:
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java?rev=571176&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/GenPatternsTestCase.java
Thu Aug 30 07:14:36 2007
@@ -0,0 +1,115 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.math.BigDecimal;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.simple.SimpleFactory;
+import commonj.sdo.helper.HelperContext;
+
+
+public class GenPatternsTestCase extends TestCase
+{
+ /**
+ * Simple Default Generation Pattern Static SDO 2.1 test.
+ */
+ public void testSimpleDefaultGeneratedClasses()
+ {
+ try
+ {
+ HelperContext scope = SDOUtil.createHelperContext();
+ com.example.simple.SimpleFactory.INSTANCE.register(scope);
+
+ com.example.simple.Quote quote =
+
(com.example.simple.Quote)scope.getDataFactory().create(com.example.simple.Quote.class);
+
+ quote.setSymbol("fbnt");
+ quote.setCompanyName("FlyByNightTechnology");
+ quote.setPrice(new BigDecimal("1000.0"));
+ quote.setOpen1(new BigDecimal("1000.0"));
+ quote.setHigh(new BigDecimal("1000.0"));
+ quote.setLow(new BigDecimal("1000.0"));
+ quote.setVolume(1000);
+ quote.setChange1(1000);
+
+ com.example.simple.Quote child =
+
(com.example.simple.Quote)scope.getDataFactory().create(com.example.simple.Quote.class);
+ quote.getQuotes().add(child);
+ child.setPrice(new BigDecimal("2000.0"));
+
+ //XMLHelper.INSTANCE.save((DataObject)quote,
"http://www.example.com/simple", "stockQuote", System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Simple Default Generation Pattern Static SDO 2.1 test.
+ */
+ public void testSimpleNoInterfaceGeneratedClasses()
+ {
+ try
+ {
+ HelperContext scope = SDOUtil.createHelperContext();
+ com.example.noInterfaces.simple.SimpleFactory.INSTANCE.register(scope);
+
+ com.example.noInterfaces.simple.Quote quote =
+
(com.example.noInterfaces.simple.Quote)scope.getDataFactory().create(com.example.noInterfaces.simple.Quote.class);
+
+ quote.setSymbol("fbnt");
+ quote.setCompanyName("FlyByNightTechnology");
+ quote.setPrice(new BigDecimal("1000.0"));
+ quote.setOpen1(new BigDecimal("1000.0"));
+ quote.setHigh(new BigDecimal("1000.0"));
+ quote.setLow(new BigDecimal("1000.0"));
+ quote.setVolume(1000);
+ quote.setChange1(1000);
+
+ com.example.noInterfaces.simple.Quote child =
+
(com.example.noInterfaces.simple.Quote)scope.getDataFactory().create(com.example.noInterfaces.simple.Quote.class);
+ quote.getQuotes().add(child);
+ child.setPrice(new BigDecimal("2000.0"));
+
+ //XMLHelper.INSTANCE.save((DataObject)quote,
"http://www.example.com/simple", "stockQuote", System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testFailureOnNullScope() {
+ try {
+ SimpleFactory.INSTANCE.register(null);
+ assertTrue("Should not be able to register in null scope", false);
+ }
+ catch (Exception e) {
+ // caught expected exception
+ }
+ }
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]