Author: kelvingoodson
Date: Thu Aug 30 07:52:45 2007
New Revision: 571193
URL: http://svn.apache.org/viewvc?rev=571193&view=rev
Log:
TUSCANY-1399 more test cases migrated
Added:
incubator/tuscany/java/sdo/toolsTest/src/main/resources/Open.xsd
incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup.xsd
incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup1.xml
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
Modified:
incubator/tuscany/java/sdo/toolsTest/pom.xml
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
Modified: incubator/tuscany/java/sdo/toolsTest/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/pom.xml?rev=571193&r1=571192&r2=571193&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/pom.xml (original)
+++ incubator/tuscany/java/sdo/toolsTest/pom.xml Thu Aug 30 07:52:45 2007
@@ -110,6 +110,24 @@
<goal>generate</goal>
</goals>
</execution>
+ <execution>
+ <id>subgroup</id>
+ <configuration>
+
<schemaFile>${basedir}/src/main/resources/subgroup.xsd</schemaFile>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>openContent</id>
+ <configuration>
+
<schemaFile>${basedir}/src/main/resources/Open.xsd</schemaFile>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
</executions>
</plugin>
</plugins>
Added: incubator/tuscany/java/sdo/toolsTest/src/main/resources/Open.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/Open.xsd?rev=571193&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/src/main/resources/Open.xsd (added)
+++ incubator/tuscany/java/sdo/toolsTest/src/main/resources/Open.xsd Thu Aug 30
07:52:45 2007
@@ -0,0 +1,33 @@
+<?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:open="http://www.example.com/open"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/open">
+
+
+ <xsd:attribute name="globAttribute" type="xsd:string"/>
+
+ <xsd:complexType name="OneElementAndAnyAttr">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:anyAttribute processContents="lax"/>
+ </xsd:complexType>
+
+
+</xsd:schema>
Added: incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup.xsd
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup.xsd?rev=571193&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup.xsd (added)
+++ incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup.xsd Thu
Aug 30 07:52:45 2007
@@ -0,0 +1,48 @@
+<?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.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:sg="http://example.com/subgroup" elementFormDefault="qualified"
targetNamespace="http://example.com/subgroup">
+
+ <element name="a" type="sg:A"/>
+
+ <complexType name="A">
+ <sequence>
+ <element maxOccurs="1" minOccurs="1" ref="sg:ge1"/>
+ </sequence>
+ </complexType>
+
+ <element name="ge1" type="sg:B"/>
+ <element name="se1" substitutionGroup="sg:ge1" type="sg:Bprime"/>
+
+ <complexType name="B">
+ <sequence>
+ <element maxOccurs="1" name="imInTypeB" type="string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="Bprime">
+ <complexContent>
+ <extension base="sg:B">
+ <sequence>
+ <element name="imInTypeBprime" type="string"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
Added: incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup1.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup1.xml?rev=571193&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup1.xml
(added)
+++ incubator/tuscany/java/sdo/toolsTest/src/main/resources/subgroup1.xml Thu
Aug 30 07:52:45 2007
@@ -0,0 +1,23 @@
+<!--
+ * 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.
+ -->
+<subgroup:a xmlns:subgroup="http://example.com/subgroup">
+ <subgroup:ge1>
+ <subgroup:imInTypeB>thisIsElB</subgroup:imInTypeB>
+ </subgroup:ge1>
+</subgroup:a>
Added:
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java?rev=571193&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java
Thu Aug 30 07:52:45 2007
@@ -0,0 +1,102 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.subgroup.A;
+import com.example.subgroup.B;
+import com.example.subgroup.Bprime;
+import com.example.subgroup.SubgroupFactory;
+import com.example.subgroup.impl.AImpl;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+public class InheritanceTestCase extends TestCase {
+
+ private HelperContext scope;
+
+ public void testSubGroupLoad() throws IOException {
+ XMLDocument doc = scope.getXMLHelper().load(
+ getClass().getResourceAsStream("/subgroup1.xml"));
+ assertEquals("a", doc.getRootElementName());
+ String strdoc = scope.getXMLHelper().save(
+ doc.getRootObject(), doc.getRootElementURI(),
doc.getRootElementName());
+
assertTrue(strdoc.indexOf("<sg:imInTypeB>thisIsElB</sg:imInTypeB>") != -1);
+ }
+
+ public void testSubGroup_AcontainsB() {
+ A a = (A) scope.getDataFactory().create(A.class);
+ B b = (B) scope.getDataFactory().create(B.class);
+ b.setImInTypeB("thisIsElB");
+ a.setGe1(b);
+
+ assertSame(b, a.getGe1());
+ assertSame(b, ((AImpl) a).get(AImpl.GE1));
+
+ String doc = scope.getXMLHelper().save((DataObject) a,
+ "http://example.com/subgroup", "a");
+
assertTrue(doc.indexOf("<sg:imInTypeB>thisIsElB</sg:imInTypeB>") != -1);
+
+ }
+
+ public void testSubGroup_AcontainsBprime() {
+ A a = (A) scope.getDataFactory().create(A.class);
+ Bprime bp = (Bprime)
scope.getDataFactory().create(Bprime.class);
+ bp.setImInTypeBprime("thisIsElBprime");
+ a.setGe1(bp);
+
+ assertSame(bp, a.getGe1());
+ assertSame(bp, ((AImpl) a).get(AImpl.GE1));
+
+ String doc = scope.getXMLHelper().save((DataObject) a,
+ "http://example.com/subgroup", "a");
+
+
assertTrue(doc.indexOf("<sg:imInTypeBprime>thisIsElBprime</sg:imInTypeBprime>")
!= -1);
+
+ }
+
+ public void testSubGroup_Bprime() {
+ Bprime bp = (Bprime)
scope.getDataFactory().create(Bprime.class);
+ bp.setImInTypeB("bValue");
+ bp.setImInTypeBprime("bpvalue");
+ String doc = scope.getXMLHelper().save((DataObject) bp,
+ "http://example.com/subgroup", "bp");
+ assertTrue(doc.indexOf("<sg:imInTypeB>bValue</sg:imInTypeB>")
!= -1);
+
assertTrue(doc.indexOf("<sg:imInTypeBprime>bpvalue</sg:imInTypeBprime>") != -1);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scope = SDOUtil.createHelperContext();
+
+ SubgroupFactory.INSTANCE.register(scope);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
Added:
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java?rev=571193&view=auto
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
(added)
+++
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
Thu Aug 30 07:52:45 2007
@@ -0,0 +1,75 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.open.OneElementAndAnyAttr;
+import com.example.open.OpenFactory;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.helper.HelperContext;
+
+
+public class OpenContentTestCase extends TestCase
+{
+
+ HelperContext scope;
+
+ public void testAnyAttribute() throws IOException
+ {
+
+ OpenFactory.INSTANCE.register(scope);
+ DataObject dob =
scope.getDataFactory().create(OneElementAndAnyAttr.class);
+ OneElementAndAnyAttr staticDob = (OneElementAndAnyAttr)dob;
+
+ staticDob.setName("fred");
+
+ assertEquals(1, dob.getInstanceProperties().size());
+ Sequence s = ((OneElementAndAnyAttr)dob).getAnyAttribute();
+
+ assertFalse(dob.getType().isSequenced());
+ assertTrue(dob.getType().isOpen());
+ assertNull(dob.getSequence());
+
+ Property prop =
scope.getTypeHelper().getOpenContentProperty("http://www.example.com/open",
"globAttribute");
+ s.add(prop, "foo");
+ assertEquals(2, dob.getInstanceProperties().size());
+ assertTrue(dob.getInstanceProperties().contains(prop));
+
+ // scope.getXMLHelper().save((DataObject)dob,
"http://www.example.com/open", "bar", System.out);
+ }
+
+ protected void setUp() throws Exception {
+ scope = SDOUtil.createHelperContext();
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+}
Modified:
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java?rev=571193&r1=571192&r2=571193&view=diff
==============================================================================
---
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
(original)
+++
incubator/tuscany/java/sdo/toolsTest/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
Thu Aug 30 07:52:45 2007
@@ -23,15 +23,11 @@
import junit.framework.TestCase;
-import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.sdo.api.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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]