Author: kelvingoodson
Date: Wed Sep  5 06:14:47 2007
New Revision: 572947

URL: http://svn.apache.org/viewvc?rev=572947&view=rev
Log:
TUSCANY-1540 adding new test cases from patch to toolsTest project

Added:
    incubator/tuscany/java/sdo/toolsTest/src/main/resources/mixedTypesStatic.xsd
    
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java
    incubator/tuscany/java/sdo/toolsTest/src/test/resources/
    
incubator/tuscany/java/sdo/toolsTest/src/test/resources/mixedTypesDynamic.xsd
Modified:
    
incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
    incubator/tuscany/java/sdo/toolsTest/pom.xml
    
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/AllTests.java

Modified: 
incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java?rev=572947&r1=572946&r2=572947&view=diff
==============================================================================
--- 
incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
 (original)
+++ 
incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
 Wed Sep  5 06:14:47 2007
@@ -30,6 +30,7 @@
         TestSuite suite = new TestSuite();
       
         suite.addTestSuite(GeneratedPackagesTestCase.class);
+        suite.addTestSuite(MixedTypesTestCase.class);
 
         return suite;
     }
@@ -43,5 +44,6 @@
         junit.textui.TestRunner.run(suite());
     }
 }
+
 
 

Modified: incubator/tuscany/java/sdo/toolsTest/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/pom.xml?rev=572947&r1=572946&r2=572947&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/pom.xml (original)
+++ incubator/tuscany/java/sdo/toolsTest/pom.xml Wed Sep  5 06:14:47 2007
@@ -128,6 +128,15 @@
                             <goal>generate</goal>
                         </goals>
                     </execution>
+                    <execution>
+                        <id>MixedTypesStaticPart</id>
+                        <configuration>
+                            
<schemaFile>${basedir}/src/main/resources/mixedTypesStatic.xsd</schemaFile>
+                        </configuration>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
                 </executions>
             </plugin>
         </plugins>

Added: 
incubator/tuscany/java/sdo/toolsTest/src/main/resources/mixedTypesStatic.xsd
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/mixedTypesStatic.xsd?rev=572947&view=auto
==============================================================================
--- 
incubator/tuscany/java/sdo/toolsTest/src/main/resources/mixedTypesStatic.xsd 
(added)
+++ 
incubator/tuscany/java/sdo/toolsTest/src/main/resources/mixedTypesStatic.xsd 
Wed Sep  5 06:14:47 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 xmlns:statictypes="http://www.example.com/mixedtypes/statictypes";
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+       elementFormDefault="qualified"
+       targetNamespace="http://www.example.com/mixedtypes/statictypes";>
+       
+       <xsd:complexType name="Customer">
+               <xsd:sequence>
+                       <xsd:element name="number" type="xsd:integer" />
+                       <xsd:element name="account" type="statictypes:Account" 
/>
+                       <xsd:element name="address" type="statictypes:Address" 
/>
+               </xsd:sequence>
+       </xsd:complexType>
+       
+       <xsd:complexType name="Account" abstract="true" />
+       
+       <xsd:complexType name="Address">
+               <xsd:sequence>
+                       <xsd:element name="street" type="xsd:string" />
+               </xsd:sequence>
+       </xsd:complexType>
+       
+</xsd:schema>

Modified: 
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/AllTests.java?rev=572947&r1=572946&r2=572947&view=diff
==============================================================================
--- 
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
 (original)
+++ 
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
 Wed Sep  5 06:14:47 2007
@@ -35,6 +35,7 @@
         suite.addTestSuite(InheritanceTestCase.class);
         suite.addTestSuite(OpenContentTestCase.class);
         suite.addTestSuite(SimpleStaticTestCase.class);
+        suite.addTestSuite(MixedTypesTestCase.class);
 
         return suite;
     }

Added: 
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java?rev=572947&view=auto
==============================================================================
--- 
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java
 (added)
+++ 
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/MixedTypesTestCase.java
 Wed Sep  5 06:14:47 2007
