You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/04/25 11:41:37 UTC
svn commit: r532283 - in
/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src:
main/java/org/apache/tuscany/sdo/util/
main/java/org/apache/tuscany/sdo/util/resource/ test/java/com/example/test/
test/java/com/example/test/Containment/ test...
Author: kelvingoodson
Date: Wed Apr 25 02:41:36 2007
New Revision: 532283
URL: http://svn.apache.org/viewvc?view=rev&rev=532283
Log:
TUSCANY-1171 port fix for Tuscany 826 to beta1 tag
Added:
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java (with props)
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentTest.java (with props)
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java (with props)
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java (with props)
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java (with props)
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java (with props)
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd (with props)
Modified:
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java
incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
Modified: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java?view=diff&rev=532283&r1=532282&r2=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java (original)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java Wed Apr 25 02:41:36 2007
@@ -2597,10 +2597,14 @@
}
*/
- protected static StringBuffer getXPath(DataObject dataObject, StringBuffer path)
+ protected static StringBuffer getXPath(DataObject dataObject, StringBuffer path, DataObject root)
{
DataObject container = dataObject.getContainer();
if (container == null) return path;
+
+ if (container == root) {
+ throw new IllegalStateException("There is a cycle in the containment hierarchy of " + root);
+ }
boolean first = path.length() == 0;
Property property = dataObject.getContainmentProperty();
@@ -2615,12 +2619,12 @@
path.insert(0, property.getName() + (first ? "" : "/"));
}
- return getXPath(container, path);
+ return getXPath(container, path, root);
}
public static String getXPath(DataObject dataObject)
{
- StringBuffer path = getXPath(dataObject, new StringBuffer());
+ StringBuffer path = getXPath(dataObject, new StringBuffer(), dataObject);
return path.toString();
}
Modified: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java?view=diff&rev=532283&r1=532282&r2=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java (original)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java Wed Apr 25 02:41:36 2007
@@ -56,6 +56,8 @@
private String rootElementURI;
private String rootElementName;
+
+ private DataObject serializeRoot;
private TypeHelper typeHelper;
@@ -104,6 +106,7 @@
this.dataObject = dataObject;
this.rootElementURI = rootElmentURI;
this.rootElementName = rootElementName;
+ this.serializeRoot = dataObject;
this.typeHelper = typeHelper == null ? TypeHelper.INSTANCE : typeHelper;
this.xsdHelper = (xsdHelper != null) ? xsdHelper : ((typeHelper == null) ? XSDHelper.INSTANCE : SDOUtil.createXSDHelper(typeHelper));
rootElement = this.xsdHelper.getGlobalProperty(rootElmentURI, rootElementName, true);
@@ -120,6 +123,15 @@
this.rootElementName = xsdHelper.getLocalName(rootElement);
}
+ protected DataObjectXMLStreamReader(TypeHelper typeHelper, XSDHelper xsdHelper, Property rootElement, DataObject dataObject, DataObject serializeRoot) {
+ this.typeHelper = typeHelper == null ? TypeHelper.INSTANCE : typeHelper;
+ this.xsdHelper = (xsdHelper != null) ? xsdHelper : ((typeHelper == null) ? XSDHelper.INSTANCE : SDOUtil.createXSDHelper(typeHelper));
+ this.rootElement = rootElement;
+ this.dataObject = dataObject;
+ this.serializeRoot = serializeRoot;
+ this.rootElementURI = xsdHelper.getNamespaceURI(rootElement);
+ this.rootElementName = xsdHelper.getLocalName(rootElement);
+ }
public DataObjectXMLStreamReader(Property rootElement, DataObject dataObject, TypeHelper typeHelper, XSDHelper xsdHelper) {
this(typeHelper, xsdHelper, rootElement, dataObject);
namespaceContext = new NameSpaceContext();
@@ -130,6 +142,7 @@
this.dataObject = document.getRootObject();
this.rootElementName = document.getRootElementName();
this.rootElementURI = document.getRootElementURI();
+ this.serializeRoot = this.dataObject;
this.typeHelper = typeHelper;
this.xsdHelper = typeHelper == null ? XSDHelper.INSTANCE : SDOUtil.createXSDHelper(typeHelper);
namespaceContext = new NameSpaceContext();
@@ -231,8 +244,11 @@
} else if (propertyType.isDataType()) {
Map.Entry entry = new NameValuePair(qname, SDOUtil.convertToString(propertyType, value));
propertyList.add(entry);
+ } else if (property.isContainment() && value == serializeRoot) {
+ // do not create the childReader because a containmentCycle exists and this is the second
+ // time this DataObject has been encountered
} else {
- DataObjectXMLStreamReader childReader = new DataObjectXMLStreamReader(typeHelper, xsdHelper, property, (DataObject) value);
+ DataObjectXMLStreamReader childReader = new DataObjectXMLStreamReader(typeHelper, xsdHelper, property, (DataObject) value, serializeRoot);
childReader.namespaceContext = namespaceContext;
childReader.populateProperties();
childReader.rootElement = property;
Added: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java?view=auto&rev=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java (added)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java Wed Apr 25 02:41:36 2007
@@ -0,0 +1,61 @@
+/**
+ *
+ * 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 com.example.test.Containment;
+
+import commonj.sdo.helper.HelperContext;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public interface ContainmentFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ ContainmentFactory INSTANCE = com.example.test.Containment.impl.ContainmentFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Test</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Test</em>'.
+ * @generated
+ */
+ ContainmentTest createContainmentTest();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //ContainmentFactory
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentTest.java?view=auto&rev=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentTest.java (added)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentTest.java Wed Apr 25 02:41:36 2007
@@ -0,0 +1,177 @@
+/**
+ *
+ * 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 com.example.test.Containment;
+
+import commonj.sdo.Sequence;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Test</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link com.example.test.Containment.ContainmentTest#getMixed <em>Mixed</em>}</li>
+ * <li>{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}</li>
+ * <li>{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}</li>
+ * <li>{@link com.example.test.Containment.ContainmentTest#getContainMany <em>Contain Many</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface ContainmentTest extends Serializable
+{
+ /**
+ * Returns the value of the '<em><b>Mixed</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Mixed</em>' attribute list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Mixed</em>' attribute list.
+ * @generated
+ */
+ Sequence getMixed();
+
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #setName(String)
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ void unsetName();
+
+ /**
+ * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Name</em>' attribute is set.
+ * @see #unsetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ boolean isSetName();
+
+ /**
+ * Returns the value of the '<em><b>Contain</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Contain</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Contain</em>' containment reference.
+ * @see #isSetContain()
+ * @see #unsetContain()
+ * @see #setContain(ContainmentTest)
+ * @generated
+ */
+ ContainmentTest getContain();
+
+ /**
+ * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Contain</em>' containment reference.
+ * @see #isSetContain()
+ * @see #unsetContain()
+ * @see #getContain()
+ * @generated
+ */
+ void setContain(ContainmentTest value);
+
+ /**
+ * Unsets the value of the '{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetContain()
+ * @see #getContain()
+ * @see #setContain(ContainmentTest)
+ * @generated
+ */
+ void unsetContain();
+
+ /**
+ * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}' containment reference is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Contain</em>' containment reference is set.
+ * @see #unsetContain()
+ * @see #getContain()
+ * @see #setContain(ContainmentTest)
+ * @generated
+ */
+ boolean isSetContain();
+
+ /**
+ * Returns the value of the '<em><b>Contain Many</b></em>' containment reference list.
+ * The list contents are of type {@link com.example.test.Containment.ContainmentTest}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Contain Many</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Contain Many</em>' containment reference list.
+ * @generated
+ */
+ List getContainMany();
+
+} // ContainmentTest
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/ContainmentTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java?view=auto&rev=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java (added)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java Wed Apr 25 02:41:36 2007
@@ -0,0 +1,267 @@
+/**
+ *
+ * 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 com.example.test.Containment.impl;
+
+import commonj.sdo.helper.HelperContext;
+import org.apache.tuscany.sdo.helper.TypeHelperImpl;
+
+import com.example.test.Containment.*;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+import org.apache.tuscany.sdo.SDOFactory;
+
+import org.apache.tuscany.sdo.impl.FactoryBase;
+
+import org.apache.tuscany.sdo.model.ModelFactory;
+
+import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * Generator information:
+ * patternVersion=1.1; -prefix Containment
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class ContainmentFactoryImpl extends FactoryBase implements ContainmentFactory
+{
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "http://www.example.com/ContainmentTest";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "contain";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String PATTERN_VERSION = "1.1";
+
+ public static final int CONTAINMENT_TEST = 1;
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ContainmentFactoryImpl()
+ {
+ super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.example.test.Containment");
+ }
+
+ /**
+ * Registers the Factory instance so that it is available within the supplied scope.
+ * @argument scope a HelperContext instance that will make the types supported by this Factory available.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void register(HelperContext scope) {
+ if(scope == null) {
+ throw new IllegalArgumentException("Scope can not be null");
+ }
+ TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
+ th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataObject create(int typeNumber)
+ {
+ switch (typeNumber)
+ {
+ case CONTAINMENT_TEST: return (DataObject)createContainmentTest();
+ default:
+ return super.create(typeNumber);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ContainmentTest createContainmentTest()
+ {
+ ContainmentTestImpl containmentTest = new ContainmentTestImpl();
+ return containmentTest;
+ }
+
+ // Following creates and initializes SDO metadata for the supported types.
+ protected Type containmentTestType = null;
+
+ public Type getContainmentTest()
+ {
+ return containmentTestType;
+ }
+
+
+ private static boolean isInited = false;
+
+ public static ContainmentFactoryImpl init()
+ {
+ if (isInited) return (ContainmentFactoryImpl)FactoryBase.getStaticFactory(ContainmentFactoryImpl.NAMESPACE_URI);
+ ContainmentFactoryImpl theContainmentFactoryImpl = new ContainmentFactoryImpl();
+ isInited = true;
+
+ // Initialize simple dependencies
+ SDOUtil.registerStaticTypes(SDOFactory.class);
+ SDOUtil.registerStaticTypes(ModelFactory.class);
+
+ // Create package meta-data objects
+ theContainmentFactoryImpl.createMetaData();
+
+ // Initialize created meta-data
+ theContainmentFactoryImpl.initializeMetaData();
+
+ // Mark meta-data to indicate it can't be changed
+ //theContainmentFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ????
+
+ return theContainmentFactoryImpl;
+ }
+
+ private boolean isCreated = false;
+
+ public void createMetaData()
+ {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create types and their properties
+ containmentTestType = createType(false, CONTAINMENT_TEST);
+ createProperty(true, containmentTestType,ContainmentTestImpl.INTERNAL_MIXED);
+ createProperty(true, containmentTestType,ContainmentTestImpl.INTERNAL_NAME);
+ createProperty(false, containmentTestType,ContainmentTestImpl.INTERNAL_CONTAIN);
+ createProperty(false, containmentTestType,ContainmentTestImpl.INTERNAL_CONTAIN_MANY);
+ }
+
+ private boolean isInitialized = false;
+
+ public void initializeMetaData()
+ {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Obtain other dependent packages
+ ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)FactoryBase.getStaticFactory(ModelFactoryImpl.NAMESPACE_URI);
+ Property property = null;
+
+ // Add supertypes to types
+
+ // Initialize types and properties
+ initializeType(containmentTestType, ContainmentTest.class, "ContainmentTest", false);
+ property = getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_MIXED);
+ initializeProperty(property, getSequence(), "mixed", null, 0, -1, ContainmentTest.class, false, false, false);
+
+ property = getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_NAME);
+ initializeProperty(property, theModelPackageImpl.getString(), "Name", null, 1, 1, ContainmentTest.class, false, true, true);
+
+ property = getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_CONTAIN);
+ initializeProperty(property, this.getContainmentTest(), "Contain", null, 1, 1, ContainmentTest.class, false, true, true, true , null);
+
+ property = getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_CONTAIN_MANY);
+ initializeProperty(property, this.getContainmentTest(), "ContainMany", null, 0, -1, ContainmentTest.class, false, false, true, true , null);
+
+ createXSDMetaData(theModelPackageImpl);
+ }
+
+ protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl)
+ {
+ super.initXSD();
+
+ Property property = null;
+
+
+ addXSDMapping
+ (containmentTestType,
+ new String[]
+ {
+ "name", "ContainmentTest",
+ "kind", "mixed"
+ });
+
+ addXSDMapping
+ (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_MIXED),
+ new String[]
+ {
+ "kind", "elementWildcard",
+ "name", ":mixed"
+ });
+
+ addXSDMapping
+ (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_NAME),
+ new String[]
+ {
+ "kind", "element",
+ "name", "Name"
+ });
+
+ addXSDMapping
+ (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_CONTAIN),
+ new String[]
+ {
+ "kind", "element",
+ "name", "Contain"
+ });
+
+ addXSDMapping
+ (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_CONTAIN_MANY),
+ new String[]
+ {
+ "kind", "element",
+ "name", "ContainMany"
+ });
+
+ property = createGlobalProperty
+ ("containTestInstance",
+ this.getContainmentTest(),
+ new String[]
+ {
+ "kind", "element",
+ "name", "containTestInstance",
+ "namespace", "##targetNamespace"
+ });
+
+ }
+
+} //ContainmentFactoryImpl
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java?view=auto&rev=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java (added)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java Wed Apr 25 02:41:36 2007
@@ -0,0 +1,409 @@
+/**
+ *
+ * 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 com.example.test.Containment.impl;
+
+import com.example.test.Containment.ContainmentFactory;
+import com.example.test.Containment.ContainmentTest;
+
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sdo.impl.DataObjectBase;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Test</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getMixed <em>Mixed</em>}</li>
+ * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getName <em>Name</em>}</li>
+ * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getContain <em>Contain</em>}</li>
+ * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getContainMany <em>Contain Many</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class ContainmentTestImpl extends DataObjectBase implements ContainmentTest
+{
+
+ public final static int MIXED = -1;
+
+ public final static int NAME = 0;
+
+ public final static int CONTAIN = 1;
+
+ public final static int CONTAIN_MANY = 2;
+
+ public final static int SDO_PROPERTY_COUNT = 3;
+
+ public final static int EXTENDED_PROPERTY_COUNT = -1;
+
+
+ /**
+ * The internal feature id for the '<em><b>Mixed</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_MIXED = 0;
+
+ /**
+ * The internal feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_NAME = 1;
+
+ /**
+ * The internal feature id for the '<em><b>Contain</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_CONTAIN = 2;
+
+ /**
+ * The internal feature id for the '<em><b>Contain Many</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_CONTAIN_MANY = 3;
+
+ /**
+ * The number of properties for this type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_PROPERTY_COUNT = 4;
+
+ protected int internalConvertIndex(int internalIndex)
+ {
+ switch (internalIndex)
+ {
+ case INTERNAL_MIXED: return MIXED;
+ case INTERNAL_NAME: return NAME;
+ case INTERNAL_CONTAIN: return CONTAIN;
+ case INTERNAL_CONTAIN_MANY: return CONTAIN_MANY;
+ }
+ return super.internalConvertIndex(internalIndex);
+ }
+
+
+ /**
+ * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMixed()
+ * @generated
+ * @ordered
+ */
+
+ protected Sequence mixed = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ContainmentTestImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Type getType()
+ {
+ return ((ContainmentFactoryImpl)ContainmentFactory.INSTANCE).getContainmentTest();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Sequence getMixed()
+ {
+ if (mixed == null)
+ {
+ mixed = createSequence(INTERNAL_MIXED);
+ }
+ return mixed;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName()
+ {
+ return (String)get(getMixed(), getType(), INTERNAL_NAME);
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName)
+ {
+ set(getMixed(), getType(), INTERNAL_NAME, newName);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unsetName()
+ {
+ unset(getMixed(), getType(), INTERNAL_NAME);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetName()
+ {
+ return isSet(getMixed(), getType(), INTERNAL_NAME);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ContainmentTest getContain()
+ {
+ return (ContainmentTest)get(getMixed(), getType(), INTERNAL_CONTAIN);
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ChangeContext basicSetContain(ContainmentTest newContain, ChangeContext changeContext)
+ {
+ return basicAdd(getMixed(), getType(), INTERNAL_CONTAIN, newContain, changeContext);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setContain(ContainmentTest newContain)
+ {
+ set(getMixed(), getType(), INTERNAL_CONTAIN, newContain);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ChangeContext basicUnsetContain(ChangeContext changeContext)
+ {
+ // TODO: implement this method to unset the contained 'Contain' containment reference
+ // -> this method is automatically invoked to keep the containment relationship in synch
+ // -> do not modify other features
+ // -> return changeContext, after adding any generated Notification to it (if it is null, a NotificationChain object must be created first)
+ // Ensure that you remove @generated or mark it @generated NOT
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unsetContain()
+ {
+ unset(getMixed(), getType(), INTERNAL_CONTAIN);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetContain()
+ {
+ return isSet(getMixed(), getType(), INTERNAL_CONTAIN);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public List getContainMany()
+ {
+ return getList(getMixed(), getType(), INTERNAL_CONTAIN_MANY);
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext)
+ {
+ switch (propertyIndex)
+ {
+ case MIXED:
+ return removeFromSequence(getMixed(), otherEnd, changeContext);
+ case CONTAIN:
+ return basicUnsetContain(changeContext);
+ case CONTAIN_MANY:
+ return removeFromList(getContainMany(), otherEnd, changeContext);
+ }
+ return super.inverseRemove(otherEnd, propertyIndex, changeContext);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object get(int propertyIndex, boolean resolve)
+ {
+ switch (propertyIndex)
+ {
+ case MIXED:
+ // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view
+ //if (coreType)
+ return getMixed();
+ case NAME:
+ return getName();
+ case CONTAIN:
+ return getContain();
+ case CONTAIN_MANY:
+ return getContainMany();
+ }
+ return super.get(propertyIndex, resolve);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void set(int propertyIndex, Object newValue)
+ {
+ switch (propertyIndex)
+ {
+ case MIXED:
+ setSequence(getMixed(), newValue);
+ return;
+ case NAME:
+ setName((String)newValue);
+ return;
+ case CONTAIN:
+ setContain((ContainmentTest)newValue);
+ return;
+ case CONTAIN_MANY:
+ getContainMany().clear();
+ getContainMany().addAll((Collection)newValue);
+ return;
+ }
+ super.set(propertyIndex, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unset(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case MIXED:
+ unsetSequence(getMixed());
+ return;
+ case NAME:
+ unsetName();
+ return;
+ case CONTAIN:
+ unsetContain();
+ return;
+ case CONTAIN_MANY:
+ getContainMany().clear();
+ return;
+ }
+ super.unset(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSet(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case MIXED:
+ return mixed != null && !isSequenceEmpty(getMixed());
+ case NAME:
+ return isSetName();
+ case CONTAIN:
+ return isSetContain();
+ case CONTAIN_MANY:
+ return !getContainMany().isEmpty();
+ }
+ return super.isSet(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString()
+ {
+ if (isProxy(this)) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (mixed: ");
+ result.append(mixed);
+ result.append(')');
+ return result.toString();
+ }
+
+} //ContainmentTestImpl
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java?view=diff&rev=532283&r1=532282&r2=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java (original)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java Wed Apr 25 02:41:36 2007
@@ -33,6 +33,7 @@
suite.addTestSuite(ChangeSummaryOnDataObjectTestCase.class);
suite.addTestSuite(ChangeSummaryPropertyTestCase.class);
suite.addTestSuite(ChangeSummaryTestCase.class);
+ suite.addTestSuite(ContainmentCycleTestCase.class);
suite.addTestSuite(CrossScopeCopyTestCase.class);
suite.addTestSuite(DataGraphTestCase.class);
suite.addTestSuite(DataTypeBaseTypeTestCase.class);
Added: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java?view=auto&rev=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java (added)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java Wed Apr 25 02:41:36 2007
@@ -0,0 +1,864 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import junit.framework.TestCase;
+import commonj.sdo.DataObject;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import org.apache.tuscany.sdo.helper.XMLStreamHelper;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import com.example.test.Containment.ContainmentFactory;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests serialization of containment cycles. For JavaSerialization, the test case
+ * passes if an IllegalStateException is thrown. For XMLHelper and XMLStreamHelper
+ * serialization, serization should complete without throwing an Exception. In all
+ * cases, the actual structure of the DataObject should not be changed by the
+ * method call to serialize the DO.
+ *
+ * The same test is run for a static model (Type created using XSD2JavaGenerator), a
+ * dynamic model (Type created using TypeHelper), and a 'mixed' model (Type created
+ * using XSDHelper - dynamic Type creation using static resources).
+ */
+public class ContainmentCycleTestCase extends TestCase {
+
+ private static final String CONTAIN_URI = "http://www.example.com/ContainmentTest";
+ private static final String CONTAIN_TYPE = "ContainmentTest";
+ private static HelperContext staticScope;
+ private static HelperContext dynamicScope;
+ private static HelperContext mixedScope;
+ private static boolean initialized = false;
+ private static boolean mixedCreated = false;
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property
+ * and verify the behavior of serialization. This is the static version of this test case.
+ */
+ // Note: Static test cases are prevented due to a JVM Error in ObjectOutputStream.
+ // The IllegalStateException thrown by Java serialization is caught, which in turn allows
+ // the StackOverflowException to occur. The catcher is catching RuntimeException, so it does
+ // not matter which Exception is thrown by the SDO code.
+ public void atestStaticOneMemberSingleValueSetDataObject() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+
+ setSingleValueOneMember(dataObj1);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using set____ on a single valued property
+ * and verify the behavior of serialization. This is the static version of this test case.
+ */
+ public void atestStaticNMemberSingleValueSetDataObject() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setSingleValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property
+ * and verify the behavior of serialization. This is the static version of this test case.
+ */
+ public void atestStaticOneMemberMultiValueSetDataObject() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setMultiValueOneMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property
+ * and verify the behavior of serialization. This is the static version of this test case.
+ */
+ public void atestStaticNMemberMultiValueSetDataObject() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setManyValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle by making updates to a List returned
+ * from the DataObject and verify the behavior of serialization. This is the static version
+ * of this test case.
+ */
+ public void atestStaticOneMemberReturnedList() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+
+ returnedListOneMember(dataObj1);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle by making updates to a List returned
+ * from the DataObject and verify the behavior of serialization. This is the static version
+ * of this test case.
+ */
+ public void atestStaticNMemberReturnedList() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ returnedListNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a single valued property, and verify the behavior of
+ * serialization. This is the static version of this test case.
+ */
+ public void atestStaticOneMemberSingleValueSequence() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+
+ sequenceSingleValueOneMember(dataObj1);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a single valued property, and verify the behavior of
+ * serialization. This is the static version of this test case.
+ */
+ public void atestStaticNMemberSingleValueSequence() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a multi valued property, and verify the behavior of
+ * serialization. This is the static version of this test case.
+ */
+ public void atestStaticOneMemberMultiValueSequence() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a multi valued property, and verify the behavior of
+ * serialization. This is the static version of this test case.
+ */
+ public void atestStaticNMemberMultiValueSequence() {
+ DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceManyValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, staticScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property
+ * and verify the behavior of serialization. This is the hybrid version of this test case.
+ */
+ public void testHybridOneMemberSingleValueSetDataObject() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+
+ setSingleValueOneMember(dataObj1);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using set____ on a single valued property
+ * and verify the behavior of serialization. This is the hybrid version of this test case.
+ */
+ public void testHybridNMemberSingleValueSetDataObject() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setSingleValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property
+ * and verify the behavior of serialization. This is the hybrid version of this test case.
+ */
+ public void testHybridOneMemberMultiValueSetDataObject() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setMultiValueOneMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property
+ * and verify the behavior of serialization. This is the hybrid version of this test case.
+ */
+ public void testHybridNMemberMultiValueSetDataObject() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setManyValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle by making updates to a List returned
+ * from the DataObject and verify the behavior of serialization. This is the hybrid version
+ * of this test case.
+ */
+ public void testHybridOneMemberReturnedList() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+
+ returnedListOneMember(dataObj1);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle by making updates to a List returned
+ * from the DataObject and verify the behavior of serialization. This is the hybrid version
+ * of this test case.
+ */
+ public void testHybridNMemberReturnedList() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ returnedListNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a single valued property, and verify the behavior of
+ * serialization. This is the hybrid version of this test case.
+ */
+ public void testHybridOneMemberSingleValueSequence() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+
+ sequenceSingleValueOneMember(dataObj1);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a single valued property, and verify the behavior of
+ * serialization. This is the hybrid version of this test case.
+ */
+ public void testHybridNMemberSingleValueSequence() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a multi valued property, and verify the behavior of serialization.
+ * This is the hybrid version of this test case.
+ */
+ public void testHybridOneMemberMultiValueSequence() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a multi valued property, and verify the behavior of serialization.
+ * This is the hybrid version of this test case.
+ */
+ public void testHybridNMemberMultiValueSequence() {
+ assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated);
+
+ DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceManyValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, mixedScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property
+ * and verify the behavior of serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicOneMemberSingleValueSetDataObject() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+
+ setSingleValueOneMember(dataObj1);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using set____ on a single valued property
+ * and verify the behavior of serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicNMemberSingleValueSetDataObject() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setSingleValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property
+ * and verify the behavior of serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicOneMemberMultiValueSetDataObject() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setMultiValueOneMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property
+ * and verify the behavior of serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicNMemberMultiValueSetDataObject() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ setManyValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle by making updates to a List returned
+ * from the DataObject and verify the behavior of serialization. This is the dynamic version
+ * of this test case.
+ */
+ public void testDynamicOneMemberReturnedList() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+
+ returnedListOneMember(dataObj1);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle by making updates to a List returned
+ * from the DataObject and verify the behavior of serialization. This is the dynamic version
+ * of this test case.
+ */
+ public void testDynamicNMemberReturnedList() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ returnedListNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a single valued property, and verify the behavior of
+ * serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicOneMemberSingleValueSequence() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+
+ sequenceSingleValueOneMember(dataObj1);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a single valued property, and verify the behavior of
+ * serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicNMemberSingleValueSequence() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a multi valued property, and verify the behavior of
+ * serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicOneMemberMultiValueSequence() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates
+ * to the DataObject, affecting a multi valued property, and verify the behavior of
+ * serialization. This is the dynamic version of this test case.
+ */
+ public void testDynamicNMemberMultiValueSequence() {
+ DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ dataObj1.setString("Name", "dataObj1");
+ dataObj2.setString("Name", "dataObj2");
+ dataObj3.setString("Name", "dataObj3");
+
+ sequenceManyValueNMember(dataObj1, dataObj2, dataObj3);
+ attemptSerialization(dataObj1, dynamicScope);
+ }
+
+ /**
+ * Attempt to serialize the DataObject in via XML, XMLStreamHelper,
+ * and Java serialization.
+ * @param dataObj
+ */
+ private void attemptSerialization(DataObject dataObj, HelperContext scope) {
+
+ assertTrue("Containment cycle was not established.",
+ containmentCycleExists(dataObj));
+
+ try {
+ serializeDataObjectXML(dataObj, scope);
+ } catch (Exception e) {
+ fail("XML serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + ".");
+ e.printStackTrace();
+ }
+
+ assertTrue("Containment cycle was affected by XMLHelper serialization.",
+ containmentCycleExists(dataObj));
+
+ try {
+ serializeDataObjectJava(dataObj);
+ fail("Java serialization of a containment cycle should result in an IllegalStateException.");
+ } catch (Exception e) {
+ // Do nothing. An Exception is expected in this case.
+ }
+
+ assertTrue("Containment cycle was affected by Java serialization.",
+ containmentCycleExists(dataObj));
+
+ try {
+ serializeDataObjectStream(dataObj, scope);
+ } catch (Exception e) {
+ fail("XMLStreamHelper serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + ".");
+ e.printStackTrace();
+ }
+ assertTrue("Containment cycle was affected by XMLStreamHelper serialization.",
+ containmentCycleExists(dataObj));
+ }
+ /**
+ * Uses the XMLHelper to serialize the input DataObject
+ *
+ * @param dataObject
+ * @param fileName
+ * @throws IOException
+ */
+ private static void serializeDataObjectXML(DataObject dataObject, HelperContext scope) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Type type = dataObject.getType();
+
+ try {
+ scope.getXMLHelper().save(dataObject, type.getURI(), type.getName(), baos);
+ }
+ catch (IOException e) {
+ fail("Could not complete test case due to IOException.");
+ }
+ }
+
+ /**
+ * Uses Java serialization to serialize the input DataObject
+ *
+ * @param dataObject
+ * @param fileName
+ * @throws IOException
+ */
+ private static void serializeDataObjectStream(DataObject dataObject, HelperContext scope) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ XMLStreamWriter serializer;
+ XMLStreamHelper xmlStreamHelper = SDOUtil.createXMLStreamHelper(scope.getTypeHelper());
+ try {
+ serializer = factory.createXMLStreamWriter(baos);
+ xmlStreamHelper.saveObject(dataObject, serializer);
+ serializer.flush();
+ }
+ catch (XMLStreamException e) {
+ fail("Exception encountered during XMLStreamHelper serialization.");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Uses Java serialization to serialize the input DataObject
+ *
+ * @param dataObject
+ * @param fileName
+ * @throws IOException
+ */
+ private static void serializeDataObjectJava(DataObject dataObject) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try {
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ out.writeObject(dataObject);
+ out.close();
+ }
+ catch (IOException e) {
+ fail("Could not complete test case due to IOException.");
+ }
+ }
+
+ /**
+ * Returns true if input DataObject root is part of a containment cycle,
+ * false otherwise.
+ * @param root
+ * @return
+ */
+ private static boolean containmentCycleExists (DataObject root)
+ {
+ DataObject curr = root.getContainer();
+
+ while (curr != null)
+ {
+ if (curr == root)
+ return true;
+
+ curr = curr.getContainer();
+ }
+ return false;
+ }
+
+ /**
+ * Use setDataObject to create a one member containment cycle.
+ * @param dataObj1
+ */
+ private void setSingleValueOneMember(DataObject dataObj1) {
+ dataObj1.setDataObject("Contain", dataObj1);
+ }
+
+ /**
+ * Use setDataObject to create an N-member containment cycle.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataobj3
+ */
+ private void setSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) {
+ dataObj1.setDataObject("Contain", dataObj2);
+ dataObj2.setDataObject("Contain", dataObj3);
+ dataObj3.setDataObject("Contain", dataObj1);
+ }
+
+ /**
+ * Use setList to create a one member containment cycle.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataObj3
+ */
+ private void setMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) {
+ List addList = new ArrayList();
+
+ addList.add(dataObj2);
+ addList.add(dataObj1);
+ addList.add(dataObj3);
+ dataObj1.setList("ContainMany", addList);
+ }
+
+ /**
+ * Use setList to create an N-member containment cycle.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataObj3
+ */
+ private void setManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) {
+ List addList = new ArrayList();
+
+ dataObj1.setDataObject("Contain", dataObj2);
+ dataObj2.setDataObject("Contain", dataObj3);
+ addList.add(dataObj1);
+ dataObj3.setList("ContainMany", addList);
+ }
+
+ /**
+ * Create a 1-member containment cycle by making updates to a returned List.
+ * @param dataObj1
+ */
+ private void returnedListOneMember(DataObject dataObj1) {
+ List returnedList = dataObj1.getList("ContainMany");
+
+ returnedList.add(dataObj1);
+ }
+
+ /**
+ * Create an n-member containment cycle by making updates to a returned List.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataobj3
+ */
+ private void returnedListNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) {
+ dataObj1.setDataObject("Contain", dataObj2);
+ dataObj2.setDataObject("Contain", dataObj3);
+
+ List returnedList = dataObj3.getList("ContainMany");
+
+ returnedList.add(dataObj1);
+ }
+
+ /**
+ * Create a 1-member containment cycle by making updates to a Sequence.
+ * The data member in this case is single valued.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataObj3
+ */
+ private void sequenceSingleValueOneMember(DataObject dataObj1) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ Sequence sequence = dataObj1.getSequence();
+
+ sequence.add("Contain", dataObj1);
+ }
+
+ /**
+ * Create an n-member containment cycle by making updates to a Sequence.
+ * The data member in this case is single valued.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataObj3
+ */
+ private void sequenceSingleValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ Sequence sequence1 = dataObj1.getSequence();
+ Sequence sequence2 = dataObj2.getSequence();
+ Sequence sequence3 = dataObj3.getSequence();
+
+ sequence1.add("Contain", (Object) dataObj2);
+ sequence2.add("Contain", (Object) dataObj3);
+
+ sequence3.add("Contain", (Object) dataObj1);
+ }
+
+ /**
+ * Create a 1-member containment cycle by making updates to a Sequence.
+ * The data member in this case is many valued.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataObj3
+ */
+ private void sequenceMultiValueOneMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ Sequence sequence = dataObj1.getSequence();
+
+ sequence.add("ContainMany", dataObj2);
+ sequence.add("ContainMany", dataObj3);
+ sequence.add("ContainMany", dataObj1);
+ }
+
+ /**
+ * Create an n-member containment cycle by making updates to a Sequence.
+ * The data member in this case is many valued.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataObj3
+ */
+ private void sequenceManyValueNMember(DataObject dataObj1, DataObject dataObj2, DataObject dataObj3) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ List addList = new ArrayList();
+
+ addList.add(dataObj2);
+ dataObj1.setList("ContainMany", addList);
+
+ addList.clear();
+ addList.add(dataObj3);
+ dataObj2.setList("ContainMany", addList);
+
+ Sequence sequence = dataObj3.getSequence();
+
+ sequence.add("ContainMany", dataObj1);
+ }
+
+ public void setUp() {
+ if (!initialized) {
+ staticScope = SDOUtil.createHelperContext();
+ ContainmentFactory.INSTANCE.register(staticScope);
+
+ dynamicScope = SDOUtil.createHelperContext();
+ ContainmentTypeUtil.createDynamically(dynamicScope);
+
+ mixedScope = SDOUtil.createHelperContext();
+ mixedCreated = ContainmentTypeUtil.createDynamicWithStaticResources(mixedScope);
+
+ initialized = true;
+ }
+ }
+}
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java?view=auto&rev=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java (added)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java Wed Apr 25 02:41:36 2007
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Provides methods to dynamically create the ContainemntTest Type using the XSDHelper
+ * and the TypeHelper.
+ */
+public class ContainmentTypeUtil {
+
+ /**
+ * createDynamicWithStaticResources creates the DataObject type from an existing
+ * XSD. The same XSD is used to create the Types statically using the XSD2JavaGenerator.
+ * The XSD should be kept in synch with the createDynamically method in this class.
+ * @throws IOException
+ * @return true if
+ */
+ public static boolean createDynamicWithStaticResources(HelperContext hc) {
+ try {
+ // Populate the meta data for the test model (ContainTest)
+ URL url = ContainmentCycleTestCase.class.getResource("/containmenttest.xsd");
+ InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ } catch(IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * createDynamically() creates the SDO Types using the TypeHelper. This method should be kept in
+ * synch with the XSD used for createDynamicallyWithStaticResources. The same XSD is used for
+ * the static generation of SDO Types using XSD2JavaGenerator.
+ */
+ public static void createDynamically(HelperContext hc) {
+ TypeHelper types = hc.getTypeHelper();
+ Type stringType = types.getType("commonj.sdo", "String");
+
+ DataObject testType = hc.getDataFactory().create("commonj.sdo", "Type");
+ testType.set("uri", "http://www.example.com/ContainmentTest");
+ testType.set("name", "ContainmentTest");
+ testType.setBoolean("sequenced", true);
+
+ DataObject nameProperty = testType.createDataObject("property");
+ nameProperty.set("name", "Name");
+ nameProperty.set("type", stringType);
+
+ DataObject containProperty = testType.createDataObject("property");
+ containProperty.set("name", "Contain");
+ containProperty.setBoolean("containment", true);
+ containProperty.set("type", testType);
+
+ DataObject containManyProperty = testType.createDataObject("property");
+ containManyProperty.set("name", "ContainMany");
+ containManyProperty.setBoolean("many", true);
+ containManyProperty.setBoolean("containment", true);
+ containManyProperty.set("type", testType);
+
+ types.define(testType);
+ }
+}
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd?view=auto&rev=532283
==============================================================================
--- incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd (added)
+++ incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd Wed Apr 25 02:41:36 2007
@@ -0,0 +1,12 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:contain="http://www.example.com/ContainmentTest" targetNamespace="http://www.example.com/ContainmentTest">
+
+ <xsd:element name="containTestInstance" type="contain:ContainmentTest"/>
+
+ <xsd:complexType mixed="true" name="ContainmentTest">
+ <xsd:sequence>
+ <xsd:element name="Name" type="xsd:string"/>
+ <xsd:element name="Contain" type="contain:ContainmentTest"/>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="ContainMany" type="contain:ContainmentTest"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/tuscany/tags/java/sdo/1.0-incubating-beta1/sdo/impl/src/test/resources/containmenttest.xsd
------------------------------------------------------------------------------
svn:mime-type = text/xml
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org