@@ -0,0 +1,86 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.mixedtypes.statictypes.StatictypesFactory;
+import com.example.mixedtypes.statictypes.Address;
+import com.example.mixedtypes.statictypes.Customer;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+
+public class MixedTypesTestCase extends TestCase {
+
+       private final String[] MODELS = new String[] {
+                       "/mixedtypesDynamic.xsd"
+       };
+
+    private final String NS_DYNAMIC = 
"http://www.example.com/mixedtypes/dynamictypes";;
+
+       private HelperContext scope;
+
+    public void testSetDynamicToStatic() {
+               DataFactory factory = scope.getDataFactory();
+
+               DataObject staticCustomer = factory.create(Customer.class);
+               assertTrue("The account property type has to be abstract, pre 
condition to this test.",
+                 
staticCustomer.getInstanceProperty("account").getType().isAbstract());
+
+               DataObject dynamicSavingsAccount = factory.create(NS_DYNAMIC, 
"SavingsAccount");
+               staticCustomer.set("account", dynamicSavingsAccount);
+               assertNotNull("The account property in the static customer has 
to be set",
+                 ((Customer)staticCustomer).getAccount());
+       }
+
+       public void testSetStaticToDynamic() {
+               DataFactory factory = scope.getDataFactory();
+
+               DataObject dynamicSavingsAccount = factory.create(NS_DYNAMIC, 
"SavingsAccount");
+               DataObject staticAddress = factory.create(Address.class);
+
+               dynamicSavingsAccount.set("alternateAddress", staticAddress);
+               assertTrue("The address property on the dynamic account object 
has to be set",
+                 dynamicSavingsAccount.isSet("alternateAddress"));
+       }
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               scope = SDOUtil.createHelperContext();
+
+               StatictypesFactory.INSTANCE.register(scope);
+
+        // Populate the meta data for the models
+               for (int i = 0; i < MODELS.length; i++) {
+                       String model = MODELS[i];
+               URL url = getClass().getResource(model);
+               InputStream inputStream = url.openStream();
+               scope.getXSDHelper().define(inputStream, url.toString());
+               inputStream.close();
+               }
+       }
+
+}

Added: 
incubator/tuscany/java/sdo/toolsTest/src/test/resources/mixedTypesDynamic.xsd
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/resources/mixedTypesDynamic.xsd?rev=572947&view=auto
==============================================================================
--- 
incubator/tuscany/java/sdo/toolsTest/src/test/resources/mixedTypesDynamic.xsd 
(added)
+++ 
incubator/tuscany/java/sdo/toolsTest/src/test/resources/mixedTypesDynamic.xsd 
Wed Sep  5 06:14:47 2007
@@ -0,0 +1,50 @@
+<?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:dynamictypes="http://www.example.com/mixedtypes/dynamictypes";
+        xmlns:statictypes="http://www.example.com/mixedtypes/statictypes";
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+       elementFormDefault="qualified"
+       targetNamespace="http://www.example.com/mixedtypes/dynamictypes";>
+
+       <xsd:import namespace="http://www.example.com/mixedtypes/statictypes";
+               schemaLocation="mixedtypesstatictypes.xsd" />
+       
+       <xsd:complexType name="SavingsAccount">
+               <xsd:complexContent>
+                       <xsd:extension base="statictypes:Account">
+                               <xsd:sequence>
+                                       <xsd:element name="interest" 
type="xsd:int" />
+                                       <xsd:element name="alternateAddress" 
type="statictypes:Address" />
+                               </xsd:sequence>
+                       </xsd:extension>
+               </xsd:complexContent>
+       </xsd:complexType>
+
+       <xsd:complexType name="HomeAddress">
+               <xsd:complexContent>
+                       <xsd:extension base="statictypes:Address">
+                               <xsd:sequence>
+                                       <xsd:element name="email" 
type="xsd:string" />
+                               </xsd:sequence>
+                       </xsd:extension>
+               </xsd:complexContent>
+       </xsd:complexType>
+               
+</xsd:schema>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to