+ *
+ * @generated
+ */
+public class DataTypeImpl extends EDataTypeImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/
+{
+ /**
+ *
+ *
+ * @generated
+ */
+ protected DataTypeImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ protected EClass eStaticClass()
+ {
+ return SDOPackage.eINSTANCE.getDataType();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public String getURI()
+ {
+ return getEPackage().getNsURI();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isDataType()
+ {
+ return true;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isOpen()
+ {
+ return false;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isSequenced()
+ {
+ return false;
+ }
+
+ protected List aliasNames = null;
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getAliasNames()
+ {
+ if (aliasNames == null)
+ {
+ aliasNames = DataObjectUtil.getAliasNames(this);
+ }
+ return aliasNames;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getDeclaredProperties()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getProperties()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getBaseTypes()
+ {
+ EDataType dataType = ExtendedMetaData.INSTANCE.getBaseType(this);
+ if (dataType == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ else
+ {
+ return Collections.singletonList(dataType);
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public Property getProperty(String propertyName)
+ {
+ return null;
+ }
+
+ public List getInstanceProperties() {
+ return DataObjectUtil.getMetaObjectInstanceProperties(this);
+ }
+
+ public Object get(Property property) {
+ return DataObjectUtil.getMetaObjectInstanceProperty(this, property);
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // org.apache.tuscany.sdo.model.Type method implementations
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public List getBaseType() {
+ return this.getBaseTypes();
+ }
+
+ public List getProperty() {
+ return this.getProperties();
+ }
+
+ public List getAliasName() {
+ return this.getAliasNames();
+ }
+
+ public Sequence getAny() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Sequence getAnyAttribute() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAbstract()
+ {
+ return false;
+ }
+
+ public void setAbstract(boolean value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSetAbstract() {
+ return false;
+ }
+
+ public void unsetAbstract() {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public void setDataType(boolean value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public void unsetDataType() {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSetDataType() {
+ return true;
+ }
+
+ public void setOpen(boolean value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public void unsetOpen() {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSetOpen() {
+ return false;
+ }
+
+ public void setSequenced(boolean value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public void unsetSequenced() {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSetSequenced() {
+ return false;
+ }
+
+ public void unsetName()
+ {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSetName()
+ {
+ return true;
+ }
+
+ public void unsetUri()
+ {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSetUri()
+ {
+ return true;
+ }
+
+ public void setUri(String value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public String getUri() {
+ return getURI();
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // DataObject method implementations
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /*
+ public Object get(int propertyIndex) {
+ Object ret = DataObjectUtil.get(this, propertyIndex);
+ return (ret != null) ?
+ ret : eGet(propertyIndex, true, false);
+ }
+
+ public void set(int propertyIndex, Object value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSet(int propertyIndex) {
+ return eIsSet(propertyIndex);
+ }
+
+ public void unset(int propertyIndex) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public Object get(Property property) {
+ Object ret = DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID());
+ return (ret != null) ?
+ ret : eGet((EStructuralFeature)property, true, false);
+ }
+
+ public void set(Property property, Object value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSet(Property property) {
+ return eIsSet((EStructuralFeature)property);
+ }
+
+ public void unset(Property property) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public DataObject getContainer() {
+ return (DataObject)eContainer();
+ }
+
+ public Property getContainmentProperty() {
+ return (Property)eContainmentFeature();
+ }
+
+ public Type getType() {
+ return (Type)ModelPackageImpl.eINSTANCE.getType();
+ }
+
+ // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil
+
+ public Object get(String path) {
+ return DataObjectUtil.get(this, path);
+ }
+
+ public void set(String path, Object value) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean isSet(String path) {
+ return DataObjectUtil.isSet(this, path);
+ }
+
+ public void unset(String path) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public boolean getBoolean(String path) {
+ return DataObjectUtil.getBoolean(get(path));
+ }
+
+ public byte getByte(String path) {
+ return DataObjectUtil.getByte(get(path));
+ }
+
+ public char getChar(String path) {
+ return DataObjectUtil.getChar(get(path));
+ }
+
+ public double getDouble(String path) {
+ return DataObjectUtil.getDouble(get(path));
+ }
+
+ public float getFloat(String path) {
+ return DataObjectUtil.getFloat(get(path));
+ }
+
+ public int getInt(String path) {
+ return DataObjectUtil.getInt(get(path));
+ }
+
+ public long getLong(String path) {
+ return DataObjectUtil.getLong(get(path));
+ }
+
+ public short getShort(String path) {
+ return DataObjectUtil.getShort(get(path));
+ }
+
+ public byte[] getBytes(String path) {
+ return DataObjectUtil.getBytes(get(path));
+ }
+
+ public BigDecimal getBigDecimal(String path) {
+ return DataObjectUtil.getBigDecimal(get(path));
+ }
+
+ public BigInteger getBigInteger(String path) {
+ return DataObjectUtil.getBigInteger(get(path));
+ }
+
+ public DataObject getDataObject(String path) {
+ return (DataObject)get(path);
+ }
+
+ public Date getDate(String path) {
+ return DataObjectUtil.getDate(get(path));
+ }
+
+ public String getString(String path) {
+ return DataObjectUtil.getString(get(path));
+ }
+
+ public List getList(String path) {
+ return (List)get(path);
+ }
+
+ public Sequence getSequence(String path) {
+ return (Sequence)get(path);
+ }
+
+ public void setBoolean(String path, boolean value) {
+ set(path, new Boolean(value));
+ }
+
+ public void setByte(String path, byte value) {
+ set(path, new Byte(value));
+ }
+
+ public void setChar(String path, char value) {
+ set(path, new Character(value));
+ }
+
+ public void setDouble(String path, double value) {
+ set(path, new Double(value));
+ }
+
+ public void setFloat(String path, float value) {
+ set(path, new Float(value));
+ }
+
+ public void setInt(String path, int value) {
+ set(path, new Integer(value));
+ }
+
+ public void setLong(String path, long value) {
+ set(path, new Long(value));
+ }
+
+ public void setShort(String path, short value) {
+ set(path, new Short(value));
+ }
+
+ public void setBytes(String path, byte[] value) {
+ set(path, value);
+ }
+
+ public void setBigDecimal(String path, BigDecimal value) {
+ set(path, value);
+ }
+
+ public void setBigInteger(String path, BigInteger value) {
+ set(path, value);
+ }
+
+ public void setDataObject(String path, DataObject value) {
+ set(path, value);
+ }
+
+ public void setDate(String path, Date value) {
+ set(path, value);
+ }
+
+ public void setString(String path, String value) {
+ set(path, value);
+ }
+
+ public void setList(String path, List value) {
+ set(path, value);
+ }
+
+ public boolean getBoolean(int propertyIndex) {
+ return DataObjectUtil.getBoolean(this, propertyIndex);
+ }
+
+ public byte getByte(int propertyIndex) {
+ return DataObjectUtil.getByte(this, propertyIndex);
+ }
+
+ public char getChar(int propertyIndex) {
+ return DataObjectUtil.getChar(this, propertyIndex);
+ }
+
+ public double getDouble(int propertyIndex) {
+ return DataObjectUtil.getDouble(this, propertyIndex);
+ }
+
+ public float getFloat(int propertyIndex) {
+ return DataObjectUtil.getFloat(this, propertyIndex);
+ }
+
+ public int getInt(int propertyIndex) {
+ return DataObjectUtil.getInt(this, propertyIndex);
+ }
+
+ public long getLong(int propertyIndex) {
+ return DataObjectUtil.getLong(this, propertyIndex);
+ }
+
+ public short getShort(int propertyIndex) {
+ return DataObjectUtil.getShort(this, propertyIndex);
+ }
+
+ public byte[] getBytes(int propertyIndex) {
+ return DataObjectUtil.getBytes(this, propertyIndex);
+ }
+
+ public BigDecimal getBigDecimal(int propertyIndex) {
+ return DataObjectUtil.getBigDecimal(this, propertyIndex);
+ }
+
+ public BigInteger getBigInteger(int propertyIndex) {
+ return DataObjectUtil.getBigInteger(this, propertyIndex);
+ }
+
+ public DataObject getDataObject(int propertyIndex) {
+ return DataObjectUtil.getDataObject(this, propertyIndex);
+ }
+
+ public Date getDate(int propertyIndex) {
+ return DataObjectUtil.getDate(this, propertyIndex);
+ }
+
+ public String getString(int propertyIndex) {
+ return DataObjectUtil.getString(this, propertyIndex);
+ }
+
+ public List getList(int propertyIndex) {
+ return DataObjectUtil.getList(this, propertyIndex);
+ }
+
+ public Sequence getSequence(int propertyIndex) {
+ return DataObjectUtil.getSequence(this, propertyIndex);
+ }
+
+ public void setBoolean(int propertyIndex, boolean value) {
+ set(propertyIndex, new Boolean(value));
+ }
+
+ public void setByte(int propertyIndex, byte value) {
+ set(propertyIndex, new Byte(value));
+ }
+
+ public void setChar(int propertyIndex, char value) {
+ set(propertyIndex, new Character(value));
+ }
+
+ public void setDouble(int propertyIndex, double value) {
+ set(propertyIndex, new Double(value));
+ }
+
+ public void setFloat(int propertyIndex, float value) {
+ set(propertyIndex, new Float(value));
+ }
+
+ public void setInt(int propertyIndex, int value) {
+ set(propertyIndex, new Integer(value));
+ }
+
+ public void setLong(int propertyIndex, long value) {
+ set(propertyIndex, new Long(value));
+ }
+
+ public void setShort(int propertyIndex, short value) {
+ set(propertyIndex, new Short(value));
+ }
+
+ public void setBytes(int propertyIndex, byte[] value) {
+ set(propertyIndex, value);
+ }
+
+ public void setBigDecimal(int propertyIndex, BigDecimal value) {
+ set(propertyIndex, value);
+ }
+
+ public void setBigInteger(int propertyIndex, BigInteger value) {
+ set(propertyIndex, value);
+ }
+
+ public void setDataObject(int propertyIndex, DataObject value) {
+ set(propertyIndex, value);
+ }
+
+ public void setDate(int propertyIndex, Date value) {
+ set(propertyIndex, value);
+ }
+
+ public void setString(int propertyIndex, String value) {
+ set(propertyIndex, value);
+ }
+
+ public void setList(int propertyIndex, List value) {
+ set(propertyIndex, value);
+ }
+
+ public boolean getBoolean(Property property) {
+ return DataObjectUtil.getBoolean(this, property);
+ }
+
+ public byte getByte(Property property) {
+ return DataObjectUtil.getByte(this, property);
+ }
+
+ public char getChar(Property property) {
+ return DataObjectUtil.getChar(this, property);
+ }
+
+ public double getDouble(Property property) {
+ return DataObjectUtil.getDouble(this, property);
+ }
+
+ public float getFloat(Property property) {
+ return DataObjectUtil.getFloat(this, property);
+ }
+
+ public int getInt(Property property) {
+ return DataObjectUtil.getInt(this, property);
+ }
+
+ public long getLong(Property property) {
+ return DataObjectUtil.getLong(this, property);
+ }
+
+ public short getShort(Property property) {
+ return DataObjectUtil.getShort(this, property);
+ }
+
+ public byte[] getBytes(Property property) {
+ return DataObjectUtil.getBytes(this, property);
+ }
+
+ public BigDecimal getBigDecimal(Property property) {
+ return DataObjectUtil.getBigDecimal(this, property);
+ }
+
+ public BigInteger getBigInteger(Property property) {
+ return DataObjectUtil.getBigInteger(this, property);
+ }
+
+ public DataObject getDataObject(Property property) {
+ return DataObjectUtil.getDataObject(this, property);
+ }
+
+ public Date getDate(Property property) {
+ return DataObjectUtil.getDate(this, property);
+ }
+
+ public String getString(Property property) {
+ return DataObjectUtil.getString(this, property);
+ }
+
+ public List getList(Property property) {
+ return DataObjectUtil.getList(this, property);
+ }
+
+ public Sequence getSequence(Property property) {
+ return DataObjectUtil.getSequence(this, property);
+ }
+
+ public void setBoolean(Property property, boolean value) {
+ set(property, new Boolean(value));
+ }
+
+ public void setByte(Property property, byte value) {
+ set(property, new Byte(value));
+ }
+
+ public void setChar(Property property, char value) {
+ set(property, new Character(value));
+ }
+
+ public void setDouble(Property property, double value) {
+ set(property, new Double(value));
+ }
+
+ public void setFloat(Property property, float value) {
+ set(property, new Float(value));
+ }
+
+ public void setInt(Property property, int value) {
+ set(property, new Integer(value));
+ }
+
+ public void setLong(Property property, long value) {
+ set(property, new Long(value));
+ }
+
+ public void setShort(Property property, short value) {
+ set(property, new Short(value));
+ }
+
+ public void setBytes(Property property, byte[] value) {
+ set(property, value);
+ }
+
+ public void setBigDecimal(Property property, BigDecimal value) {
+ set(property, value);
+ }
+
+ public void setBigInteger(Property property, BigInteger value) {
+ set(property, value);
+ }
+
+ public void setDataObject(Property property, DataObject value) {
+ set(property, value);
+ }
+
+ public void setDate(Property property, Date value) {
+ set(property, value);
+ }
+
+ public void setString(Property property, String value) {
+ set(property, value);
+ }
+
+ public void setList(Property property, List value) {
+ set(property, value);
+ }
+
+ public DataObject createDataObject(String propertyName) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(int propertyIndex) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(Property property) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(Property property, Type type) {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public void delete() {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+
+ public DataGraph getDataGraph() {
+ return DataObjectUtil.getDataGraph(this);
+ }
+
+ public Sequence getSequence() {
+ EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass());
+ return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null;
+ }
+
+ public List getInstanceProperties() {
+ return DataObjectUtil.getInstanceProperties(this);
+ }
+
+ public DataObject getRootObject() {
+ return DataObjectUtil.getRootObject(this);
+ }
+
+ public ChangeSummary getChangeSummary() {
+ // TODO: implement this method
+ throw new UnsupportedOperationException();
+ }
+
+ public void detach() {
+ throw new UnsupportedOperationException("Type is frozen and cannot be modified");
+ }
+ */
+
+} //DataTypeImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java
new file mode 100644
index 0000000000..153ef18444
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java
@@ -0,0 +1,216 @@
+/**
+ *
+ * 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.impl;
+
+import org.apache.tuscany.sdo.SDOFactory;
+import org.apache.tuscany.sdo.SDOPackage;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+
+/**
+ *
+ * An implementation of the model object 'Dynamic Data Object'.
+ * @extends EStructuralFeature.Internal.DynamicValueHolder
+ *
+ *
+ *
+ *
+ * @generated
+ */
+public class DynamicDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder
+{
+ protected EClass eClass;
+ protected Object [] eSettings;
+
+ protected static final Object [] ENO_SETTINGS = new Object [0];
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected DynamicDataObjectImpl()
+ {
+ super();
+ }
+
+ /**
+ * Creates a dynamic DataObject.
+ */
+ public DynamicDataObjectImpl(EClass eClass)
+ {
+ super();
+ eSetClass(eClass);
+ Property csp = ((ClassImpl)eClass).getChangeSummaryProperty();
+ if (csp != null)
+ {
+ ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary();
+ set(csp, changeSummary);
+ changeSummary.setDataObject(this);
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected EClass eStaticClass()
+ {
+ return SDOPackage.eINSTANCE.getDynamicDataObject();
+ }
+
+ protected int eStaticFeatureCount()
+ {
+ return 0;
+ }
+
+ public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature)
+ {
+ return eClass().getFeatureID(eStructuralFeature);
+ }
+
+ protected boolean eHasSettings()
+ {
+ return eSettings != null;
+ }
+
+ protected EStructuralFeature.Internal.DynamicValueHolder eSettings()
+ {
+ if (eSettings == null)
+ {
+ int size = eClass().getFeatureCount() - eStaticFeatureCount();
+ eSettings = size == 0 ? ENO_SETTINGS : new Object [size];
+ }
+
+ return this;
+ }
+
+ protected EClass eDynamicClass()
+ {
+ return eClass;
+ }
+
+ public EClass eClass()
+ {
+ return eClass;
+ }
+
+ public void eSetClass(EClass eClass)
+ {
+ this.eClass = eClass;
+ }
+
+ public Object dynamicGet(int dynamicFeatureID)
+ {
+ return eSettings[dynamicFeatureID];
+ }
+
+ public void dynamicSet(int dynamicFeatureID, Object value)
+ {
+ eSettings[dynamicFeatureID] = value;
+ }
+
+ public void dynamicUnset(int dynamicFeatureID)
+ {
+ eSettings[dynamicFeatureID] = null;
+ }
+
+ public Object eDynamicGet(int featureID, boolean resolve, boolean coreType)
+ {
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), featureID, resolve, coreType);
+ }
+ else
+ {
+ return super.eDynamicGet(featureID, resolve, coreType);
+ }
+ }
+
+ public void eDynamicSet(int featureID, Object newValue)
+ {
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ try {
+ eDynamicSet(featureID, eFeature, newValue);
+ } catch (IllegalArgumentException e) {
+ throw new UnsupportedOperationException(e.getMessage());
+ }
+ }
+ else
+ {
+ super.eDynamicSet(featureID, newValue);
+ }
+ }
+
+ public void eDynamicUnset(int featureID)
+ {
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ try {
+ eDynamicUnset(featureID, eFeature);
+ } catch (IllegalArgumentException e) {
+ throw new UnsupportedOperationException(e.getMessage());
+ }
+ }
+ else
+ {
+ super.eDynamicUnset(featureID);
+ }
+ }
+
+ public boolean eDynamicIsSet(int featureID)
+ {
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ return eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), featureID);
+ }
+ else
+ {
+ return super.eDynamicIsSet(featureID);
+ }
+ }
+
+ /**
+ * An EFactoryImpl that creates DynamicEDataObjectImpl instances.
+ */
+ public static class FactoryImpl extends EFactoryImpl
+ {
+ public FactoryImpl()
+ {
+ }
+
+ public EObject basicCreate(EClass eClass)
+ {
+ return new DynamicDataObjectImpl(eClass);
+ }
+ }
+
+} //DynamicDataObjectImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java
new file mode 100644
index 0000000000..d9d39bad49
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * 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.impl;
+
+import org.apache.tuscany.sdo.SDOPackage;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import commonj.sdo.DataObject;
+
+/**
+ *
+ * An implementation of the model object 'Dynamic Store Data Object'.
+ *
+ *
+ *
+ *
+ * @generated
+ */
+public class DynamicStoreDataObjectImpl extends StoreDataObjectImpl implements DataObject
+{
+ protected EClass eClass;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected DynamicStoreDataObjectImpl()
+ {
+ super();
+ }
+
+ public DynamicStoreDataObjectImpl(InternalEObject.EStore eStore)
+ {
+ super(eStore);
+ }
+
+ public DynamicStoreDataObjectImpl(EClass eClass)
+ {
+ super(eClass);
+ }
+
+ public DynamicStoreDataObjectImpl(EClass eClass, InternalEObject.EStore eStore)
+ {
+ super(eClass, eStore);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected EClass eStaticClass()
+ {
+ return SDOPackage.eINSTANCE.getDynamicStoreDataObject();
+ }
+
+ protected EClass eDynamicClass()
+ {
+ return eClass;
+ }
+
+ public EClass eClass()
+ {
+ return eClass;
+ }
+
+ public void eSetClass(EClass eClass)
+ {
+ this.eClass = eClass;
+ }
+
+} //DynamicStoreDataObjectImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java
new file mode 100644
index 0000000000..54f642d8cf
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java
@@ -0,0 +1,183 @@
+/**
+ *
+ * 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.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+//import org.apache.tuscany.sdo.SDOPackage;
+
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.impl.EEnumImpl;
+
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+/**
+ *
+ * An implementation of the model object 'Enum'.
+ *
+ *
+ *
+ *
+ * @generated
+ * @deprecated SDO doesn't support Enum types
+ */
+public class EnumImpl extends EEnumImpl implements Type
+{
+ /**
+ *
+ *
+ * @generated
+ */
+ protected EnumImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ protected EClass eStaticClass()
+ {
+ return EcorePackage.eINSTANCE.getEEnum();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public String getURI()
+ {
+ return getEPackage().getNsURI();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isDataType()
+ {
+ return true;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isOpen()
+ {
+ return false;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isSequenced()
+ {
+ return false;
+ }
+
+ protected List aliasNames = null;
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getAliasNames()
+ {
+ if (aliasNames == null)
+ {
+ aliasNames = DataObjectUtil.getAliasNames(this);
+ }
+ return aliasNames;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getDeclaredProperties()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getProperties()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getBaseTypes()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public Property getProperty(String propertyName)
+ {
+ return null;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isAbstract()
+ {
+ return false;
+ }
+
+ public List getInstanceProperties()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object get(Property property)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+} //EnumTypeImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java
new file mode 100644
index 0000000000..b1ae572f21
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java
@@ -0,0 +1,142 @@
+package org.apache.tuscany.sdo.impl;
+
+import org.apache.tuscany.sdo.api.Event;
+import org.eclipse.emf.common.notify.Notification;
+
+import commonj.sdo.Property;
+
+
+public class EventImpl implements Event {
+
+ protected Notification emfEvent;
+ protected Object notifier;
+
+ public EventImpl(Notification notification)
+ {
+ this.emfEvent = notification;
+ }
+
+ public Object getNotifier()
+ {
+ return notifier == null ? emfEvent.getNotifier() : notifier;
+ }
+
+ public int getEventType()
+ {
+ return emfEvent.getEventType();
+ }
+
+
+ public Property getProperty()
+ {
+ return (Property)emfEvent.getFeature();
+ }
+
+ public Object getOldValue()
+ {
+ return emfEvent.getOldValue();
+ }
+
+ public Object getNewValue()
+ {
+ return emfEvent.getNewValue();
+ }
+
+ public boolean wasSet()
+ {
+ return emfEvent.wasSet();
+ }
+
+ public boolean isTouch()
+ {
+ return emfEvent.isTouch();
+ }
+
+ public int getPosition()
+ {
+ return emfEvent.getPosition();
+ }
+
+
+ public boolean getOldBooleanValue()
+ {
+ return emfEvent.getOldBooleanValue();
+ }
+
+ public boolean getNewBooleanValue()
+ {
+ return emfEvent.getNewBooleanValue();
+ }
+
+ public byte getOldByteValue()
+ {
+ return emfEvent.getOldByteValue();
+ }
+ public byte getNewByteValue()
+ {
+ return emfEvent.getNewByteValue();
+ }
+
+ public char getOldCharValue()
+ {
+ return emfEvent.getOldCharValue();
+ }
+ public char getNewCharValue()
+ {
+ return emfEvent.getNewCharValue();
+ }
+
+ public double getOldDoubleValue()
+ {
+ return emfEvent.getOldDoubleValue();
+ }
+ public double getNewDoubleValue()
+ {
+ return emfEvent.getNewDoubleValue();
+ }
+
+ public float getOldFloatValue()
+ {
+ return emfEvent.getOldFloatValue();
+ }
+ public float getNewFloatValue()
+ {
+ return emfEvent.getNewFloatValue();
+ }
+
+ public int getOldIntValue()
+ {
+ return emfEvent.getOldIntValue();
+ }
+ public int getNewIntValue()
+ {
+ return emfEvent.getNewIntValue();
+ }
+
+ public long getOldLongValue()
+ {
+ return emfEvent.getOldLongValue();
+ }
+ public long getNewLongValue()
+ {
+ return emfEvent.getNewLongValue();
+ }
+
+ public short getOldShortValue()
+ {
+ return emfEvent.getOldShortValue();
+ }
+ public short getNewShortValue()
+ {
+ return emfEvent.getNewShortValue();
+ }
+
+ public String getOldStringValue()
+ {
+ return emfEvent.getOldStringValue();
+ }
+ public String getNewStringValue()
+ {
+ return emfEvent.getNewStringValue();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java
new file mode 100644
index 0000000000..93825f7873
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java
@@ -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 org.apache.tuscany.sdo.impl;
+
+import org.apache.tuscany.sdo.SDOFactory;
+import org.apache.tuscany.sdo.SDOPackage;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+
+/**
+ *
+ * An implementation of the model object 'Extensible Data Object'.
+ * @extends EStructuralFeature.Internal.DynamicValueHolder
+ *
+ *
+ *
+ *
+ * @generated
+ */
+public class ExtensibleDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder
+{
+ protected EClass eClass;
+ protected Object [] eSettings;
+
+ protected static final Object [] ENO_SETTINGS = new Object [0];
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected ExtensibleDataObjectImpl()
+ {
+ super();
+ }
+
+ /**
+ * Creates an extensible DataObject.
+ */
+ public ExtensibleDataObjectImpl(EClass eClass)
+ {
+ super();
+ eSetClass(eClass);
+ Property csp = ((ClassImpl)eClass).getChangeSummaryProperty();
+ if (csp != null)
+ {
+ ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary();
+ set(csp, changeSummary);
+ changeSummary.setDataObject(this);
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected EClass eStaticClass()
+ {
+ return SDOPackage.eINSTANCE.getExtensibleDataObject();
+ }
+
+ public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature)
+ {
+ return eClass().getFeatureID(eStructuralFeature);
+ }
+
+ protected boolean eHasSettings()
+ {
+ return eSettings != null;
+ }
+
+ protected EStructuralFeature.Internal.DynamicValueHolder eSettings()
+ {
+ if (eSettings == null)
+ {
+ int size = eClass().getFeatureCount() - eStaticFeatureCount();
+ eSettings = size == 0 ? ENO_SETTINGS : new Object [size];
+ }
+
+ return this;
+ }
+
+ protected EClass eDynamicClass()
+ {
+ return eClass;
+ }
+
+ protected boolean isDynamic()
+ {
+ return (eClass != null);
+ }
+
+ public Object get(int featureID, boolean resolve)
+ {
+ return get(featureID, resolve, true);
+ }
+
+ public Object get(int featureID, boolean resolve, boolean coreType)
+ {
+ Object result = null;
+ if (isDynamic() || featureID >= eStaticFeatureCount())
+ {
+ result = super.eGet(featureID, resolve, coreType);
+ }
+ else
+ {
+ result = super.get(featureID);
+ }
+ return result;
+ }
+
+ public void set(int featureID, Object newValue)
+ {
+ if (isDynamic() || featureID >= eStaticFeatureCount())
+ {
+ super.eSet(featureID, newValue);
+ }
+ else
+ {
+ super.set(featureID, newValue);
+ }
+ }
+
+ public void unset(int featureID)
+ {
+ if (isDynamic() || featureID >= eStaticFeatureCount())
+ {
+ super.eUnset(featureID);
+ }
+ else
+ {
+ super.unset(featureID);
+ }
+ }
+
+ public boolean isSet(int featureID)
+ {
+ if (isDynamic() || featureID >= eStaticFeatureCount())
+ {
+ return super.eIsSet(featureID);
+ }
+ else
+ {
+ return super.isSet(featureID);
+ }
+ }
+
+ public EClass eClass()
+ {
+ return isDynamic() ? eClass : eStaticClass();
+ }
+
+ public void eSetClass(EClass eClass)
+ {
+ this.eClass = eClass;
+ }
+
+ public Object dynamicGet(int dynamicFeatureID)
+ {
+ return eSettings[dynamicFeatureID];
+ }
+
+ public void dynamicSet(int dynamicFeatureID, Object value)
+ {
+ eSettings[dynamicFeatureID] = value;
+ }
+
+ public void dynamicUnset(int dynamicFeatureID)
+ {
+ eSettings[dynamicFeatureID] = null;
+ }
+
+ public Object eDynamicGet(int featureID, boolean resolve, boolean coreType)
+ {
+ int dynamicFeatureID = featureID - eStaticFeatureCount();
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), dynamicFeatureID, resolve, coreType);
+ }
+ else
+ {
+ return super.eDynamicGet(dynamicFeatureID, resolve, coreType);
+ }
+ }
+
+ public void eDynamicSet(int featureID, Object newValue)
+ {
+ int dynamicFeatureID = featureID - eStaticFeatureCount();
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ eDynamicSet(dynamicFeatureID, eFeature, newValue);
+ }
+ else
+ {
+ super.eDynamicSet(dynamicFeatureID, newValue);
+ }
+ }
+
+ public void eDynamicUnset(int featureID)
+ {
+ int dynamicFeatureID = featureID - eStaticFeatureCount();
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ eDynamicUnset(dynamicFeatureID, eFeature);
+ }
+ else
+ {
+ super.eDynamicUnset(dynamicFeatureID);
+ }
+ }
+
+ public boolean eDynamicIsSet(int featureID)
+ {
+ int dynamicFeatureID = featureID - eStaticFeatureCount();
+ if (featureID < eClass().getFeatureCount())
+ {
+ EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
+ return eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), dynamicFeatureID);
+ }
+ else
+ {
+ return super.eDynamicIsSet(dynamicFeatureID);
+ }
+ }
+
+ /**
+ * An EFactoryImpl that creates ExtensibleDataObjectImpl instances.
+ */
+ public static class FactoryImpl extends EFactoryImpl
+ {
+ public FactoryImpl()
+ {
+ }
+
+ public EObject basicCreate(EClass eClass)
+ {
+ return new ExtensibleDataObjectImpl(eClass);
+ }
+ }
+
+} //ExtensibleDataObjectImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
new file mode 100644
index 0000000000..e344a6ffde
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
@@ -0,0 +1,368 @@
+/**
+ *
+ * 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.impl;
+
+import org.apache.tuscany.sdo.SDOFactory;
+import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EClassImpl;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+/**
+ * Base class for generated (static) SDO factories
+ */
+public class FactoryBase extends EPackageImpl
+{
+
+ public static final boolean IS_ATTRIBUTE = true;
+
+ protected FactoryBase(String namespaceURI, String namespacePrefix)
+ {
+ super(new SDOEFactoryImpl());
+ ecoreFactory = new SDOEcoreFactory();
+
+ int index = namespacePrefix.lastIndexOf(".");
+ setName(index != -1 ? namespacePrefix.substring(index + 1) : namespacePrefix);
+ setNsPrefix(namespacePrefix);
+
+ createResource(namespaceURI);
+ setNsURI(namespaceURI);
+
+ ((SDOEFactoryImpl)getEFactoryInstance()).sdoFactory = this;
+ }
+
+ protected FactoryBase(String namespaceURI, String namespacePrefix, String interfacePackage)
+ {
+ super(new SDOEFactoryImpl());
+ ecoreFactory = new SDOEcoreFactory();
+
+ int index = interfacePackage.lastIndexOf(".");
+ setName(index != -1 ? interfacePackage.substring(index + 1) : interfacePackage);
+ setNsPrefix(namespacePrefix);
+
+ createResource(namespaceURI);
+ setNsURI(namespaceURI);
+
+ ((SDOEFactoryImpl)getEFactoryInstance()).sdoFactory = this;
+ }
+
+
+
+ public DataObject create(int typeNumber)
+ {
+ return null;
+ }
+
+ public Object createFromString(int typeNumber, String stringValue)
+ {
+ return ((SDOEFactoryImpl)getEFactoryInstance()).createFromString(typeNumber, stringValue);
+ }
+
+ public String convertToString(int typeNumber, Object objectValue)
+ {
+ return ((SDOEFactoryImpl)getEFactoryInstance()).convertToString(typeNumber, objectValue);
+ }
+
+ protected Type createType(boolean isDataType, int typeNumber)
+ {
+ if (isDataType)
+ return (Type)createEDataType(typeNumber);
+ else
+ return (Type)createEClass(typeNumber);
+ }
+
+ protected void createProperty(boolean isDataType, Type containingType, int internalPropertyNumber)
+ {
+ if (isDataType)
+ createEAttribute((EClass)containingType, internalPropertyNumber);
+ else
+ createEReference((EClass)containingType, internalPropertyNumber);
+ }
+
+ /**
+ * @deprecated - use getLocalProperty instead, since getProperty causes
+ * caching of structural features.
+ */
+ protected Property getProperty(Type type, int internalPropertyNumber)
+ {
+ return (Property)((EClass)type).getEAllStructuralFeatures().get(internalPropertyNumber);
+ }
+
+ protected Property getLocalProperty(Type type, int localPropertyIndex)
+ {
+ return (Property)((EClass)type).getEStructuralFeatures().get(localPropertyIndex);
+ }
+
+
+ protected void initializeType(Type type, Class instanceClass, String name)
+ {
+ initEClass((EClass)type, instanceClass, name, !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ }
+
+ protected void initializeType(Type type, Class instanceClass, String name, boolean isAbstract)
+ {
+ initEClass((EClass)type, instanceClass, name, isAbstract, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ }
+
+ protected void initializeType(Type type, Class instanceClass, String name, boolean isSerializable, boolean isGenerated)
+ {
+ initEDataType((EDataType)type, instanceClass, name, isSerializable, isGenerated);
+ }
+
+ protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived)
+ {
+ initEAttribute((EAttribute)property, type != sequence ? (EClassifier)type : ecorePackage.getEFeatureMapEntry(), name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isUnsettable, !IS_ID, !IS_UNIQUE, isDerived, IS_ORDERED);
+ }
+
+ protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived, boolean isComposite, Property oppositeProperty)
+ {
+ initEReference((EReference)property, (EClassifier)type, (EReference)oppositeProperty, name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isComposite, !isComposite /*resolve*/, isUnsettable, IS_UNIQUE, isDerived, IS_ORDERED);
+ }
+
+ protected void initXSD()
+ {
+ createDocumentRoot();
+ }
+
+ protected void addXSDMapping(String[] xsdMappings, String annotationSource)
+ {
+ addAnnotation((ENamedElement)this, annotationSource, xsdMappings);
+ }
+
+ protected void addXSDMapping(Type type, String[] xsdMappings)
+ {
+ addAnnotation((ENamedElement)type, ANNOTATION_SOURCE, xsdMappings);
+ }
+
+ protected void addXSDMapping(Property property, String[] xsdMappings)
+ {
+ addAnnotation((ENamedElement)property, ANNOTATION_SOURCE, xsdMappings);
+ }
+
+ protected void setInstanceProperty(Type type, String namespaceURI, String propertyName, String propertyValue)
+ {
+ setInstanceProperty((ENamedElement)type, namespaceURI, propertyName, propertyValue);
+ }
+
+ protected void setInstanceProperty(Property property, String namespaceURI, String propertyName, String propertyValue)
+ {
+ setInstanceProperty((ENamedElement)property, namespaceURI, propertyName, propertyValue);
+ }
+
+ private void setInstanceProperty(ENamedElement eNamedElement, String namespaceURI, String propertyName, String propertyValue)
+ {
+ EAnnotation annotation = eNamedElement.getEAnnotation(namespaceURI);
+ if (annotation == null)
+ {
+ addAnnotation(eNamedElement, namespaceURI, new String[]{propertyName, propertyValue});
+ } else
+ {
+ annotation.getDetails().put(propertyName, propertyValue);
+ }
+ }
+
+ protected Property createGlobalProperty(String name, Type type, String[] xsdMappings)
+ {
+ return createGlobalProperty(name, type, xsdMappings, false);
+ }
+
+ protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute)
+ {
+ return createGlobalProperty(name, type, xsdMappings, asAttribute, ANNOTATION_SOURCE);
+ }
+
+ protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute, String annotationSource)
+ {
+ int propertyNumber = documentRootEClass.getEStructuralFeatures().size();
+
+ EStructuralFeature globalProperty;
+ if(asAttribute) {
+ createEAttribute(documentRootEClass, propertyNumber);
+ EAttribute gatt = (EAttribute)documentRootEClass.getEStructuralFeatures().get(propertyNumber);
+ initEAttribute(gatt, (EDataType)type, name, null, 0, -2, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+ globalProperty = gatt;
+ } else {
+ createEReference(documentRootEClass, propertyNumber);
+ EReference gref = (EReference)documentRootEClass.getEStructuralFeatures().get(propertyNumber);
+ initEReference(gref, (EClass)type, null, name, null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+ globalProperty = gref;
+ }
+ addAnnotation((ENamedElement)globalProperty, annotationSource, xsdMappings);
+ return (Property) globalProperty;
+ }
+
+ private static final Type sequence = SDOFactory.eINSTANCE.createDataType(); // dummy type
+
+ protected Type getSequence()
+ {
+ return sequence;
+ }
+
+ protected void addSuperType(Type subType, Type superType)
+ {
+ ((EClass)subType).getESuperTypes().add((EClass)superType);
+ }
+
+ /***
+ * @param namespaceURI
+ * @return Static factory (from the global scope) for the provided URI
+ *
+ * @deprecated - Use of the global scope is no longer encouraged. This method uses the
+ * global scope for retrieving the URI's factory. Instead, it is now possible to simply
+ * access SomeFactoryInterface.INSTANCE object directly.
+ *
+ */
+ public static Object getStaticFactory(String namespaceURI)
+ {
+ EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(namespaceURI);
+ //return (FactoryBase)ePackage;
+ return ePackage instanceof FactoryBase ? (Object)ePackage : (Object)ePackage.getEFactoryInstance();
+ }
+
+ // private EMF-specific methods
+
+ private static class SDOEFactoryImpl extends DynamicDataObjectImpl.FactoryImpl
+ {
+ protected FactoryBase sdoFactory;
+
+ public SDOEFactoryImpl()
+ {
+ super();
+ }
+
+ public EObject create(EClass eClass)
+ {
+ DataObject result = sdoFactory.create(eClass.getClassifierID());
+ if (result == null) {
+ if (eClass.isAbstract()) {
+ Class instanceClass = eClass.getInstanceClass();
+ try {
+ Class concreteInstanceClass = DataObjectUtil.getImplementationClass(instanceClass, true);
+ return (EObject)concreteInstanceClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ //System.out.println("Error: " + e);
+ }
+ }
+ return super.create(eClass);
+ }
+ return (EObject)result;
+ }
+
+ public Object createFromString(EDataType eDataType, String stringValue)
+ {
+ return sdoFactory.createFromString(eDataType.getClassifierID(), stringValue);
+ }
+
+ public String convertToString(EDataType eDataType, Object objectValue)
+ {
+ return sdoFactory.convertToString(eDataType.getClassifierID(), objectValue);
+ }
+
+ protected Object createFromString(int typeNumber, String stringValue)
+ {
+ return super.createFromString((EDataType)sdoFactory.getEClassifiers().get(typeNumber), stringValue);
+ }
+
+ protected String convertToString(int typeNumber, Object objectValue)
+ {
+ return super.convertToString((EDataType)sdoFactory.getEClassifiers().get(typeNumber), objectValue);
+ }
+ }
+
+ private static final int DOCUMENT_ROOT = 0;
+ private static final int DOCUMENT_ROOT__MIXED = 0;
+ private static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1;
+ private static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2;
+ private static final String ANNOTATION_SOURCE = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";
+ private EClass documentRootEClass = null;
+
+ private void createDocumentRoot()
+ {
+ documentRootEClass = ecoreFactory.createEClass();
+ ((EClassImpl)documentRootEClass).setClassifierID(DOCUMENT_ROOT);
+ getEClassifiers().add(DOCUMENT_ROOT, documentRootEClass);
+
+ createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
+
+ initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ addAnnotation
+ (documentRootEClass,
+ ANNOTATION_SOURCE,
+ new String[]
+ {
+ "name", "",
+ "kind", "mixed"
+ });
+ addAnnotation
+ ((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED),
+ ANNOTATION_SOURCE,
+ new String[]
+ {
+ "kind", "elementWildcard",
+ "name", ":mixed"
+ });
+ addAnnotation
+ ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP),
+ ANNOTATION_SOURCE,
+ new String[]
+ {
+ "kind", "attribute",
+ "name", "xmlns:prefix"
+ });
+ addAnnotation
+ ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION),
+ ANNOTATION_SOURCE,
+ new String[]
+ {
+ "kind", "attribute",
+ "name", "xsi:schemaLocation"
+ });
+ }
+
+ /**
+ * Initialize SDO runtime.
+ */
+ static
+ {
+ DataObjectUtil.initRuntime();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..19fb89bbd3
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java
@@ -0,0 +1,785 @@
+/**
+ *
+ * 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.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sdo.SDOPackage;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.impl.EReferenceImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+
+/**
+ *
+ * An implementation of the model object 'Reference'.
+ *
+ *
+ *
+ *
+ * @generated
+ */
+public class ReferenceImpl extends EReferenceImpl implements Property,/* DataObject,*/ org.apache.tuscany.sdo.model.Property
+{
+ /**
+ *
+ *
+ * @generated
+ */
+ protected ReferenceImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ protected EClass eStaticClass()
+ {
+ return SDOPackage.eINSTANCE.getReference();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public Object getDefault()
+ {
+ return getDefaultValue();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public boolean isReadOnly()
+ {
+ //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly"));
+ return !isChangeable(); //TODO semantics don't exactly match?
+ }
+
+ /**
+ * Single-valued SDO properties behave as EMF unsettable, multi-valued properties as EMF !unsettable
+ */
+ public boolean isUnsettable()
+ {
+ return !isMany();
+ }
+
+ protected List aliasNames = null;
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public List getAliasNames()
+ {
+ if (aliasNames == null)
+ {
+ aliasNames = DataObjectUtil.getAliasNames(this);
+ }
+ return aliasNames;
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public Type getType()
+ {
+ return (Type)getEType();
+ /*
+ EClassifier eType = getEType();
+ //FB More temporary hacks
+ return eType instanceof Type ? (Type)getEType() : null;
+ */
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public Type getContainingType()
+ {
+ return (Type)getEContainingClass();
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public Property getOpposite()
+ {
+ return (Property)getEOpposite();
+ }
+
+ public boolean isNullable()
+ {
+ String isNillable = EcoreUtil.getAnnotation(this, ExtendedMetaData.ANNOTATION_URI, "nillable");
+ return isNillable != null && "true".equals(isNillable);
+ }
+
+ public boolean isOpenContent()
+ {
+ return SDOUtil.isDocumentRoot(getContainingType());
+ }
+
+ public List getInstanceProperties() {
+ return DataObjectUtil.getMetaObjectInstanceProperties(this);
+ }
+
+ public Object get(Property property) {
+ return DataObjectUtil.getMetaObjectInstanceProperty(this, property);
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // org.apache.tuscany.sdo.model.Property methods
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public List getAliasName() {
+ return this.getAliasNames();
+ }
+
+ public Sequence getAny() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setMany(boolean value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public void unsetMany() {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetMany() {
+ return isMany();
+ }
+
+ public void setReadOnly(boolean value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public void unsetReadOnly() {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetReadOnly() {
+ return isReadOnly();
+ }
+
+ public org.apache.tuscany.sdo.model.Type getType_() {
+ return (org.apache.tuscany.sdo.model.Type)getType();
+ }
+
+ public void setType(org.apache.tuscany.sdo.model.Type value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public Sequence getAnyAttribute() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getDefault_() {
+ return (String) this.getDefault();
+ }
+
+ public void setDefault_(String value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public org.apache.tuscany.sdo.model.Property getOpposite_() {
+ return (org.apache.tuscany.sdo.model.Property) getOpposite();
+ }
+
+ public void setOpposite_(org.apache.tuscany.sdo.model.Property value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public void unsetContainment() {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetContainment() {
+ return isContainment();
+ }
+
+ public void setNullable(boolean value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public void unsetNullable() {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetNullable() {
+ return isNullable();
+ }
+
+ public void unsetName()
+ {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetName()
+ {
+ return true;
+ }
+
+ public void unsetOpposite()
+ {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetOpposite()
+ {
+ return getOpposite() != null;
+ }
+
+ public void unsetType()
+ {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetType()
+ {
+ return true;
+ }
+
+ public void unsetDefault()
+ {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSetDefault()
+ {
+ return getDefault() != null;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // DataObject method implementations
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /*
+ public Object get(int propertyIndex) {
+ return DataObjectUtil.get(this, propertyIndex);
+ }
+
+ public void set(int propertyIndex, Object value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSet(int propertyIndex) {
+ return DataObjectUtil.isSet(this, propertyIndex);
+ }
+
+ public void unset(int propertyIndex) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public Object get(Property property) {
+ return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID());
+ }
+
+ public void set(Property property, Object value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSet(Property property) {
+ return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID());
+ }
+
+ public void unset(Property property) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public DataObject getContainer() {
+ return (DataObject)eContainer();
+ }
+
+ public Property getContainmentProperty() {
+ return (Property)eContainmentFeature();
+ }
+
+ // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil
+
+ public Object get(String path) {
+ return DataObjectUtil.get(this, path);
+ }
+
+ public void set(String path, Object value) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean isSet(String path) {
+ return DataObjectUtil.isSet(this, path);
+ }
+
+ public void unset(String path) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public boolean getBoolean(String path) {
+ return DataObjectUtil.getBoolean(get(path));
+ }
+
+ public byte getByte(String path) {
+ return DataObjectUtil.getByte(get(path));
+ }
+
+ public char getChar(String path) {
+ return DataObjectUtil.getChar(get(path));
+ }
+
+ public double getDouble(String path) {
+ return DataObjectUtil.getDouble(get(path));
+ }
+
+ public float getFloat(String path) {
+ return DataObjectUtil.getFloat(get(path));
+ }
+
+ public int getInt(String path) {
+ return DataObjectUtil.getInt(get(path));
+ }
+
+ public long getLong(String path) {
+ return DataObjectUtil.getLong(get(path));
+ }
+
+ public short getShort(String path) {
+ return DataObjectUtil.getShort(get(path));
+ }
+
+ public byte[] getBytes(String path) {
+ return DataObjectUtil.getBytes(get(path));
+ }
+
+ public BigDecimal getBigDecimal(String path) {
+ return DataObjectUtil.getBigDecimal(get(path));
+ }
+
+ public BigInteger getBigInteger(String path) {
+ return DataObjectUtil.getBigInteger(get(path));
+ }
+
+ public DataObject getDataObject(String path) {
+ return (DataObject)get(path);
+ }
+
+ public Date getDate(String path) {
+ return DataObjectUtil.getDate(get(path));
+ }
+
+ public String getString(String path) {
+ return DataObjectUtil.getString(get(path));
+ }
+
+ public List getList(String path) {
+ return (List)get(path);
+ }
+
+ public Sequence getSequence(String path) {
+ return (Sequence)get(path);
+ }
+
+ public void setBoolean(String path, boolean value) {
+ set(path, new Boolean(value));
+ }
+
+ public void setByte(String path, byte value) {
+ set(path, new Byte(value));
+ }
+
+ public void setChar(String path, char value) {
+ set(path, new Character(value));
+ }
+
+ public void setDouble(String path, double value) {
+ set(path, new Double(value));
+ }
+
+ public void setFloat(String path, float value) {
+ set(path, new Float(value));
+ }
+
+ public void setInt(String path, int value) {
+ set(path, new Integer(value));
+ }
+
+ public void setLong(String path, long value) {
+ set(path, new Long(value));
+ }
+
+ public void setShort(String path, short value) {
+ set(path, new Short(value));
+ }
+
+ public void setBytes(String path, byte[] value) {
+ set(path, value);
+ }
+
+ public void setBigDecimal(String path, BigDecimal value) {
+ set(path, value);
+ }
+
+ public void setBigInteger(String path, BigInteger value) {
+ set(path, value);
+ }
+
+ public void setDataObject(String path, DataObject value) {
+ set(path, value);
+ }
+
+ public void setDate(String path, Date value) {
+ set(path, value);
+ }
+
+ public void setString(String path, String value) {
+ set(path, value);
+ }
+
+ public void setList(String path, List value) {
+ set(path, value);
+ }
+
+ public boolean getBoolean(int propertyIndex) {
+ return DataObjectUtil.getBoolean(this, propertyIndex);
+ }
+
+ public byte getByte(int propertyIndex) {
+ return DataObjectUtil.getByte(this, propertyIndex);
+ }
+
+ public char getChar(int propertyIndex) {
+ return DataObjectUtil.getChar(this, propertyIndex);
+ }
+
+ public double getDouble(int propertyIndex) {
+ return DataObjectUtil.getDouble(this, propertyIndex);
+ }
+
+ public float getFloat(int propertyIndex) {
+ return DataObjectUtil.getFloat(this, propertyIndex);
+ }
+
+ public int getInt(int propertyIndex) {
+ return DataObjectUtil.getInt(this, propertyIndex);
+ }
+
+ public long getLong(int propertyIndex) {
+ return DataObjectUtil.getLong(this, propertyIndex);
+ }
+
+ public short getShort(int propertyIndex) {
+ return DataObjectUtil.getShort(this, propertyIndex);
+ }
+
+ public byte[] getBytes(int propertyIndex) {
+ return DataObjectUtil.getBytes(this, propertyIndex);
+ }
+
+ public BigDecimal getBigDecimal(int propertyIndex) {
+ return DataObjectUtil.getBigDecimal(this, propertyIndex);
+ }
+
+ public BigInteger getBigInteger(int propertyIndex) {
+ return DataObjectUtil.getBigInteger(this, propertyIndex);
+ }
+
+ public DataObject getDataObject(int propertyIndex) {
+ return DataObjectUtil.getDataObject(this, propertyIndex);
+ }
+
+ public Date getDate(int propertyIndex) {
+ return DataObjectUtil.getDate(this, propertyIndex);
+ }
+
+ public String getString(int propertyIndex) {
+ return DataObjectUtil.getString(this, propertyIndex);
+ }
+
+ public List getList(int propertyIndex) {
+ return DataObjectUtil.getList(this, propertyIndex);
+ }
+
+ public Sequence getSequence(int propertyIndex) {
+ return DataObjectUtil.getSequence(this, propertyIndex);
+ }
+
+ public void setBoolean(int propertyIndex, boolean value) {
+ set(propertyIndex, new Boolean(value));
+ }
+
+ public void setByte(int propertyIndex, byte value) {
+ set(propertyIndex, new Byte(value));
+ }
+
+ public void setChar(int propertyIndex, char value) {
+ set(propertyIndex, new Character(value));
+ }
+
+ public void setDouble(int propertyIndex, double value) {
+ set(propertyIndex, new Double(value));
+ }
+
+ public void setFloat(int propertyIndex, float value) {
+ set(propertyIndex, new Float(value));
+ }
+
+ public void setInt(int propertyIndex, int value) {
+ set(propertyIndex, new Integer(value));
+ }
+
+ public void setLong(int propertyIndex, long value) {
+ set(propertyIndex, new Long(value));
+ }
+
+ public void setShort(int propertyIndex, short value) {
+ set(propertyIndex, new Short(value));
+ }
+
+ public void setBytes(int propertyIndex, byte[] value) {
+ set(propertyIndex, value);
+ }
+
+ public void setBigDecimal(int propertyIndex, BigDecimal value) {
+ set(propertyIndex, value);
+ }
+
+ public void setBigInteger(int propertyIndex, BigInteger value) {
+ set(propertyIndex, value);
+ }
+
+ public void setDataObject(int propertyIndex, DataObject value) {
+ set(propertyIndex, value);
+ }
+
+ public void setDate(int propertyIndex, Date value) {
+ set(propertyIndex, value);
+ }
+
+ public void setString(int propertyIndex, String value) {
+ set(propertyIndex, value);
+ }
+
+ public void setList(int propertyIndex, List value) {
+ set(propertyIndex, value);
+ }
+
+ public boolean getBoolean(Property property) {
+ return DataObjectUtil.getBoolean(this, property);
+ }
+
+ public byte getByte(Property property) {
+ return DataObjectUtil.getByte(this, property);
+ }
+
+ public char getChar(Property property) {
+ return DataObjectUtil.getChar(this, property);
+ }
+
+ public double getDouble(Property property) {
+ return DataObjectUtil.getDouble(this, property);
+ }
+
+ public float getFloat(Property property) {
+ return DataObjectUtil.getFloat(this, property);
+ }
+
+ public int getInt(Property property) {
+ return DataObjectUtil.getInt(this, property);
+ }
+
+ public long getLong(Property property) {
+ return DataObjectUtil.getLong(this, property);
+ }
+
+ public short getShort(Property property) {
+ return DataObjectUtil.getShort(this, property);
+ }
+
+ public byte[] getBytes(Property property) {
+ return DataObjectUtil.getBytes(this, property);
+ }
+
+ public BigDecimal getBigDecimal(Property property) {
+ return DataObjectUtil.getBigDecimal(this, property);
+ }
+
+ public BigInteger getBigInteger(Property property) {
+ return DataObjectUtil.getBigInteger(this, property);
+ }
+
+ public DataObject getDataObject(Property property) {
+ return DataObjectUtil.getDataObject(this, property);
+ }
+
+ public Date getDate(Property property) {
+ return DataObjectUtil.getDate(this, property);
+ }
+
+ public String getString(Property property) {
+ return DataObjectUtil.getString(this, property);
+ }
+
+ public List getList(Property property) {
+ return DataObjectUtil.getList(this, property);
+ }
+
+ public Sequence getSequence(Property property) {
+ return DataObjectUtil.getSequence(this, property);
+ }
+
+ public void setBoolean(Property property, boolean value) {
+ set(property, new Boolean(value));
+ }
+
+ public void setByte(Property property, byte value) {
+ set(property, new Byte(value));
+ }
+
+ public void setChar(Property property, char value) {
+ set(property, new Character(value));
+ }
+
+ public void setDouble(Property property, double value) {
+ set(property, new Double(value));
+ }
+
+ public void setFloat(Property property, float value) {
+ set(property, new Float(value));
+ }
+
+ public void setInt(Property property, int value) {
+ set(property, new Integer(value));
+ }
+
+ public void setLong(Property property, long value) {
+ set(property, new Long(value));
+ }
+
+ public void setShort(Property property, short value) {
+ set(property, new Short(value));
+ }
+
+ public void setBytes(Property property, byte[] value) {
+ set(property, value);
+ }
+
+ public void setBigDecimal(Property property, BigDecimal value) {
+ set(property, value);
+ }
+
+ public void setBigInteger(Property property, BigInteger value) {
+ set(property, value);
+ }
+
+ public void setDataObject(Property property, DataObject value) {
+ set(property, value);
+ }
+
+ public void setDate(Property property, Date value) {
+ set(property, value);
+ }
+
+ public void setString(Property property, String value) {
+ set(property, value);
+ }
+
+ public void setList(Property property, List value) {
+ set(property, value);
+ }
+
+ public DataObject createDataObject(String propertyName) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(int propertyIndex) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(Property property) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public DataObject createDataObject(Property property, Type type) {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public void delete() {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ }
+
+ public DataGraph getDataGraph() {
+ return DataObjectUtil.getDataGraph(this);
+ }
+
+ public Sequence getSequence() {
+ EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass());
+ return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null;
+ }
+
+ public List getInstanceProperties() {
+ return DataObjectUtil.getInstanceProperties(this);
+ }
+
+ public DataObject getRootObject() {
+ return DataObjectUtil.getRootObject(this);
+ }
+
+ public ChangeSummary getChangeSummary() {
+ // TODO: implement this method
+ throw new UnsupportedOperationException();
+ }
+
+ public void detach() {
+ throw new UnsupportedOperationException("Property is frozen and cannot be modified");
+ //DataObjectUtil.detach(this);
+ }
+
+ public Property getProperty(String propertyName) {
+ return DataObjectUtil.getProperty(this, propertyName);
+ }
+ */
+
+} //ReferenceImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java
new file mode 100644
index 0000000000..bb0f5ccd2a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java
@@ -0,0 +1,337 @@
+/**
+ *
+ * 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.impl;
+
+import org.apache.tuscany.sdo.AnyTypeDataObject;
+import org.apache.tuscany.sdo.SDOFactory;
+import org.apache.tuscany.sdo.SDOPackage;
+import org.apache.tuscany.sdo.SimpleAnyTypeDataObject;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+import org.eclipse.emf.ecore.impl.EcoreFactoryImpl;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+/**
+ *
+ * An implementation of the model Factory.
+ *
+ * @generated
+ */
+public class SDOFactoryImpl extends EFactoryImpl implements SDOFactory
+{
+ /**
+ * Creates the default factory implementation.
+ *
+ *
+ * @generated NOT
+ */
+ public static SDOFactory init()
+ {
+ try
+ {
+ SDOFactory theSDOFactory = (SDOFactory)EPackage.Registry.INSTANCE.getEFactory(SDOPackage.eNS_URI);
+ if (theSDOFactory != null)
+ {
+ return theSDOFactory;
+ }
+ }
+ catch (Exception exception)
+ {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new SDOFactoryImpl();
+ }
+
+ public static class SDOEcoreFactory extends EcoreFactoryImpl
+ {
+ public EClass createEClass() { return new ClassImpl(); }
+ public EDataType createEDataType() { return new DataTypeImpl(); }
+ //public EEnum createEEnum() { return new EnumImpl(); }
+ public EAttribute createEAttribute() { return new AttributeImpl(); }
+ public EReference createEReference() { return new ReferenceImpl(); }
+
+// public EFactory createEFactory()
+// {
+// EFactoryImpl eFactory = new EFactoryImpl() { OVERRIDE basicCreate(); } // TODO think about doing this
+// return eFactory;
+// }
+ }
+
+ /**
+ * Creates an instance of the factory.
+ *
+ *
+ * @generated
+ */
+ public SDOFactoryImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EObject create(EClass eClass)
+ {
+ switch (eClass.getClassifierID())
+ {
+ case SDOPackage.CHANGE_SUMMARY: return (EObject)createChangeSummary();
+ case SDOPackage.CHANGE_SUMMARY_SETTING: return (EObject)createChangeSummarySetting();
+ case SDOPackage.DATA_GRAPH: return (EObject)createDataGraph();
+ case SDOPackage.ANY_TYPE_DATA_OBJECT: return createAnyTypeDataObject();
+ case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT: return createSimpleAnyTypeDataObject();
+ case SDOPackage.CLASS: return (EObject)createClass();
+ case SDOPackage.DATA_TYPE: return (EObject)createDataType();
+ case SDOPackage.ATTRIBUTE: return (EObject)createAttribute();
+ case SDOPackage.REFERENCE: return (EObject)createReference();
+ case SDOPackage.ENUM: return (EObject)createEnum();
+ case SDOPackage.DYNAMIC_DATA_OBJECT: return (EObject)createDynamicDataObject();
+ case SDOPackage.STORE_DATA_OBJECT: return (EObject)createStoreDataObject();
+ case SDOPackage.DYNAMIC_STORE_DATA_OBJECT: return (EObject)createDynamicStoreDataObject();
+ case SDOPackage.EXTENSIBLE_DATA_OBJECT: return (EObject)createExtensibleDataObject();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Object createFromString(EDataType eDataType, String initialValue)
+ {
+ switch (eDataType.getClassifierID())
+ {
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String convertToString(EDataType eDataType, Object instanceValue)
+ {
+ switch (eDataType.getClassifierID())
+ {
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public ChangeSummary createChangeSummary()
+ {
+ ChangeSummaryImpl changeSummary = new ChangeSummaryImpl();
+ return changeSummary;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public ChangeSummary.Setting createChangeSummarySetting()
+ {
+ ChangeSummarySettingImpl changeSummarySetting = new ChangeSummarySettingImpl();
+ return changeSummarySetting;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataGraph createDataGraph()
+ {
+ DataGraphImpl dataGraph = new DataGraphImpl();
+ return dataGraph;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public AnyTypeDataObject createAnyTypeDataObject()
+ {
+ AnyTypeDataObjectImpl anyTypeDataObject = new AnyTypeDataObjectImpl();
+ return anyTypeDataObject;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public SimpleAnyTypeDataObject createSimpleAnyTypeDataObject()
+ {
+ SimpleAnyTypeDataObjectImpl simpleAnyTypeDataObject = new SimpleAnyTypeDataObjectImpl();
+ return simpleAnyTypeDataObject;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Type createClass()
+ {
+ ClassImpl class_ = new ClassImpl();
+ return class_;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Type createDataType()
+ {
+ DataTypeImpl dataType = new DataTypeImpl();
+ return dataType;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Property createAttribute()
+ {
+ AttributeImpl attribute = new AttributeImpl();
+ return attribute;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Property createReference()
+ {
+ ReferenceImpl reference = new ReferenceImpl();
+ return reference;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Type createEnum()
+ {
+ EnumImpl enum_ = new EnumImpl();
+ return enum_;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataObject createDynamicDataObject()
+ {
+ DynamicDataObjectImpl dynamicDataObject = new DynamicDataObjectImpl();
+ return dynamicDataObject;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataObject createStoreDataObject()
+ {
+ StoreDataObjectImpl storeDataObject = new StoreDataObjectImpl();
+ return storeDataObject;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataObject createDynamicStoreDataObject()
+ {
+ DynamicStoreDataObjectImpl dynamicStoreDataObject = new DynamicStoreDataObjectImpl();
+ return dynamicStoreDataObject;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataObject createExtensibleDataObject()
+ {
+ ExtensibleDataObjectImpl extensibleDataObject = new ExtensibleDataObjectImpl();
+ return extensibleDataObject;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public SDOPackage getSDOPackage()
+ {
+ return (SDOPackage)getEPackage();
+ }
+
+ /**
+ *
+ *
+ * @deprecated
+ * @generated
+ */
+ public static SDOPackage getPackage()
+ {
+ return SDOPackage.eINSTANCE;
+ }
+
+ public ChangeSummary.Setting createChangeSummarySetting(EStructuralFeature eStructuralFeature, Object value, boolean isSet)
+ {
+ ChangeSummarySettingImpl eChangeSummarySetting = new ChangeSummarySettingImpl(eStructuralFeature, value, isSet);
+ return eChangeSummarySetting;
+ }
+
+} //SDOFactoryImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java
new file mode 100644
index 0000000000..25bdab16fe
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java
@@ -0,0 +1,2207 @@
+/**
+ *
+ * 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.impl;
+
+import java.io.ObjectStreamException;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.sdo.AnyTypeDataObject;
+import org.apache.tuscany.sdo.SDOFactory;
+import org.apache.tuscany.sdo.SDOPackage;
+import org.apache.tuscany.sdo.SimpleAnyTypeDataObject;
+import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.change.ChangePackage;
+import org.eclipse.emf.ecore.change.impl.ChangePackageImpl;
+import org.eclipse.emf.ecore.impl.EClassImpl;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.emf.ecore.impl.EcorePackageImpl;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+import org.eclipse.emf.ecore.xml.type.impl.XMLTypePackageImpl;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+
+/**
+ *
+ * An implementation of the model Package.
+ *
+ * @generated
+ */
+public class SDOPackageImpl extends EPackageImpl implements SDOPackage
+{
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass changeSummaryEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass changeSummarySettingEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass dataGraphEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass dataObjectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass propertyEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass sequenceEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass typeEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass anyTypeDataObjectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass simpleAnyTypeDataObjectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass classEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass dataTypeEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass attributeEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass referenceEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass enumEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass dynamicDataObjectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass storeDataObjectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass dynamicStoreDataObjectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass extensibleDataObjectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EDataType eJavaListEDataType = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EDataType eObjectStreamExceptionEDataType = null;
+
+ /**
+ * Creates an instance of the model Package, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ *
Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ *
+ *
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.apache.tuscany.sdo.SDOPackage#eNS_URI
+ * @see #init()
+ * @generated NOT
+ */
+ private SDOPackageImpl()
+ {
+ super(eNS_URI, SDOFactory.eINSTANCE);
+ ecoreFactory = new SDOEcoreFactory();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the Package for this
+ * model, and for any others upon which it depends. Simple
+ * dependencies are satisfied by calling this method on all
+ * dependent packages before doing anything else. This method drives
+ * initialization for interdependent packages directly, in parallel
+ * with this package, itself.
+ *
Of this package and its interdependencies, all packages which
+ * have not yet been registered by their URI values are first created
+ * and registered. The packages are then initialized in two steps:
+ * meta-model objects for all of the packages are created before any
+ * are initialized, since one package's meta-model objects may refer to
+ * those of another.
+ *
{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getAnyAttribute Any Attribute}
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface BaseDataGraphType extends Serializable
+{
+ /**
+ * Returns the value of the 'Models' containment reference.
+ *
+ *
+ * If the meaning of the 'Models' containment reference isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Models' containment reference.
+ * @see #isSetModels()
+ * @see #unsetModels()
+ * @see #setModels(ModelsType)
+ * @generated
+ */
+ ModelsType getModels();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels Models}' containment reference.
+ *
+ *
+ * @param value the new value of the 'Models' containment reference.
+ * @see #isSetModels()
+ * @see #unsetModels()
+ * @see #getModels()
+ * @generated
+ */
+ void setModels(ModelsType value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels Models}' containment reference.
+ *
+ *
+ * @see #isSetModels()
+ * @see #getModels()
+ * @see #setModels(ModelsType)
+ * @generated
+ */
+ void unsetModels();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels Models}' containment reference is set.
+ *
+ *
+ * @return whether the value of the 'Models' containment reference is set.
+ * @see #unsetModels()
+ * @see #getModels()
+ * @see #setModels(ModelsType)
+ * @generated
+ */
+ boolean isSetModels();
+
+ /**
+ * Returns the value of the 'Xsd' containment reference.
+ *
+ *
+ * If the meaning of the 'Xsd' containment reference isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Xsd' containment reference.
+ * @see #isSetXsd()
+ * @see #unsetXsd()
+ * @see #setXsd(XSDType)
+ * @generated
+ */
+ XSDType getXsd();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd Xsd}' containment reference.
+ *
+ *
+ * @param value the new value of the 'Xsd' containment reference.
+ * @see #isSetXsd()
+ * @see #unsetXsd()
+ * @see #getXsd()
+ * @generated
+ */
+ void setXsd(XSDType value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd Xsd}' containment reference.
+ *
+ *
+ * @see #isSetXsd()
+ * @see #getXsd()
+ * @see #setXsd(XSDType)
+ * @generated
+ */
+ void unsetXsd();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd Xsd}' containment reference is set.
+ *
+ *
+ * @return whether the value of the 'Xsd' containment reference is set.
+ * @see #unsetXsd()
+ * @see #getXsd()
+ * @see #setXsd(XSDType)
+ * @generated
+ */
+ boolean isSetXsd();
+
+ /**
+ * Returns the value of the 'Change Summary' attribute.
+ *
+ *
+ * If the meaning of the 'Change Summary' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Change Summary' attribute.
+ * @see #isSetChangeSummary()
+ * @see #unsetChangeSummary()
+ * @see #setChangeSummary(ChangeSummary)
+ * @generated
+ */
+ ChangeSummary getChangeSummary();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary Change Summary}' attribute.
+ *
+ *
+ * @param value the new value of the 'Change Summary' attribute.
+ * @see #isSetChangeSummary()
+ * @see #unsetChangeSummary()
+ * @see #getChangeSummary()
+ * @generated
+ */
+ void setChangeSummary(ChangeSummary value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary Change Summary}' attribute.
+ *
+ *
+ * @see #isSetChangeSummary()
+ * @see #getChangeSummary()
+ * @see #setChangeSummary(ChangeSummary)
+ * @generated
+ */
+ void unsetChangeSummary();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary Change Summary}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Change Summary' attribute is set.
+ * @see #unsetChangeSummary()
+ * @see #getChangeSummary()
+ * @see #setChangeSummary(ChangeSummary)
+ * @generated
+ */
+ boolean isSetChangeSummary();
+
+ /**
+ * Returns the value of the 'Any Attribute' attribute list.
+ *
+ *
+ * If the meaning of the 'Any Attribute' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any Attribute' attribute list.
+ * @generated
+ */
+ Sequence getAnyAttribute();
+
+} // BaseDataGraphType
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java
new file mode 100644
index 0000000000..2c83244789
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * 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.model;
+
+import commonj.sdo.Sequence;
+
+/**
+ *
+ * A representation of the model object 'Data Graph Type'.
+ *
+ *
+ *
+ *
+ *
+ * @generated
+ */
+public interface DataGraphType extends BaseDataGraphType
+{
+ /**
+ * Returns the value of the 'Any' attribute list.
+ *
+ *
+ * If the meaning of the 'Any' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any' attribute list.
+ * @generated
+ */
+ Sequence getAny();
+
+} // DataGraphType
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java
new file mode 100644
index 0000000000..9e3b2a1386
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.model;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A representation of the model object 'Data Object'.
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface DataObject extends Serializable
+{
+} // DataObject
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java
new file mode 100644
index 0000000000..c8fe69167e
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java
@@ -0,0 +1,106 @@
+/**
+ *
+ * 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.model;
+
+import commonj.sdo.helper.HelperContext;
+
+
+/**
+ *
+ * The Factory for the model.
+ * It provides a create method for each non-abstract class of the model.
+ *
+ * @generated
+ */
+public interface ModelFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ *
+ *
+ * @generated
+ */
+ ModelFactory INSTANCE = org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.init();
+
+ /**
+ * Returns a new object of class 'Data Graph Type'.
+ *
+ *
+ * @return a new object of class 'Data Graph Type'.
+ * @generated
+ */
+ DataGraphType createDataGraphType();
+
+ /**
+ * Returns a new object of class 'Models Type'.
+ *
+ *
+ * @return a new object of class 'Models Type'.
+ * @generated
+ */
+ ModelsType createModelsType();
+
+ /**
+ * Returns a new object of class 'Property'.
+ *
+ *
+ * @return a new object of class 'Property'.
+ * @generated
+ */
+ Property createProperty();
+
+ /**
+ * Returns a new object of class 'Type'.
+ *
+ *
+ * @return a new object of class 'Type'.
+ * @generated
+ */
+ Type createType();
+
+ /**
+ * Returns a new object of class 'Types'.
+ *
+ *
+ * @return a new object of class 'Types'.
+ * @generated
+ */
+ Types createTypes();
+
+ /**
+ * Returns a new object of class 'XSD Type'.
+ *
+ *
+ * @return a new object of class 'XSD Type'.
+ * @generated
+ */
+ XSDType createXSDType();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ *
+ *
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //ModelFactory
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java
new file mode 100644
index 0000000000..4159ac9dc1
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * 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.model;
+
+import commonj.sdo.Sequence;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A representation of the model object 'Models Type'.
+ *
+ *
+ *
+ *
+ * Expected type is emof:Package.
+ *
+ *
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface ModelsType extends Serializable
+{
+ /**
+ * Returns the value of the 'Any' attribute list.
+ *
+ *
+ * If the meaning of the 'Any' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any' attribute list.
+ * @generated
+ */
+ Sequence getAny();
+
+} // ModelsType
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java
new file mode 100644
index 0000000000..15ee4c2f99
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java
@@ -0,0 +1,503 @@
+/**
+ *
+ * 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.model;
+
+import commonj.sdo.Sequence;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+/**
+ *
+ * A representation of the model object 'Property'.
+ *
+ *
+ *
+ * The following features are supported:
+ *
+ *
{@link org.apache.tuscany.sdo.model.Property#getAliasName Alias Name}
{@link org.apache.tuscany.sdo.model.Property#getAnyAttribute Any Attribute}
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface Property extends Serializable
+{
+ /**
+ * Returns the value of the 'Alias Name' attribute list.
+ * The list contents are of type {@link java.lang.String}.
+ *
+ *
+ * If the meaning of the 'Alias Name' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Alias Name' attribute list.
+ * @generated
+ */
+ List getAliasName();
+
+ /**
+ * Returns the value of the 'Any' attribute list.
+ *
+ *
+ * If the meaning of the 'Any' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any' attribute list.
+ * @generated
+ */
+ Sequence getAny();
+
+ /**
+ * Returns the value of the 'Name' attribute.
+ *
+ *
+ * If the meaning of the 'Name' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Name' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #setName(String)
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getName Name}' attribute.
+ *
+ *
+ * @param value the new value of the 'Name' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getName Name}' attribute.
+ *
+ *
+ * @see #isSetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ void unsetName();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getName Name}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Name' attribute is set.
+ * @see #unsetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ boolean isSetName();
+
+ /**
+ * Returns the value of the 'Many' attribute.
+ *
+ *
+ * If the meaning of the 'Many' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Many' attribute.
+ * @see #isSetMany()
+ * @see #unsetMany()
+ * @see #setMany(boolean)
+ * @generated
+ */
+ boolean isMany();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany Many}' attribute.
+ *
+ *
+ * @param value the new value of the 'Many' attribute.
+ * @see #isSetMany()
+ * @see #unsetMany()
+ * @see #isMany()
+ * @generated
+ */
+ void setMany(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany Many}' attribute.
+ *
+ *
+ * @see #isSetMany()
+ * @see #isMany()
+ * @see #setMany(boolean)
+ * @generated
+ */
+ void unsetMany();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany Many}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Many' attribute is set.
+ * @see #unsetMany()
+ * @see #isMany()
+ * @see #setMany(boolean)
+ * @generated
+ */
+ boolean isSetMany();
+
+ /**
+ * Returns the value of the 'Containment' attribute.
+ *
+ *
+ * If the meaning of the 'Containment' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Containment' attribute.
+ * @see #isSetContainment()
+ * @see #unsetContainment()
+ * @see #setContainment(boolean)
+ * @generated
+ */
+ boolean isContainment();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment Containment}' attribute.
+ *
+ *
+ * @param value the new value of the 'Containment' attribute.
+ * @see #isSetContainment()
+ * @see #unsetContainment()
+ * @see #isContainment()
+ * @generated
+ */
+ void setContainment(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment Containment}' attribute.
+ *
+ *
+ * @see #isSetContainment()
+ * @see #isContainment()
+ * @see #setContainment(boolean)
+ * @generated
+ */
+ void unsetContainment();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment Containment}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Containment' attribute is set.
+ * @see #unsetContainment()
+ * @see #isContainment()
+ * @see #setContainment(boolean)
+ * @generated
+ */
+ boolean isSetContainment();
+
+ /**
+ * Returns the value of the 'Default' attribute.
+ *
+ *
+ * If the meaning of the 'Default' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Default' attribute.
+ * @see #isSetDefault()
+ * @see #unsetDefault()
+ * @see #setDefault_(String)
+ * @generated
+ */
+ String getDefault_();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getDefault Default}' attribute.
+ *
+ *
+ * @param value the new value of the 'Default' attribute.
+ * @see #isSetDefault()
+ * @see #unsetDefault()
+ * @see #getDefault_()
+ * @generated
+ */
+ void setDefault_(String value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getDefault Default}' attribute.
+ *
+ *
+ * @see #isSetDefault()
+ * @see #getDefault_()
+ * @see #setDefault_(String)
+ * @generated
+ */
+ void unsetDefault();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getDefault Default}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Default' attribute is set.
+ * @see #unsetDefault()
+ * @see #getDefault_()
+ * @see #setDefault_(String)
+ * @generated
+ */
+ boolean isSetDefault();
+
+ /**
+ * Returns the value of the 'Read Only' attribute.
+ *
+ *
+ * If the meaning of the 'Read Only' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Read Only' attribute.
+ * @see #isSetReadOnly()
+ * @see #unsetReadOnly()
+ * @see #setReadOnly(boolean)
+ * @generated
+ */
+ boolean isReadOnly();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly Read Only}' attribute.
+ *
+ *
+ * @param value the new value of the 'Read Only' attribute.
+ * @see #isSetReadOnly()
+ * @see #unsetReadOnly()
+ * @see #isReadOnly()
+ * @generated
+ */
+ void setReadOnly(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly Read Only}' attribute.
+ *
+ *
+ * @see #isSetReadOnly()
+ * @see #isReadOnly()
+ * @see #setReadOnly(boolean)
+ * @generated
+ */
+ void unsetReadOnly();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly Read Only}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Read Only' attribute is set.
+ * @see #unsetReadOnly()
+ * @see #isReadOnly()
+ * @see #setReadOnly(boolean)
+ * @generated
+ */
+ boolean isSetReadOnly();
+
+ /**
+ * Returns the value of the 'Type' reference.
+ *
+ *
+ * If the meaning of the 'Type' reference isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Type' reference.
+ * @see #isSetType()
+ * @see #unsetType()
+ * @see #setType(Type)
+ * @generated
+ */
+ Type getType_();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getType_ Type}' reference.
+ *
+ *
+ * @param value the new value of the 'Type' reference.
+ * @see #isSetType()
+ * @see #unsetType()
+ * @see #getType_()
+ * @generated
+ */
+ void setType(Type value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getType_ Type}' reference.
+ *
+ *
+ * @see #isSetType()
+ * @see #getType_()
+ * @see #setType(Type)
+ * @generated
+ */
+ void unsetType();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getType_ Type}' reference is set.
+ *
+ *
+ * @return whether the value of the 'Type' reference is set.
+ * @see #unsetType()
+ * @see #getType_()
+ * @see #setType(Type)
+ * @generated
+ */
+ boolean isSetType();
+
+ /**
+ * Returns the value of the 'Opposite' reference.
+ *
+ *
+ * If the meaning of the 'Opposite' reference isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Opposite' reference.
+ * @see #isSetOpposite()
+ * @see #unsetOpposite()
+ * @see #setOpposite_(Property)
+ * @generated
+ */
+ Property getOpposite_();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getOpposite Opposite}' reference.
+ *
+ *
+ * @param value the new value of the 'Opposite' reference.
+ * @see #isSetOpposite()
+ * @see #unsetOpposite()
+ * @see #getOpposite_()
+ * @generated
+ */
+ void setOpposite_(Property value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getOpposite Opposite}' reference.
+ *
+ *
+ * @see #isSetOpposite()
+ * @see #getOpposite_()
+ * @see #setOpposite_(Property)
+ * @generated
+ */
+ void unsetOpposite();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getOpposite Opposite}' reference is set.
+ *
+ *
+ * @return whether the value of the 'Opposite' reference is set.
+ * @see #unsetOpposite()
+ * @see #getOpposite_()
+ * @see #setOpposite_(Property)
+ * @generated
+ */
+ boolean isSetOpposite();
+
+ /**
+ * Returns the value of the 'Nullable' attribute.
+ *
+ *
+ * If the meaning of the 'Nullable' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Nullable' attribute.
+ * @see #isSetNullable()
+ * @see #unsetNullable()
+ * @see #setNullable(boolean)
+ * @generated
+ */
+ boolean isNullable();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isNullable Nullable}' attribute.
+ *
+ *
+ * @param value the new value of the 'Nullable' attribute.
+ * @see #isSetNullable()
+ * @see #unsetNullable()
+ * @see #isNullable()
+ * @generated
+ */
+ void setNullable(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isNullable Nullable}' attribute.
+ *
+ *
+ * @see #isSetNullable()
+ * @see #isNullable()
+ * @see #setNullable(boolean)
+ * @generated
+ */
+ void unsetNullable();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isNullable Nullable}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Nullable' attribute is set.
+ * @see #unsetNullable()
+ * @see #isNullable()
+ * @see #setNullable(boolean)
+ * @generated
+ */
+ boolean isSetNullable();
+
+ /**
+ * Returns the value of the 'Any Attribute' attribute list.
+ *
+ *
+ * If the meaning of the 'Any Attribute' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any Attribute' attribute list.
+ * @generated
+ */
+ Sequence getAnyAttribute();
+
+} // Property
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java
new file mode 100644
index 0000000000..741343e5a8
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * 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.model;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+/**
+ *
+ * A representation of the model object 'Text Type'.
+ *
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface TextType extends Serializable
+{
+ /**
+ * Returns the value of the 'Text' attribute list.
+ * The list contents are of type {@link java.lang.String}.
+ *
+ *
+ * If the meaning of the 'Text' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Text' attribute list.
+ * @generated
+ */
+ List getText();
+
+} // TextType
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java
new file mode 100644
index 0000000000..26a02f7cc0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java
@@ -0,0 +1,431 @@
+/**
+ *
+ * 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.model;
+
+import commonj.sdo.Sequence;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+/**
+ *
+ * A representation of the model object 'Type'.
+ *
+ *
+ *
+ * The following features are supported:
+ *
+ *
{@link org.apache.tuscany.sdo.model.Type#getBaseType Base Type}
{@link org.apache.tuscany.sdo.model.Type#getAnyAttribute Any Attribute}
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface Type extends Serializable
+{
+ /**
+ * Returns the value of the 'Base Type' reference list.
+ * The list contents are of type {@link org.apache.tuscany.sdo.model.Type}.
+ *
+ *
+ * If the meaning of the 'Base Type' reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Base Type' reference list.
+ * @generated
+ */
+ List getBaseType();
+
+ /**
+ * Returns the value of the 'Property' containment reference list.
+ * The list contents are of type {@link org.apache.tuscany.sdo.model.Property}.
+ *
+ *
+ * If the meaning of the 'Property' containment reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Property' containment reference list.
+ * @generated
+ */
+ List getProperty();
+
+ /**
+ * Returns the value of the 'Alias Name' attribute list.
+ * The list contents are of type {@link java.lang.String}.
+ *
+ *
+ * If the meaning of the 'Alias Name' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Alias Name' attribute list.
+ * @generated
+ */
+ List getAliasName();
+
+ /**
+ * Returns the value of the 'Any' attribute list.
+ *
+ *
+ * If the meaning of the 'Any' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any' attribute list.
+ * @generated
+ */
+ Sequence getAny();
+
+ /**
+ * Returns the value of the 'Name' attribute.
+ *
+ *
+ * If the meaning of the 'Name' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Name' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #setName(String)
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#getName Name}' attribute.
+ *
+ *
+ * @param value the new value of the 'Name' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#getName Name}' attribute.
+ *
+ *
+ * @see #isSetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ void unsetName();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#getName Name}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Name' attribute is set.
+ * @see #unsetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ boolean isSetName();
+
+ /**
+ * Returns the value of the 'Uri' attribute.
+ *
+ *
+ * If the meaning of the 'Uri' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Uri' attribute.
+ * @see #isSetUri()
+ * @see #unsetUri()
+ * @see #setUri(String)
+ * @generated
+ */
+ String getUri();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#getUri Uri}' attribute.
+ *
+ *
+ * @param value the new value of the 'Uri' attribute.
+ * @see #isSetUri()
+ * @see #unsetUri()
+ * @see #getUri()
+ * @generated
+ */
+ void setUri(String value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#getUri Uri}' attribute.
+ *
+ *
+ * @see #isSetUri()
+ * @see #getUri()
+ * @see #setUri(String)
+ * @generated
+ */
+ void unsetUri();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#getUri Uri}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Uri' attribute is set.
+ * @see #unsetUri()
+ * @see #getUri()
+ * @see #setUri(String)
+ * @generated
+ */
+ boolean isSetUri();
+
+ /**
+ * Returns the value of the 'Data Type' attribute.
+ *
+ *
+ * If the meaning of the 'Data Type' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Data Type' attribute.
+ * @see #isSetDataType()
+ * @see #unsetDataType()
+ * @see #setDataType(boolean)
+ * @generated
+ */
+ boolean isDataType();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType Data Type}' attribute.
+ *
+ *
+ * @param value the new value of the 'Data Type' attribute.
+ * @see #isSetDataType()
+ * @see #unsetDataType()
+ * @see #isDataType()
+ * @generated
+ */
+ void setDataType(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType Data Type}' attribute.
+ *
+ *
+ * @see #isSetDataType()
+ * @see #isDataType()
+ * @see #setDataType(boolean)
+ * @generated
+ */
+ void unsetDataType();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType Data Type}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Data Type' attribute is set.
+ * @see #unsetDataType()
+ * @see #isDataType()
+ * @see #setDataType(boolean)
+ * @generated
+ */
+ boolean isSetDataType();
+
+ /**
+ * Returns the value of the 'Open' attribute.
+ *
+ *
+ * If the meaning of the 'Open' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Open' attribute.
+ * @see #isSetOpen()
+ * @see #unsetOpen()
+ * @see #setOpen(boolean)
+ * @generated
+ */
+ boolean isOpen();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen Open}' attribute.
+ *
+ *
+ * @param value the new value of the 'Open' attribute.
+ * @see #isSetOpen()
+ * @see #unsetOpen()
+ * @see #isOpen()
+ * @generated
+ */
+ void setOpen(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen Open}' attribute.
+ *
+ *
+ * @see #isSetOpen()
+ * @see #isOpen()
+ * @see #setOpen(boolean)
+ * @generated
+ */
+ void unsetOpen();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen Open}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Open' attribute is set.
+ * @see #unsetOpen()
+ * @see #isOpen()
+ * @see #setOpen(boolean)
+ * @generated
+ */
+ boolean isSetOpen();
+
+ /**
+ * Returns the value of the 'Sequenced' attribute.
+ *
+ *
+ * If the meaning of the 'Sequenced' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Sequenced' attribute.
+ * @see #isSetSequenced()
+ * @see #unsetSequenced()
+ * @see #setSequenced(boolean)
+ * @generated
+ */
+ boolean isSequenced();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced Sequenced}' attribute.
+ *
+ *
+ * @param value the new value of the 'Sequenced' attribute.
+ * @see #isSetSequenced()
+ * @see #unsetSequenced()
+ * @see #isSequenced()
+ * @generated
+ */
+ void setSequenced(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced Sequenced}' attribute.
+ *
+ *
+ * @see #isSetSequenced()
+ * @see #isSequenced()
+ * @see #setSequenced(boolean)
+ * @generated
+ */
+ void unsetSequenced();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced Sequenced}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Sequenced' attribute is set.
+ * @see #unsetSequenced()
+ * @see #isSequenced()
+ * @see #setSequenced(boolean)
+ * @generated
+ */
+ boolean isSetSequenced();
+
+ /**
+ * Returns the value of the 'Abstract' attribute.
+ *
+ *
+ * If the meaning of the 'Abstract' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Abstract' attribute.
+ * @see #isSetAbstract()
+ * @see #unsetAbstract()
+ * @see #setAbstract(boolean)
+ * @generated
+ */
+ boolean isAbstract();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract Abstract}' attribute.
+ *
+ *
+ * @param value the new value of the 'Abstract' attribute.
+ * @see #isSetAbstract()
+ * @see #unsetAbstract()
+ * @see #isAbstract()
+ * @generated
+ */
+ void setAbstract(boolean value);
+
+ /**
+ * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract Abstract}' attribute.
+ *
+ *
+ * @see #isSetAbstract()
+ * @see #isAbstract()
+ * @see #setAbstract(boolean)
+ * @generated
+ */
+ void unsetAbstract();
+
+ /**
+ * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract Abstract}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Abstract' attribute is set.
+ * @see #unsetAbstract()
+ * @see #isAbstract()
+ * @see #setAbstract(boolean)
+ * @generated
+ */
+ boolean isSetAbstract();
+
+ /**
+ * Returns the value of the 'Any Attribute' attribute list.
+ *
+ *
+ * If the meaning of the 'Any Attribute' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any Attribute' attribute list.
+ * @generated
+ */
+ Sequence getAnyAttribute();
+
+ String getInstanceClassName();
+
+} // Type
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java
new file mode 100644
index 0000000000..26fb9c57ce
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java
@@ -0,0 +1,59 @@
+/**
+ *
+ * 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.model;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+/**
+ *
+ * A representation of the model object 'Types'.
+ *
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface Types extends Serializable
+{
+ /**
+ * Returns the value of the 'Type' containment reference list.
+ * The list contents are of type {@link org.apache.tuscany.sdo.model.Type}.
+ *
+ *
+ * If the meaning of the 'Type' containment reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Type' containment reference list.
+ * @generated
+ */
+ List getType_();
+
+ List getTypeList();
+
+} // Types
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java
new file mode 100644
index 0000000000..32cde02086
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * 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.model;
+
+import commonj.sdo.Sequence;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A representation of the model object 'XSD Type'.
+ *
+ *
+ *
+ *
+ * Expected type is xsd:schema.
+ *
+ *
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface XSDType extends Serializable
+{
+ /**
+ * Returns the value of the 'Any' attribute list.
+ *
+ *
+ * If the meaning of the 'Any' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Any' attribute list.
+ * @generated
+ */
+ Sequence getAny();
+
+} // XSDType
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java
new file mode 100644
index 0000000000..e8824974a0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java
@@ -0,0 +1,625 @@
+/**
+ *
+ * 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.model.impl;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+
+import org.apache.tuscany.sdo.impl.DataObjectBase;
+
+import org.apache.tuscany.sdo.model.BaseDataGraphType;
+import org.apache.tuscany.sdo.model.ModelFactory;
+import org.apache.tuscany.sdo.model.ModelsType;
+import org.apache.tuscany.sdo.model.XSDType;
+
+/**
+ *
+ * An implementation of the model object 'Base Data Graph Type'.
+ *
+ *
+ *
+ *
+ * @generated
+ */
+public class XSDTypeImpl extends DataObjectBase implements XSDType
+{
+
+ public final static int ANY = -1;
+
+ public final static int SDO_PROPERTY_COUNT = 0;
+
+ public final static int EXTENDED_PROPERTY_COUNT = -1;
+
+
+ /**
+ * The internal feature id for the 'Any' attribute list.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_ANY = 0;
+
+ /**
+ * The number of properties for this type.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_PROPERTY_COUNT = 1;
+
+ protected int internalConvertIndex(int internalIndex)
+ {
+ switch (internalIndex)
+ {
+ case INTERNAL_ANY: return ANY;
+ }
+ return super.internalConvertIndex(internalIndex);
+ }
+
+
+ /**
+ * The cached value of the '{@link #getAny() Any}' attribute list.
+ *
+ *
+ * @see #getAny()
+ * @generated
+ * @ordered
+ */
+
+ protected Sequence any = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public XSDTypeImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Type getStaticType()
+ {
+ return ((ModelFactoryImpl)ModelFactory.INSTANCE).getXSDType();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Sequence getAny()
+ {
+ if (any == null)
+ {
+ any = createSequence(INTERNAL_ANY);
+ }
+ return any;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext)
+ {
+ switch (propertyIndex)
+ {
+ case ANY:
+ return removeFromSequence(getAny(), otherEnd, changeContext);
+ }
+ return super.inverseRemove(otherEnd, propertyIndex, changeContext);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Object get(int propertyIndex, boolean resolve)
+ {
+ switch (propertyIndex)
+ {
+ case ANY:
+ // 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 getAny();
+ }
+ return super.get(propertyIndex, resolve);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void set(int propertyIndex, Object newValue)
+ {
+ switch (propertyIndex)
+ {
+ case ANY:
+ setSequence(getAny(), newValue);
+ return;
+ }
+ super.set(propertyIndex, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void unset(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case ANY:
+ unsetSequence(getAny());
+ return;
+ }
+ super.unset(propertyIndex);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public boolean isSet(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case ANY:
+ return any != null && !isSequenceEmpty(getAny());
+ }
+ return super.isSet(propertyIndex);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String toString()
+ {
+ if (isProxy(this)) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (any: ");
+ result.append(any);
+ result.append(')');
+ return result.toString();
+ }
+
+} //XSDTypeImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java
new file mode 100644
index 0000000000..4776cb958f
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * 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.model.internal;
+
+import commonj.sdo.helper.HelperContext;
+
+
+/**
+ *
+ * The Factory for the model.
+ * It provides a create method for each non-abstract class of the model.
+ *
+ * @generated
+ */
+public interface InternalFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ *
+ *
+ * @generated
+ */
+ InternalFactory INSTANCE = org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl.init();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ *
+ *
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //InternalFactory
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java
new file mode 100644
index 0000000000..4517f4a2a9
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java
@@ -0,0 +1,296 @@
+/**
+ *
+ * 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.model.internal.impl;
+
+import commonj.sdo.helper.HelperContext;
+import org.apache.tuscany.sdo.helper.TypeHelperImpl;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+import org.apache.tuscany.sdo.impl.FactoryBase;
+
+import org.apache.tuscany.sdo.model.internal.*;
+import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
+
+/**
+ *
+ * An implementation of the commonj.sdo.internal model factory.
+ * This model is generated from sdoInternal.xsd, in the tuscany-sdo-impl project.
+ * Until the SDO code generator supports regen/merge, follow the following steps to regenerate this model:
+ * 1. Regenerate the model into a temporary directory:
+ * XSD2JavaGenerator -generateBuiltIn http://www.apache.org/tuscany/commonj.sdo.internal -targetDirectory -javaPackage org.apache.tuscany.sdo.model.internal /src/main/resources/xml/sdoInternal.xsd
+ * 2. Delete all the createXXXFromString() and convertXXXToString() methods in the newly generated InternalFactoryImpl and
+ * replace them with the ones from this file (resolve any missing imports).
+ * 3. Comment out all simple depedencies (SDOUtil.registerStaticTypes calls) in the init() method.
+ * 4. Make sure the top of each generated file contains the ASF License.
+ * 5. Move this JavaDoc comment into the newly generated ModelFactoryImpl class.
+ *
+ * @generated
+ */
+public class InternalFactoryImpl extends FactoryBase implements InternalFactory
+{
+
+ /**
+ * The package namespace URI.
+ *
+ *
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "http://www.apache.org/tuscany/commonj.sdo.internal";
+
+ /**
+ * The package namespace name.
+ *
+ *
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "internal";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ *
+ *
+ * @generated
+ */
+ public static final String PATTERN_VERSION = "1.2";
+
+ public static final int BASE64_BYTES = 1;
+ public static final int QNAME = 2;
+
+ /**
+ * Creates an instance of the factory.
+ *
+ *
+ * @generated
+ */
+ public InternalFactoryImpl()
+ {
+ super(NAMESPACE_URI, NAMESPACE_PREFIX, "org.apache.tuscany.sdo.model.internal");
+ }
+
+ /**
+ * 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.
+ *
+ *
+ * @generated
+ */
+ public void register(HelperContext scope)
+ {
+ if(scope == null) {
+ throw new IllegalArgumentException("Scope can not be null");
+ }
+
+ //Register dependent packages with provided scope
+
+ // Initialize this package
+ TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
+ th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataObject create(int typeNumber)
+ {
+ switch (typeNumber)
+ {
+ default:
+ return super.create(typeNumber);
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Object createFromString(int typeNumber, String initialValue)
+ {
+ switch (typeNumber)
+ {
+ case BASE64_BYTES:
+ return createBase64BytesFromString(initialValue);
+ case QNAME:
+ return createQNameFromString(initialValue);
+ default:
+ throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String convertToString(int typeNumber, Object instanceValue)
+ {
+ switch (typeNumber)
+ {
+ case BASE64_BYTES:
+ return convertBase64BytesToString(instanceValue);
+ case QNAME:
+ return convertQNameToString(instanceValue);
+ default:
+ throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype");
+ }
+ }
+
+ // Following creates and initializes SDO metadata for the supported types.
+ protected Type base64BytesType = null;
+
+ public Type getBase64Bytes()
+ {
+ return base64BytesType;
+ }
+
+ protected Type qNameType = null;
+
+ public Type getQName()
+ {
+ return qNameType;
+ }
+
+
+ private static InternalFactoryImpl instance = null;
+ public static InternalFactoryImpl init()
+ {
+ if (instance != null ) return instance;
+ instance = new InternalFactoryImpl();
+
+ // Initialize dependent packages
+
+ // Create package meta-data objects
+ instance.createMetaData();
+
+ // Initialize created meta-data
+ instance.initializeMetaData();
+
+ // Mark meta-data to indicate it can't be changed
+ //theInternalFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ????
+
+ return instance;
+ }
+
+ private boolean isCreated = false;
+
+ public void createMetaData()
+ {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create data types
+ base64BytesType = createType(true, BASE64_BYTES );
+ qNameType = createType(true, QNAME );
+ }
+
+ private boolean isInitialized = false;
+
+ public void initializeMetaData()
+ {
+ if (isInitialized) return;
+ isInitialized = true;
+ Property property = null;
+
+ // Add supertypes to types
+
+ // Initialize types and properties
+ // Initialize data types
+ initializeType(base64BytesType, byte[].class, "Base64Bytes", true, false);
+ setInstanceProperty (base64BytesType, "commonj.sdo/java", "instanceClass", "byte[]");
+
+ initializeType(qNameType, String.class, "QName", true, false);
+ setInstanceProperty (qNameType, "commonj.sdo/java", "instanceClass", "java.lang.String");
+
+ createXSDMetaData();
+ }
+
+ protected void createXSDMetaData()
+ {
+ super.initXSD();
+
+ Property property = null;
+
+
+ addXSDMapping
+ (base64BytesType,
+ new String[]
+ {
+ "name", "Base64Bytes"
+ });
+
+ addXSDMapping
+ (qNameType,
+ new String[]
+ {
+ "name", "QName"
+ });
+
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public byte[] createBase64BytesFromString(String initialValue)
+ {
+ return XMLTypeFactory.eINSTANCE.createBase64Binary(initialValue);
+ }
+
+ /**
+ *
+ *
+ * @generated NOT
+ */
+ public String convertBase64BytesToString(Object instanceValue)
+ {
+ if (instanceValue instanceof byte[]) {
+ return XMLTypeFactory.eINSTANCE.convertBase64Binary((byte[])instanceValue);
+ } else {
+ return XMLTypeFactory.eINSTANCE.convertBase64Binary(instanceValue.toString().getBytes());
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String createQNameFromString(String initialValue)
+ {
+ return (String)super.createFromString(QNAME, initialValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String convertQNameToString(Object instanceValue)
+ {
+ return super.convertToString(QNAME, instanceValue);
+ }
+
+} //InternalFactoryImpl
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java
new file mode 100644
index 0000000000..50be023db5
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java
@@ -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 org.apache.tuscany.sdo.model.java;
+
+import commonj.sdo.helper.HelperContext;
+
+
+/**
+ *
+ * The Factory for the model.
+ * It provides a create method for each non-abstract class of the model.
+ *
+ * @generated
+ */
+public interface JavaFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ *
+ *
+ * @generated
+ */
+ JavaFactory INSTANCE = org.apache.tuscany.sdo.model.java.impl.JavaFactoryImpl.init();
+
+ /**
+ * Returns a new object of class 'Info'.
+ *
+ *
+ * @return a new object of class 'Info'.
+ * @generated
+ */
+ JavaInfo createJavaInfo();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ *
+ *
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //JavaFactory
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java
new file mode 100644
index 0000000000..b5eabb0f4a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * 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.model.java;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A representation of the model object 'Info'.
+ *
+ *
+ *
{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface Type Interface}
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface JavaMetaData extends Serializable
+{
+ /**
+ * Returns the value of the 'Factory Interface' attribute.
+ *
+ *
+ * If the meaning of the 'Factory Interface' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Factory Interface' attribute.
+ * @see #setFactoryInterface(String)
+ * @generated
+ */
+ String getFactoryInterface();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface Factory Interface}' attribute.
+ *
+ *
+ * @param value the new value of the 'Factory Interface' attribute.
+ * @see #getFactoryInterface()
+ * @generated
+ */
+ void setFactoryInterface(String value);
+
+ /**
+ * Returns the value of the 'Type Interface' attribute.
+ *
+ *
+ * If the meaning of the 'Type Interface' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Type Interface' attribute.
+ * @see #setTypeInterface(String)
+ * @generated
+ */
+ String getTypeInterface();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface Type Interface}' attribute.
+ *
+ *
+ * @param value the new value of the 'Type Interface' attribute.
+ * @see #getTypeInterface()
+ * @generated
+ */
+ void setTypeInterface(String value);
+
+} // JavaMetaData
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java
new file mode 100644
index 0000000000..1f540afa2c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java
@@ -0,0 +1,77 @@
+/**
+ *
+ * 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.util.metadata;
+
+
+/**
+ *
+ * The Factory for the model.
+ * It provides a create method for each non-abstract class of the model.
+ *
+ * @generated
+ */
+public interface MetadataFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ *
+ *
+ * @generated
+ */
+ MetadataFactory INSTANCE = org.apache.tuscany.sdo.util.metadata.impl.MetadataFactoryImpl.init();
+
+ /**
+ * Returns a new object of class 'Java Meta Data'.
+ *
+ *
+ * @return a new object of class 'Java Meta Data'.
+ * @generated
+ */
+ JavaMetaData createJavaMetaData();
+
+ /**
+ * Returns a new object of class 'SDO Meta Data Group'.
+ *
+ *
+ * @return a new object of class 'SDO Meta Data Group'.
+ * @generated
+ */
+ SDOMetaDataGroup createSDOMetaDataGroup();
+
+ /**
+ * Returns a new object of class 'Type Meta Data'.
+ *
+ *
+ * @return a new object of class 'Type Meta Data'.
+ * @generated
+ */
+ TypeMetaData createTypeMetaData();
+
+ /**
+ * Returns a new object of class 'XSD Meta Data'.
+ *
+ *
+ * @return a new object of class 'XSD Meta Data'.
+ * @generated
+ */
+ XSDMetaData createXSDMetaData();
+
+} //MetadataFactory
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java
new file mode 100644
index 0000000000..5657f26ca5
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java
@@ -0,0 +1,87 @@
+/**
+ *
+ * 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.util.metadata;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+/**
+ *
+ * A representation of the model object 'SDO Meta Data Group'.
+ *
+ *
+ *
+ * The following features are supported:
+ *
+ *
{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData Java Meta Data}
+ *
{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData Xsd Meta Data}
+ *
{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData Type Meta Data}
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface SDOMetaDataGroup extends Serializable
+{
+ /**
+ * Returns the value of the 'Java Meta Data' containment reference list.
+ * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.JavaMetaData}.
+ *
+ *
+ * If the meaning of the 'Java Meta Data' containment reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Java Meta Data' containment reference list.
+ * @generated
+ */
+ List getJavaMetaData();
+
+ /**
+ * Returns the value of the 'Xsd Meta Data' containment reference list.
+ * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.XSDMetaData}.
+ *
+ *
+ * If the meaning of the 'Xsd Meta Data' containment reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Xsd Meta Data' containment reference list.
+ * @generated
+ */
+ List getXsdMetaData();
+
+ /**
+ * Returns the value of the 'Type Meta Data' containment reference list.
+ * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.TypeMetaData}.
+ *
+ *
+ * If the meaning of the 'Type Meta Data' containment reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Type Meta Data' containment reference list.
+ * @generated
+ */
+ List getTypeMetaData();
+
+} // SDOMetaDataGroup
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java
new file mode 100644
index 0000000000..c3d67a8318
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java
@@ -0,0 +1,65 @@
+/**
+ *
+ * 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.util.metadata;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A representation of the model object 'Type Meta Data'.
+ *
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface TypeMetaData extends Serializable
+{
+ /**
+ * Returns the value of the 'Location' attribute.
+ *
+ *
+ * If the meaning of the 'Location' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Location' attribute.
+ * @see #setLocation(String)
+ * @generated
+ */
+ String getLocation();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation Location}' attribute.
+ *
+ *
+ * @param value the new value of the 'Location' attribute.
+ * @see #getLocation()
+ * @generated
+ */
+ void setLocation(String value);
+
+} // TypeMetaData
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java
new file mode 100644
index 0000000000..09bffece71
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * 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.util.metadata;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A representation of the model object 'XSD Meta Data'.
+ *
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface XSDMetaData extends Serializable
+{
+ /**
+ * Returns the value of the 'Location' attribute.
+ *
+ *
+ * If the meaning of the 'Location' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Location' attribute.
+ * @see #setLocation(String)
+ * @generated
+ */
+ String getLocation();
+
+ /**
+ * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation Location}' attribute.
+ *
+ *
+ * @param value the new value of the 'Location' attribute.
+ * @see #getLocation()
+ * @generated
+ */
+ void setLocation(String value);
+
+} // XSDMetaData
diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java
new file mode 100644
index 0000000000..8a6dce6161
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java
@@ -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 org.apache.tuscany.sdo.util.metadata.impl;
+
+import commonj.sdo.Type;
+
+import org.apache.tuscany.sdo.impl.DataObjectBase;
+
+import org.apache.tuscany.sdo.util.metadata.JavaMetaData;
+import org.apache.tuscany.sdo.util.metadata.MetadataFactory;
+
+/**
+ *
+ * An implementation of the model object 'Java Meta Data'.
+ *
+ *
{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal Read Only Val}
+ *
{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal Read Only List Val}
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface ExpectedExceptionType extends Serializable
+{
+ /**
+ * Returns the value of the 'String Val' attribute.
+ *
+ *
+ * If the meaning of the 'String Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'String Val' attribute.
+ * @see #isSetStringVal()
+ * @see #unsetStringVal()
+ * @see #setStringVal(String)
+ * @generated
+ */
+ String getStringVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal String Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'String Val' attribute.
+ * @see #isSetStringVal()
+ * @see #unsetStringVal()
+ * @see #getStringVal()
+ * @generated
+ */
+ void setStringVal(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal String Val}' attribute.
+ *
+ *
+ * @see #isSetStringVal()
+ * @see #getStringVal()
+ * @see #setStringVal(String)
+ * @generated
+ */
+ void unsetStringVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal String Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'String Val' attribute is set.
+ * @see #unsetStringVal()
+ * @see #getStringVal()
+ * @see #setStringVal(String)
+ * @generated
+ */
+ boolean isSetStringVal();
+
+ /**
+ * Returns the value of the 'Boolean Val' attribute.
+ *
+ *
+ * If the meaning of the 'Boolean Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Boolean Val' attribute.
+ * @see #isSetBooleanVal()
+ * @see #unsetBooleanVal()
+ * @see #setBooleanVal(boolean)
+ * @generated
+ */
+ boolean isBooleanVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal Boolean Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Boolean Val' attribute.
+ * @see #isSetBooleanVal()
+ * @see #unsetBooleanVal()
+ * @see #isBooleanVal()
+ * @generated
+ */
+ void setBooleanVal(boolean value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal Boolean Val}' attribute.
+ *
+ *
+ * @see #isSetBooleanVal()
+ * @see #isBooleanVal()
+ * @see #setBooleanVal(boolean)
+ * @generated
+ */
+ void unsetBooleanVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal Boolean Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Boolean Val' attribute is set.
+ * @see #unsetBooleanVal()
+ * @see #isBooleanVal()
+ * @see #setBooleanVal(boolean)
+ * @generated
+ */
+ boolean isSetBooleanVal();
+
+ /**
+ * Returns the value of the 'Byte Val' attribute.
+ *
+ *
+ * If the meaning of the 'Byte Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Byte Val' attribute.
+ * @see #isSetByteVal()
+ * @see #unsetByteVal()
+ * @see #setByteVal(byte)
+ * @generated
+ */
+ byte getByteVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal Byte Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Byte Val' attribute.
+ * @see #isSetByteVal()
+ * @see #unsetByteVal()
+ * @see #getByteVal()
+ * @generated
+ */
+ void setByteVal(byte value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal Byte Val}' attribute.
+ *
+ *
+ * @see #isSetByteVal()
+ * @see #getByteVal()
+ * @see #setByteVal(byte)
+ * @generated
+ */
+ void unsetByteVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal Byte Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Byte Val' attribute is set.
+ * @see #unsetByteVal()
+ * @see #getByteVal()
+ * @see #setByteVal(byte)
+ * @generated
+ */
+ boolean isSetByteVal();
+
+ /**
+ * Returns the value of the 'Decimal Val' attribute.
+ *
+ *
+ * If the meaning of the 'Decimal Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Decimal Val' attribute.
+ * @see #isSetDecimalVal()
+ * @see #unsetDecimalVal()
+ * @see #setDecimalVal(BigDecimal)
+ * @generated
+ */
+ BigDecimal getDecimalVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal Decimal Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Decimal Val' attribute.
+ * @see #isSetDecimalVal()
+ * @see #unsetDecimalVal()
+ * @see #getDecimalVal()
+ * @generated
+ */
+ void setDecimalVal(BigDecimal value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal Decimal Val}' attribute.
+ *
+ *
+ * @see #isSetDecimalVal()
+ * @see #getDecimalVal()
+ * @see #setDecimalVal(BigDecimal)
+ * @generated
+ */
+ void unsetDecimalVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal Decimal Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Decimal Val' attribute is set.
+ * @see #unsetDecimalVal()
+ * @see #getDecimalVal()
+ * @see #setDecimalVal(BigDecimal)
+ * @generated
+ */
+ boolean isSetDecimalVal();
+
+ /**
+ * Returns the value of the 'Int Val' attribute.
+ *
+ *
+ * If the meaning of the 'Int Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Int Val' attribute.
+ * @see #isSetIntVal()
+ * @see #unsetIntVal()
+ * @see #setIntVal(int)
+ * @generated
+ */
+ int getIntVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal Int Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Int Val' attribute.
+ * @see #isSetIntVal()
+ * @see #unsetIntVal()
+ * @see #getIntVal()
+ * @generated
+ */
+ void setIntVal(int value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal Int Val}' attribute.
+ *
+ *
+ * @see #isSetIntVal()
+ * @see #getIntVal()
+ * @see #setIntVal(int)
+ * @generated
+ */
+ void unsetIntVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal Int Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Int Val' attribute is set.
+ * @see #unsetIntVal()
+ * @see #getIntVal()
+ * @see #setIntVal(int)
+ * @generated
+ */
+ boolean isSetIntVal();
+
+ /**
+ * Returns the value of the 'Float Val' attribute.
+ *
+ *
+ * If the meaning of the 'Float Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Float Val' attribute.
+ * @see #isSetFloatVal()
+ * @see #unsetFloatVal()
+ * @see #setFloatVal(float)
+ * @generated
+ */
+ float getFloatVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal Float Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Float Val' attribute.
+ * @see #isSetFloatVal()
+ * @see #unsetFloatVal()
+ * @see #getFloatVal()
+ * @generated
+ */
+ void setFloatVal(float value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal Float Val}' attribute.
+ *
+ *
+ * @see #isSetFloatVal()
+ * @see #getFloatVal()
+ * @see #setFloatVal(float)
+ * @generated
+ */
+ void unsetFloatVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal Float Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Float Val' attribute is set.
+ * @see #unsetFloatVal()
+ * @see #getFloatVal()
+ * @see #setFloatVal(float)
+ * @generated
+ */
+ boolean isSetFloatVal();
+
+ /**
+ * Returns the value of the 'Double Val' attribute.
+ *
+ *
+ * If the meaning of the 'Double Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Double Val' attribute.
+ * @see #isSetDoubleVal()
+ * @see #unsetDoubleVal()
+ * @see #setDoubleVal(double)
+ * @generated
+ */
+ double getDoubleVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal Double Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Double Val' attribute.
+ * @see #isSetDoubleVal()
+ * @see #unsetDoubleVal()
+ * @see #getDoubleVal()
+ * @generated
+ */
+ void setDoubleVal(double value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal Double Val}' attribute.
+ *
+ *
+ * @see #isSetDoubleVal()
+ * @see #getDoubleVal()
+ * @see #setDoubleVal(double)
+ * @generated
+ */
+ void unsetDoubleVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal Double Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Double Val' attribute is set.
+ * @see #unsetDoubleVal()
+ * @see #getDoubleVal()
+ * @see #setDoubleVal(double)
+ * @generated
+ */
+ boolean isSetDoubleVal();
+
+ /**
+ * Returns the value of the 'Date Val' attribute.
+ *
+ *
+ * If the meaning of the 'Date Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Date Val' attribute.
+ * @see #isSetDateVal()
+ * @see #unsetDateVal()
+ * @see #setDateVal(String)
+ * @generated
+ */
+ String getDateVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal Date Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Date Val' attribute.
+ * @see #isSetDateVal()
+ * @see #unsetDateVal()
+ * @see #getDateVal()
+ * @generated
+ */
+ void setDateVal(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal Date Val}' attribute.
+ *
+ *
+ * @see #isSetDateVal()
+ * @see #getDateVal()
+ * @see #setDateVal(String)
+ * @generated
+ */
+ void unsetDateVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal Date Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Date Val' attribute is set.
+ * @see #unsetDateVal()
+ * @see #getDateVal()
+ * @see #setDateVal(String)
+ * @generated
+ */
+ boolean isSetDateVal();
+
+ /**
+ * Returns the value of the 'Short Val' attribute.
+ *
+ *
+ * If the meaning of the 'Short Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Short Val' attribute.
+ * @see #isSetShortVal()
+ * @see #unsetShortVal()
+ * @see #setShortVal(short)
+ * @generated
+ */
+ short getShortVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal Short Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Short Val' attribute.
+ * @see #isSetShortVal()
+ * @see #unsetShortVal()
+ * @see #getShortVal()
+ * @generated
+ */
+ void setShortVal(short value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal Short Val}' attribute.
+ *
+ *
+ * @see #isSetShortVal()
+ * @see #getShortVal()
+ * @see #setShortVal(short)
+ * @generated
+ */
+ void unsetShortVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal Short Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Short Val' attribute is set.
+ * @see #unsetShortVal()
+ * @see #getShortVal()
+ * @see #setShortVal(short)
+ * @generated
+ */
+ boolean isSetShortVal();
+
+ /**
+ * Returns the value of the 'Long Val' attribute.
+ *
+ *
+ * If the meaning of the 'Long Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Long Val' attribute.
+ * @see #isSetLongVal()
+ * @see #unsetLongVal()
+ * @see #setLongVal(long)
+ * @generated
+ */
+ long getLongVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal Long Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Long Val' attribute.
+ * @see #isSetLongVal()
+ * @see #unsetLongVal()
+ * @see #getLongVal()
+ * @generated
+ */
+ void setLongVal(long value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal Long Val}' attribute.
+ *
+ *
+ * @see #isSetLongVal()
+ * @see #getLongVal()
+ * @see #setLongVal(long)
+ * @generated
+ */
+ void unsetLongVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal Long Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Long Val' attribute is set.
+ * @see #unsetLongVal()
+ * @see #getLongVal()
+ * @see #setLongVal(long)
+ * @generated
+ */
+ boolean isSetLongVal();
+
+ /**
+ * Returns the value of the 'List Val' attribute list.
+ * The list contents are of type {@link java.lang.String}.
+ *
+ *
+ * If the meaning of the 'List Val' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'List Val' attribute list.
+ * @generated
+ */
+ List getListVal();
+
+ /**
+ * Returns the value of the 'Bytes Val' attribute.
+ *
+ *
+ * If the meaning of the 'Bytes Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Bytes Val' attribute.
+ * @see #isSetBytesVal()
+ * @see #unsetBytesVal()
+ * @see #setBytesVal(byte[])
+ * @generated
+ */
+ byte[] getBytesVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal Bytes Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Bytes Val' attribute.
+ * @see #isSetBytesVal()
+ * @see #unsetBytesVal()
+ * @see #getBytesVal()
+ * @generated
+ */
+ void setBytesVal(byte[] value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal Bytes Val}' attribute.
+ *
+ *
+ * @see #isSetBytesVal()
+ * @see #getBytesVal()
+ * @see #setBytesVal(byte[])
+ * @generated
+ */
+ void unsetBytesVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal Bytes Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Bytes Val' attribute is set.
+ * @see #unsetBytesVal()
+ * @see #getBytesVal()
+ * @see #setBytesVal(byte[])
+ * @generated
+ */
+ boolean isSetBytesVal();
+
+ /**
+ * Returns the value of the 'Integer Val' attribute.
+ *
+ *
+ * If the meaning of the 'Integer Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Integer Val' attribute.
+ * @see #isSetIntegerVal()
+ * @see #unsetIntegerVal()
+ * @see #setIntegerVal(BigInteger)
+ * @generated
+ */
+ BigInteger getIntegerVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal Integer Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Integer Val' attribute.
+ * @see #isSetIntegerVal()
+ * @see #unsetIntegerVal()
+ * @see #getIntegerVal()
+ * @generated
+ */
+ void setIntegerVal(BigInteger value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal Integer Val}' attribute.
+ *
+ *
+ * @see #isSetIntegerVal()
+ * @see #getIntegerVal()
+ * @see #setIntegerVal(BigInteger)
+ * @generated
+ */
+ void unsetIntegerVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal Integer Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Integer Val' attribute is set.
+ * @see #unsetIntegerVal()
+ * @see #getIntegerVal()
+ * @see #setIntegerVal(BigInteger)
+ * @generated
+ */
+ boolean isSetIntegerVal();
+
+ /**
+ * Returns the value of the 'Char Val' attribute.
+ *
+ *
+ * If the meaning of the 'Char Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Char Val' attribute.
+ * @see #isSetCharVal()
+ * @see #unsetCharVal()
+ * @see #setCharVal(String)
+ * @generated
+ */
+ String getCharVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal Char Val}' attribute.
+ *
+ *
+ * @param value the new value of the 'Char Val' attribute.
+ * @see #isSetCharVal()
+ * @see #unsetCharVal()
+ * @see #getCharVal()
+ * @generated
+ */
+ void setCharVal(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal Char Val}' attribute.
+ *
+ *
+ * @see #isSetCharVal()
+ * @see #getCharVal()
+ * @see #setCharVal(String)
+ * @generated
+ */
+ void unsetCharVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal Char Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Char Val' attribute is set.
+ * @see #unsetCharVal()
+ * @see #getCharVal()
+ * @see #setCharVal(String)
+ * @generated
+ */
+ boolean isSetCharVal();
+
+ /**
+ * Returns the value of the 'Read Only Val' attribute.
+ *
+ *
+ * If the meaning of the 'Read Only Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Read Only Val' attribute.
+ * @see #isSetReadOnlyVal()
+ * @generated
+ */
+ String getReadOnlyVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal Read Only Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Read Only Val' attribute is set.
+ * @see #getReadOnlyVal()
+ * @generated
+ */
+ boolean isSetReadOnlyVal();
+
+ /**
+ * Returns the value of the 'Read Only List Val' attribute.
+ *
+ *
+ * If the meaning of the 'Read Only List Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Read Only List Val' attribute.
+ * @see #isSetReadOnlyListVal()
+ * @generated
+ */
+ String getReadOnlyListVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal Read Only List Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Read Only List Val' attribute is set.
+ * @see #getReadOnlyListVal()
+ * @generated
+ */
+ boolean isSetReadOnlyListVal();
+
+} // ExpectedExceptionType
diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java
new file mode 100644
index 0000000000..2a2ae0db02
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java
@@ -0,0 +1,158 @@
+/**
+ *
+ * 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.ExpectedException;
+
+import commonj.sdo.Sequence;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A representation of the model object 'Sequence Read Only Type'.
+ *
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface SequenceReadOnlyType extends Serializable
+{
+ /**
+ * Returns the value of the 'Mixed' attribute list.
+ *
+ *
+ * If the meaning of the 'Mixed' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Mixed' attribute list.
+ * @generated
+ */
+ Sequence getMixed();
+
+ /**
+ * Returns the value of the 'Read Only Val' attribute.
+ *
+ *
+ * If the meaning of the 'Read Only Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Read Only Val' attribute.
+ * @see #isSetReadOnlyVal()
+ * @generated
+ */
+ String getReadOnlyVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal Read Only Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Read Only Val' attribute is set.
+ * @see #getReadOnlyVal()
+ * @generated
+ */
+ boolean isSetReadOnlyVal();
+
+ /**
+ * Returns the value of the 'Read Only List Val' attribute.
+ *
+ *
+ * If the meaning of the 'Read Only List Val' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Read Only List Val' attribute.
+ * @see #isSetReadOnlyListVal()
+ * @generated
+ */
+ String getReadOnlyListVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal Read Only List Val}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Read Only List Val' attribute is set.
+ * @see #getReadOnlyListVal()
+ * @generated
+ */
+ boolean isSetReadOnlyListVal();
+
+ /**
+ * Returns the value of the 'Unique Name' attribute.
+ *
+ *
+ * If the meaning of the 'Unique Name' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Unique Name' attribute.
+ * @see #isSetUniqueName()
+ * @see #unsetUniqueName()
+ * @see #setUniqueName(String)
+ * @generated
+ */
+ String getUniqueName();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName Unique Name}' attribute.
+ *
+ *
+ * @param value the new value of the 'Unique Name' attribute.
+ * @see #isSetUniqueName()
+ * @see #unsetUniqueName()
+ * @see #getUniqueName()
+ * @generated
+ */
+ void setUniqueName(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName Unique Name}' attribute.
+ *
+ *
+ * @see #isSetUniqueName()
+ * @see #getUniqueName()
+ * @see #setUniqueName(String)
+ * @generated
+ */
+ void unsetUniqueName();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName Unique Name}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Unique Name' attribute is set.
+ * @see #unsetUniqueName()
+ * @see #getUniqueName()
+ * @see #setUniqueName(String)
+ * @generated
+ */
+ boolean isSetUniqueName();
+
+} // SequenceReadOnlyType
diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java
new file mode 100644
index 0000000000..791c5a4604
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java
@@ -0,0 +1,579 @@
+/**
+ *
+ * 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.ExpectedException.impl;
+
+import commonj.sdo.helper.HelperContext;
+import org.apache.tuscany.sdo.helper.TypeHelperImpl;
+
+import com.example.ExpectedException.*;
+
+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.model.internal.InternalFactory;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+/**
+ *
+ * An implementation of the model Factory.
+ * Generator information:
+ * patternVersion=1.2; -prefix ExpectedException
+ *
+ * @generated
+ */
+public class ExpectedExceptionFactoryImpl extends FactoryBase implements ExpectedExceptionFactory
+{
+
+ /**
+ * The package namespace URI.
+ *
+ *
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "http://example.com/ExpectedException";
+
+ /**
+ * The package namespace name.
+ *
+ *
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "expect";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ *
+ *
+ * @generated
+ */
+ public static final String PATTERN_VERSION = "1.2";
+
+ public static final int EXPECTED_EXCEPTION_TYPE = 1;
+ public static final int SEQUENCE_READ_ONLY_TYPE = 2;
+ public static final int CHAR = 3;
+
+ /**
+ * Creates an instance of the factory.
+ *
+ *
+ * @generated
+ */
+ public ExpectedExceptionFactoryImpl()
+ {
+ super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.sdo.test.ExpectedException");
+ }
+
+ /**
+ * 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.
+ *
+ *
+ * @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);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataObject create(int typeNumber)
+ {
+ switch (typeNumber)
+ {
+ case EXPECTED_EXCEPTION_TYPE: return (DataObject)createExpectedExceptionType();
+ case SEQUENCE_READ_ONLY_TYPE: return (DataObject)createSequenceReadOnlyType();
+ default:
+ return super.create(typeNumber);
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Object createFromString(int typeNumber, String initialValue)
+ {
+ switch (typeNumber)
+ {
+ case CHAR:
+ return createcharFromString(initialValue);
+ default:
+ throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String convertToString(int typeNumber, Object instanceValue)
+ {
+ switch (typeNumber)
+ {
+ case CHAR:
+ return convertcharToString(instanceValue);
+ default:
+ throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype");
+ }
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public ExpectedExceptionType createExpectedExceptionType()
+ {
+ ExpectedExceptionTypeImpl expectedExceptionType = new ExpectedExceptionTypeImpl();
+ return expectedExceptionType;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public SequenceReadOnlyType createSequenceReadOnlyType()
+ {
+ SequenceReadOnlyTypeImpl sequenceReadOnlyType = new SequenceReadOnlyTypeImpl();
+ return sequenceReadOnlyType;
+ }
+
+ // Following creates and initializes SDO metadata for the supported types.
+ protected Type expectedExceptionTypeType = null;
+
+ public Type getExpectedExceptionType()
+ {
+ return expectedExceptionTypeType;
+ }
+
+ protected Type sequenceReadOnlyTypeType = null;
+
+ public Type getSequenceReadOnlyType()
+ {
+ return sequenceReadOnlyTypeType;
+ }
+
+ protected Type char_Type = null;
+
+ public Type getchar()
+ {
+ return char_Type;
+ }
+
+
+ private static boolean isInited = false;
+
+ public static ExpectedExceptionFactoryImpl init()
+ {
+ if (isInited) return (ExpectedExceptionFactoryImpl)FactoryBase.getStaticFactory(ExpectedExceptionFactoryImpl.NAMESPACE_URI);
+ ExpectedExceptionFactoryImpl theExpectedExceptionFactoryImpl = new ExpectedExceptionFactoryImpl();
+ isInited = true;
+
+ // Initialize dependencies
+ SDOUtil.registerStaticTypes(SDOFactory.class);
+ SDOUtil.registerStaticTypes(ModelFactory.class);
+ SDOUtil.registerStaticTypes(InternalFactory.class);
+
+ // Create package meta-data objects
+ theExpectedExceptionFactoryImpl.createMetaData();
+
+ // Initialize created meta-data
+ theExpectedExceptionFactoryImpl.initializeMetaData();
+
+ // Mark meta-data to indicate it can't be changed
+ //theExpectedExceptionFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ????
+
+ return theExpectedExceptionFactoryImpl;
+ }
+
+ private boolean isCreated = false;
+
+ public void createMetaData()
+ {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create types and their properties
+ expectedExceptionTypeType = createType(false, EXPECTED_EXCEPTION_TYPE);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_STRING_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_BOOLEAN_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_BYTE_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_DECIMAL_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_INT_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_FLOAT_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_DOUBLE_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_DATE_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_SHORT_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_LONG_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_LIST_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_BYTES_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_INTEGER_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_CHAR_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_VAL);
+ createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_LIST_VAL);
+ sequenceReadOnlyTypeType = createType(false, SEQUENCE_READ_ONLY_TYPE);
+ createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_MIXED);
+ createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_VAL);
+ createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_LIST_VAL);
+ createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_UNIQUE_NAME);
+
+ // Create data types
+ char_Type = createType(true, CHAR );
+ }
+
+ 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(expectedExceptionTypeType, ExpectedExceptionType.class, "ExpectedExceptionType", false);
+ property = getLocalProperty(expectedExceptionTypeType, 0);
+ initializeProperty(property, theModelPackageImpl.getString(), "stringVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 1);
+ initializeProperty(property, theModelPackageImpl.getBoolean(), "booleanVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 2);
+ initializeProperty(property, theModelPackageImpl.getByte(), "byteVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 3);
+ initializeProperty(property, theModelPackageImpl.getDecimal(), "decimalVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 4);
+ initializeProperty(property, theModelPackageImpl.getInt(), "intVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 5);
+ initializeProperty(property, theModelPackageImpl.getFloat(), "floatVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 6);
+ initializeProperty(property, theModelPackageImpl.getDouble(), "doubleVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 7);
+ initializeProperty(property, theModelPackageImpl.getDateTime(), "dateVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 8);
+ initializeProperty(property, theModelPackageImpl.getShort(), "shortVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 9);
+ initializeProperty(property, theModelPackageImpl.getLong(), "longVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 10);
+ initializeProperty(property, theModelPackageImpl.getString(), "listVal", null, 0, -1, ExpectedExceptionType.class, false, false, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 11);
+ initializeProperty(property, theModelPackageImpl.getBytes(), "bytesVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 12);
+ initializeProperty(property, theModelPackageImpl.getInteger(), "integerVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 13);
+ initializeProperty(property, this.getchar(), "charVal", null, 1, 1, ExpectedExceptionType.class, false, true, false);
+
+ property = getLocalProperty(expectedExceptionTypeType, 14);
+ initializeProperty(property, theModelPackageImpl.getString(), "readOnlyVal", null, 1, 1, ExpectedExceptionType.class, true, true, false);
+ setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true");
+
+ property = getLocalProperty(expectedExceptionTypeType, 15);
+ initializeProperty(property, theModelPackageImpl.getString(), "readOnlyListVal", null, 1, 1, ExpectedExceptionType.class, true, true, false);
+ setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true");
+
+ initializeType(sequenceReadOnlyTypeType, SequenceReadOnlyType.class, "SequenceReadOnlyType", false);
+ property = getLocalProperty(sequenceReadOnlyTypeType, 0);
+ initializeProperty(property, getSequence(), "mixed", null, 0, -1, SequenceReadOnlyType.class, false, false, false);
+
+ property = getLocalProperty(sequenceReadOnlyTypeType, 1);
+ initializeProperty(property, theModelPackageImpl.getString(), "readOnlyVal", null, 1, 1, SequenceReadOnlyType.class, true, true, true);
+ setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true");
+
+ property = getLocalProperty(sequenceReadOnlyTypeType, 2);
+ initializeProperty(property, theModelPackageImpl.getString(), "readOnlyListVal", null, 1, 1, SequenceReadOnlyType.class, true, true, true);
+ setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true");
+
+ property = getLocalProperty(sequenceReadOnlyTypeType, 3);
+ initializeProperty(property, theModelPackageImpl.getString(), "uniqueName", null, 1, 1, SequenceReadOnlyType.class, false, true, true);
+
+ // Initialize data types
+ initializeType(char_Type, String.class, "char", true, false);
+
+ createXSDMetaData(theModelPackageImpl);
+ }
+
+ protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl)
+ {
+ super.initXSD();
+
+ Property property = null;
+
+
+ property = createGlobalProperty
+ ("expectedExceptionsElem",
+ this.getExpectedExceptionType(),
+ new String[]
+ {
+ "kind", "element",
+ "name", "expectedExceptionsElem",
+ "namespace", "##targetNamespace"
+ });
+
+ property = createGlobalProperty
+ ("sequencedReadOnlyElem",
+ this.getSequenceReadOnlyType(),
+ new String[]
+ {
+ "kind", "element",
+ "name", "sequencedReadOnlyElem",
+ "namespace", "##targetNamespace"
+ });
+
+ addXSDMapping
+ (expectedExceptionTypeType,
+ new String[]
+ {
+ "name", "ExpectedExceptionType",
+ "kind", "elementOnly"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_STRING_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "stringVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_BOOLEAN_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "booleanVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_BYTE_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "byteVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_DECIMAL_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "decimalVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_INT_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "intVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_FLOAT_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "floatVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_DOUBLE_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "doubleVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_DATE_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "dateVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_SHORT_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "shortVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_LONG_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "longVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_LIST_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "listVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_BYTES_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "bytesVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_INTEGER_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "integerVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_CHAR_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "charVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "readOnlyVal"
+ });
+
+ addXSDMapping
+ (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_LIST_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "readOnlyListVal"
+ });
+
+ addXSDMapping
+ (sequenceReadOnlyTypeType,
+ new String[]
+ {
+ "name", "SequenceReadOnlyType",
+ "kind", "mixed"
+ });
+
+ addXSDMapping
+ (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_MIXED),
+ new String[]
+ {
+ "kind", "elementWildcard",
+ "name", ":mixed"
+ });
+
+ addXSDMapping
+ (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "readOnlyVal"
+ });
+
+ addXSDMapping
+ (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_LIST_VAL),
+ new String[]
+ {
+ "kind", "element",
+ "name", "readOnlyListVal"
+ });
+
+ addXSDMapping
+ (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_UNIQUE_NAME),
+ new String[]
+ {
+ "kind", "element",
+ "name", "uniqueName"
+ });
+
+ addXSDMapping
+ (char_Type,
+ new String[]
+ {
+ "name", "char",
+ "baseType", "commonj.sdo#String",
+ "length", "1"
+ });
+
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String createcharFromString(String initialValue)
+ {
+ return (String)((ModelFactoryImpl)ModelFactory.INSTANCE).createStringFromString(initialValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String convertcharToString(Object instanceValue)
+ {
+ return ((ModelFactoryImpl)ModelFactory.INSTANCE).convertStringToString(instanceValue);
+ }
+
+} //ExpectedExceptionFactoryImpl
diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java
new file mode 100644
index 0000000000..9021e52c18
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java
@@ -0,0 +1,1682 @@
+/**
+ *
+ * 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.ExpectedException.impl;
+
+import com.example.ExpectedException.ExpectedExceptionFactory;
+import com.example.ExpectedException.ExpectedExceptionType;
+
+import commonj.sdo.Type;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sdo.impl.DataObjectBase;
+
+/**
+ *
+ * An implementation of the model object 'Type'.
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface Quote extends Serializable
+{
+ /**
+ * Returns the value of the 'Symbol' attribute.
+ *
+ *
+ * If the meaning of the 'Symbol' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Symbol' attribute.
+ * @see #isSetSymbol()
+ * @see #unsetSymbol()
+ * @see #setSymbol(String)
+ * @generated
+ */
+ String getSymbol();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getSymbol Symbol}' attribute.
+ *
+ *
+ * @param value the new value of the 'Symbol' attribute.
+ * @see #isSetSymbol()
+ * @see #unsetSymbol()
+ * @see #getSymbol()
+ * @generated
+ */
+ void setSymbol(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getSymbol Symbol}' attribute.
+ *
+ *
+ * @see #isSetSymbol()
+ * @see #getSymbol()
+ * @see #setSymbol(String)
+ * @generated
+ */
+ void unsetSymbol();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getSymbol Symbol}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Symbol' attribute is set.
+ * @see #unsetSymbol()
+ * @see #getSymbol()
+ * @see #setSymbol(String)
+ * @generated
+ */
+ boolean isSetSymbol();
+
+ /**
+ * Returns the value of the 'Company Name' attribute.
+ *
+ *
+ * If the meaning of the 'Company Name' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Company Name' attribute.
+ * @see #isSetCompanyName()
+ * @see #unsetCompanyName()
+ * @see #setCompanyName(String)
+ * @generated
+ */
+ String getCompanyName();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getCompanyName Company Name}' attribute.
+ *
+ *
+ * @param value the new value of the 'Company Name' attribute.
+ * @see #isSetCompanyName()
+ * @see #unsetCompanyName()
+ * @see #getCompanyName()
+ * @generated
+ */
+ void setCompanyName(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getCompanyName Company Name}' attribute.
+ *
+ *
+ * @see #isSetCompanyName()
+ * @see #getCompanyName()
+ * @see #setCompanyName(String)
+ * @generated
+ */
+ void unsetCompanyName();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getCompanyName Company Name}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Company Name' attribute is set.
+ * @see #unsetCompanyName()
+ * @see #getCompanyName()
+ * @see #setCompanyName(String)
+ * @generated
+ */
+ boolean isSetCompanyName();
+
+ /**
+ * Returns the value of the 'Price' attribute.
+ *
+ *
+ * If the meaning of the 'Price' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Price' attribute.
+ * @see #isSetPrice()
+ * @see #unsetPrice()
+ * @see #setPrice(BigDecimal)
+ * @generated
+ */
+ BigDecimal getPrice();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getPrice Price}' attribute.
+ *
+ *
+ * @param value the new value of the 'Price' attribute.
+ * @see #isSetPrice()
+ * @see #unsetPrice()
+ * @see #getPrice()
+ * @generated
+ */
+ void setPrice(BigDecimal value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getPrice Price}' attribute.
+ *
+ *
+ * @see #isSetPrice()
+ * @see #getPrice()
+ * @see #setPrice(BigDecimal)
+ * @generated
+ */
+ void unsetPrice();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getPrice Price}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Price' attribute is set.
+ * @see #unsetPrice()
+ * @see #getPrice()
+ * @see #setPrice(BigDecimal)
+ * @generated
+ */
+ boolean isSetPrice();
+
+ /**
+ * Returns the value of the 'Open1' attribute.
+ *
+ *
+ * If the meaning of the 'Open1' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Open1' attribute.
+ * @see #isSetOpen1()
+ * @see #unsetOpen1()
+ * @see #setOpen1(BigDecimal)
+ * @generated
+ */
+ BigDecimal getOpen1();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getOpen1 Open1}' attribute.
+ *
+ *
+ * @param value the new value of the 'Open1' attribute.
+ * @see #isSetOpen1()
+ * @see #unsetOpen1()
+ * @see #getOpen1()
+ * @generated
+ */
+ void setOpen1(BigDecimal value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getOpen1 Open1}' attribute.
+ *
+ *
+ * @see #isSetOpen1()
+ * @see #getOpen1()
+ * @see #setOpen1(BigDecimal)
+ * @generated
+ */
+ void unsetOpen1();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getOpen1 Open1}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Open1' attribute is set.
+ * @see #unsetOpen1()
+ * @see #getOpen1()
+ * @see #setOpen1(BigDecimal)
+ * @generated
+ */
+ boolean isSetOpen1();
+
+ /**
+ * Returns the value of the 'High' attribute.
+ *
+ *
+ * If the meaning of the 'High' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'High' attribute.
+ * @see #isSetHigh()
+ * @see #unsetHigh()
+ * @see #setHigh(BigDecimal)
+ * @generated
+ */
+ BigDecimal getHigh();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getHigh High}' attribute.
+ *
+ *
+ * @param value the new value of the 'High' attribute.
+ * @see #isSetHigh()
+ * @see #unsetHigh()
+ * @see #getHigh()
+ * @generated
+ */
+ void setHigh(BigDecimal value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getHigh High}' attribute.
+ *
+ *
+ * @see #isSetHigh()
+ * @see #getHigh()
+ * @see #setHigh(BigDecimal)
+ * @generated
+ */
+ void unsetHigh();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getHigh High}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'High' attribute is set.
+ * @see #unsetHigh()
+ * @see #getHigh()
+ * @see #setHigh(BigDecimal)
+ * @generated
+ */
+ boolean isSetHigh();
+
+ /**
+ * Returns the value of the 'Low' attribute.
+ *
+ *
+ * If the meaning of the 'Low' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Low' attribute.
+ * @see #isSetLow()
+ * @see #unsetLow()
+ * @see #setLow(BigDecimal)
+ * @generated
+ */
+ BigDecimal getLow();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getLow Low}' attribute.
+ *
+ *
+ * @param value the new value of the 'Low' attribute.
+ * @see #isSetLow()
+ * @see #unsetLow()
+ * @see #getLow()
+ * @generated
+ */
+ void setLow(BigDecimal value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getLow Low}' attribute.
+ *
+ *
+ * @see #isSetLow()
+ * @see #getLow()
+ * @see #setLow(BigDecimal)
+ * @generated
+ */
+ void unsetLow();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getLow Low}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Low' attribute is set.
+ * @see #unsetLow()
+ * @see #getLow()
+ * @see #setLow(BigDecimal)
+ * @generated
+ */
+ boolean isSetLow();
+
+ /**
+ * Returns the value of the 'Volume' attribute.
+ *
+ *
+ * If the meaning of the 'Volume' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Volume' attribute.
+ * @see #isSetVolume()
+ * @see #unsetVolume()
+ * @see #setVolume(double)
+ * @generated
+ */
+ double getVolume();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getVolume Volume}' attribute.
+ *
+ *
+ * @param value the new value of the 'Volume' attribute.
+ * @see #isSetVolume()
+ * @see #unsetVolume()
+ * @see #getVolume()
+ * @generated
+ */
+ void setVolume(double value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getVolume Volume}' attribute.
+ *
+ *
+ * @see #isSetVolume()
+ * @see #getVolume()
+ * @see #setVolume(double)
+ * @generated
+ */
+ void unsetVolume();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getVolume Volume}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Volume' attribute is set.
+ * @see #unsetVolume()
+ * @see #getVolume()
+ * @see #setVolume(double)
+ * @generated
+ */
+ boolean isSetVolume();
+
+ /**
+ * Returns the value of the 'Change1' attribute.
+ *
+ *
+ * If the meaning of the 'Change1' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Change1' attribute.
+ * @see #isSetChange1()
+ * @see #unsetChange1()
+ * @see #setChange1(double)
+ * @generated
+ */
+ double getChange1();
+
+ /**
+ * Sets the value of the '{@link com.example.simple.Quote#getChange1 Change1}' attribute.
+ *
+ *
+ * @param value the new value of the 'Change1' attribute.
+ * @see #isSetChange1()
+ * @see #unsetChange1()
+ * @see #getChange1()
+ * @generated
+ */
+ void setChange1(double value);
+
+ /**
+ * Unsets the value of the '{@link com.example.simple.Quote#getChange1 Change1}' attribute.
+ *
+ *
+ * @see #isSetChange1()
+ * @see #getChange1()
+ * @see #setChange1(double)
+ * @generated
+ */
+ void unsetChange1();
+
+ /**
+ * Returns whether the value of the '{@link com.example.simple.Quote#getChange1 Change1}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Change1' attribute is set.
+ * @see #unsetChange1()
+ * @see #getChange1()
+ * @see #setChange1(double)
+ * @generated
+ */
+ boolean isSetChange1();
+
+ /**
+ * Returns the value of the 'Quotes' containment reference list.
+ * The list contents are of type {@link com.example.simple.Quote}.
+ *
+ *
+ * If the meaning of the 'Quotes' containment reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Quotes' containment reference list.
+ * @generated
+ */
+ List getQuotes();
+
+} // Quote
diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/SimpleFactory.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/SimpleFactory.java
new file mode 100644
index 0000000000..98dc01d69a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/SimpleFactory.java
@@ -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.simple;
+
+import commonj.sdo.helper.HelperContext;
+
+
+/**
+ *
+ * The Factory for the model.
+ * It provides a create method for each non-abstract class of the model.
+ *
+ * @generated
+ */
+public interface SimpleFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ *
+ *
+ * @generated
+ */
+ SimpleFactory INSTANCE = com.example.simple.impl.SimpleFactoryImpl.init();
+
+ /**
+ * Returns a new object of class 'Quote'.
+ *
+ *
+ * @return a new object of class 'Quote'.
+ * @generated
+ */
+ Quote createQuote();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ *
+ *
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //SimpleFactory
diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/QuoteImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/QuoteImpl.java
new file mode 100644
index 0000000000..39af3bbdb2
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/QuoteImpl.java
@@ -0,0 +1,1045 @@
+/**
+ *
+ * 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.simple.impl;
+
+import com.example.simple.Quote;
+import com.example.simple.SimpleFactory;
+
+import commonj.sdo.Type;
+
+import java.math.BigDecimal;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sdo.impl.DataObjectBase;
+
+/**
+ *
+ * An implementation of the model object 'Quote'.
+ *
+ *
+ *
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface ContainmentTest extends Serializable
+{
+ /**
+ * Returns the value of the 'Mixed' attribute list.
+ *
+ *
+ * If the meaning of the 'Mixed' attribute list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Mixed' attribute list.
+ * @generated
+ */
+ Sequence getMixed();
+
+ /**
+ * Returns the value of the 'Name' attribute.
+ *
+ *
+ * If the meaning of the 'Name' attribute isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Name' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #setName(String)
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getName Name}' attribute.
+ *
+ *
+ * @param value the new value of the 'Name' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.test.Containment.ContainmentTest#getName Name}' attribute.
+ *
+ *
+ * @see #isSetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ void unsetName();
+
+ /**
+ * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getName Name}' attribute is set.
+ *
+ *
+ * @return whether the value of the 'Name' attribute is set.
+ * @see #unsetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ boolean isSetName();
+
+ /**
+ * Returns the value of the 'Contain' containment reference.
+ *
+ *
+ * If the meaning of the 'Contain' containment reference isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Contain' containment reference.
+ * @see #isSetContain()
+ * @see #unsetContain()
+ * @see #setContain(ContainmentTest)
+ * @generated
+ */
+ ContainmentTest getContain();
+
+ /**
+ * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getContain Contain}' containment reference.
+ *
+ *
+ * @param value the new value of the 'Contain' 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 Contain}' containment reference.
+ *
+ *
+ * @see #isSetContain()
+ * @see #getContain()
+ * @see #setContain(ContainmentTest)
+ * @generated
+ */
+ void unsetContain();
+
+ /**
+ * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getContain Contain}' containment reference is set.
+ *
+ *
+ * @return whether the value of the 'Contain' containment reference is set.
+ * @see #unsetContain()
+ * @see #getContain()
+ * @see #setContain(ContainmentTest)
+ * @generated
+ */
+ boolean isSetContain();
+
+ /**
+ * Returns the value of the 'Contain Many' containment reference list.
+ * The list contents are of type {@link com.example.test.Containment.ContainmentTest}.
+ *
+ *
+ * If the meaning of the 'Contain Many' containment reference list isn't clear,
+ * there really should be more of a description here...
+ *
+ *
+ * @return the value of the 'Contain Many' containment reference list.
+ * @generated
+ */
+ List getContainMany();
+
+} // ContainmentTest
diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java
new file mode 100644
index 0000000000..9f51d02590
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java
@@ -0,0 +1,270 @@
+/**
+ *
+ * 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.model.internal.InternalFactory;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+/**
+ *
+ * An implementation of the model Factory.
+ * Generator information:
+ * patternVersion=1.2; -prefix Containment
+ *
+ * @generated
+ */
+public class ContainmentFactoryImpl extends FactoryBase implements ContainmentFactory
+{
+
+ /**
+ * The package namespace URI.
+ *
+ *
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "http://www.example.com/ContainmentTest";
+
+ /**
+ * The package namespace name.
+ *
+ *
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "contain";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ *
+ *
+ * @generated
+ */
+ public static final String PATTERN_VERSION = "1.2";
+
+ public static final int CONTAINMENT_TEST = 1;
+
+ /**
+ * Creates an instance of the factory.
+ *
+ *
+ * @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.
+ *
+ *
+ * @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);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public DataObject create(int typeNumber)
+ {
+ switch (typeNumber)
+ {
+ case CONTAINMENT_TEST: return (DataObject)createContainmentTest();
+ default:
+ return super.create(typeNumber);
+ }
+ }
+
+ /**
+ *
+ *
+ * @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 dependencies
+ SDOUtil.registerStaticTypes(SDOFactory.class);
+ SDOUtil.registerStaticTypes(ModelFactory.class);
+ SDOUtil.registerStaticTypes(InternalFactory.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 = getLocalProperty(containmentTestType, 0);
+ initializeProperty(property, getSequence(), "mixed", null, 0, -1, ContainmentTest.class, false, false, false);
+
+ property = getLocalProperty(containmentTestType, 1);
+ initializeProperty(property, theModelPackageImpl.getString(), "Name", null, 1, 1, ContainmentTest.class, false, true, true);
+
+ property = getLocalProperty(containmentTestType, 2);
+ initializeProperty(property, this.getContainmentTest(), "Contain", null, 1, 1, ContainmentTest.class, false, true, true, true , null);
+
+ property = getLocalProperty(containmentTestType, 3);
+ 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
diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java
new file mode 100644
index 0000000000..14d4678d2d
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java
@@ -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;
+
+/**
+ *
+ * An implementation of the model object 'Test'.
+ *
+ *
+ *
+ *
+ * @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 'Mixed' attribute list.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_MIXED = 0;
+
+ /**
+ * The internal feature id for the 'Name' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_NAME = 1;
+
+ /**
+ * The internal feature id for the 'Contain' containment reference.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_CONTAIN = 2;
+
+ /**
+ * The internal feature id for the 'Contain Many' containment reference list.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_CONTAIN_MANY = 3;
+
+ /**
+ * The number of properties for this type.
+ *
+ *
+ * @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() Mixed}' attribute list.
+ *
+ *
+ * @see #getMixed()
+ * @generated
+ * @ordered
+ */
+
+ protected Sequence mixed = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public ContainmentTestImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Type getStaticType()
+ {
+ return ((ContainmentFactoryImpl)ContainmentFactory.INSTANCE).getContainmentTest();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Sequence getMixed()
+ {
+ if (mixed == null)
+ {
+ mixed = createSequence(INTERNAL_MIXED);
+ }
+ return mixed;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getName()
+ {
+ return (String)get(getMixed(), getType(), INTERNAL_NAME);
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setName(String newName)
+ {
+ set(getMixed(), getType(), INTERNAL_NAME, newName);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void unsetName()
+ {
+ unset(getMixed(), getType(), INTERNAL_NAME);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public boolean isSetName()
+ {
+ return isSet(getMixed(), getType(), INTERNAL_NAME);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public ContainmentTest getContain()
+ {
+ return (ContainmentTest)get(getMixed(), getType(), INTERNAL_CONTAIN);
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public ChangeContext basicSetContain(ContainmentTest newContain, ChangeContext changeContext)
+ {
+ return basicAdd(getMixed(), getType(), INTERNAL_CONTAIN, newContain, changeContext);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setContain(ContainmentTest newContain)
+ {
+ set(getMixed(), getType(), INTERNAL_CONTAIN, newContain);
+ }
+
+ /**
+ *
+ *
+ * @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();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void unsetContain()
+ {
+ unset(getMixed(), getType(), INTERNAL_CONTAIN);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public boolean isSetContain()
+ {
+ return isSet(getMixed(), getType(), INTERNAL_CONTAIN);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public List getContainMany()
+ {
+ return getList(getMixed(), getType(), INTERNAL_CONTAIN_MANY);
+ }
+ /**
+ *
+ *
+ * @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);
+ }
+
+ /**
+ *
+ *
+ * @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);
+ }
+
+ /**
+ *
+ *
+ * @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);
+ }
+
+ /**
+ *
+ *
+ * @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);
+ }
+
+ /**
+ *
+ *
+ * @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);
+ }
+
+ /**
+ *
+ *
+ * @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
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java
new file mode 100644
index 0000000000..7d91456137
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * 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;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+
+ TestSuite suite = new TestSuite();
+
+ suite.addTest(org.apache.tuscany.sdo.codegen.AllTests.suite());
+ suite.addTest(org.apache.tuscany.sdo.test.AllTests.suite());
+
+ return suite;
+ }
+
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+}
+
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java
new file mode 100644
index 0000000000..d67b53fb7c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * 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.codegen;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+
+ public static TestSuite suite() {
+
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(BytecodeInterfaceGeneratorTestCase.class);
+ suite.addTestSuite(JavaInterfaceGeneratorTestCase.class);
+
+
+ return suite;
+ }
+
+
+ /**
+ * Runs the test suite using the textual runner.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+}
+
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java
new file mode 100644
index 0000000000..4a51310cd0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * 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.codegen;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Bar1 {
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java
new file mode 100644
index 0000000000..e9151b9d46
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * 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.codegen;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Bar2 {
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java
new file mode 100644
index 0000000000..218a725226
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java
@@ -0,0 +1,167 @@
+/**
+ *
+ * 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.codegen;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BytecodeInterfaceGeneratorTestCase extends TestCase {
+ private MockType foo;
+ private BytecodeInterfaceGenerator gen;
+ private TestClassLoader cl;
+
+ public void testHeaderNoBaseClass() {
+ gen.visitType(foo);
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals("Foo", c.getName());
+ assertTrue(c.isInterface());
+ assertEquals(0, c.getInterfaces().length);
+ assertEquals(0, c.getMethods().length);
+ }
+
+ public void testHeaderWithPackage() {
+ gen.visitType(new MockType("org.apache.Foo", null));
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals("org.apache.Foo", c.getName());
+ assertEquals(0, c.getInterfaces().length);
+ assertEquals(0, c.getMethods().length);
+ }
+
+ public void testHeaderOneBaseClass() throws NoJavaImplementationException {
+ foo.addBaseType(new MockType("bar1", Bar1.class));
+ gen.visitType(foo);
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals("Foo", c.getName());
+ assertEquals(1, c.getInterfaces().length);
+ assertEquals(Bar1.class, c.getInterfaces()[0]);
+ assertEquals(0, c.getMethods().length);
+ }
+
+ public void testHeaderMultipleBaseClass() throws NoJavaImplementationException {
+ foo.addBaseType(new MockType("bar1", Bar1.class));
+ foo.addBaseType(new MockType("bar2", Bar2.class));
+ gen.visitType(foo);
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals("Foo", c.getName());
+ assertEquals(2, c.getInterfaces().length);
+ assertEquals(Bar1.class, c.getInterfaces()[0]);
+ assertEquals(Bar2.class, c.getInterfaces()[1]);
+ assertEquals(0, c.getMethods().length);
+ }
+
+ public void testBooleanProperty() throws NoJavaImplementationException, NoSuchMethodException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false));
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals(2, c.getMethods().length);
+ Method getter = c.getMethod("isTrue", new Class[0]);
+ assertEquals(boolean.class, getter.getReturnType());
+ Method setter = c.getMethod("setTrue", new Class[] {boolean.class});
+ assertEquals(void.class, setter.getReturnType());
+ }
+
+ public void testByteArrayProperty() throws NoJavaImplementationException, NoSuchMethodException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("bytes", byte[].class, false, false));
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals(2, c.getMethods().length);
+ Method getter = c.getMethod("getBytes", new Class[0]);
+ assertEquals(byte[].class, getter.getReturnType());
+ Method setter = c.getMethod("setBytes", new Class[] {byte[].class});
+ assertEquals(void.class, setter.getReturnType());
+ }
+
+ public void testObjectProperty() throws NoJavaImplementationException, NoSuchMethodException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("bar", Bar1.class, false, false));
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals(2, c.getMethods().length);
+ Method getter = c.getMethod("getBar", new Class[0]);
+ assertEquals(Bar1.class, getter.getReturnType());
+ Method setter = c.getMethod("setBar", new Class[] {Bar1.class});
+ assertEquals(void.class, setter.getReturnType());
+ }
+
+ public void testReadOnlyProperty() throws NoJavaImplementationException, NoSuchMethodException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("int", Integer.TYPE, false, true));
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals(1, c.getMethods().length);
+ Method getter = c.getMethod("getInt", new Class[0]);
+ assertEquals(int.class, getter.getReturnType());
+ }
+
+ public void testManyProperty() throws NoJavaImplementationException, NoSuchMethodException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("list", Integer.TYPE, true, false));
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals(1, c.getMethods().length);
+ Method getter = c.getMethod("getList", new Class[0]);
+ assertEquals(List.class, getter.getReturnType());
+ }
+
+ public void testTwoProperties() throws NoJavaImplementationException, NoSuchMethodException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false));
+ gen.visitProperty(new MockProperty("int", Integer.TYPE, false, false));
+ gen.visitEnd();
+ Class c = cl.addClass(gen.getClassData());
+ assertEquals(4, c.getMethods().length);
+ Method getter = c.getMethod("isTrue", new Class[0]);
+ assertEquals(boolean.class, getter.getReturnType());
+ Method setter = c.getMethod("setTrue", new Class[] {boolean.class});
+ assertEquals(void.class, setter.getReturnType());
+ getter = c.getMethod("getInt", new Class[0]);
+ assertEquals(int.class, getter.getReturnType());
+ setter = c.getMethod("setInt", new Class[] {int.class});
+ assertEquals(void.class, setter.getReturnType());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ foo = new MockType("foo", null);
+ gen = new BytecodeInterfaceGenerator();
+ cl = new TestClassLoader();
+ }
+
+ private class TestClassLoader extends ClassLoader {
+ public TestClassLoader() {
+ super(TestClassLoader.class.getClassLoader());
+ }
+
+ Class addClass(byte[] bytes) {
+ return defineClass(null, bytes, 0, bytes.length);
+ }
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java
new file mode 100644
index 0000000000..56bf6af9b4
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * 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.codegen;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Foo {
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java
new file mode 100644
index 0000000000..6cc0529c5f
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java
@@ -0,0 +1,129 @@
+/**
+ *
+ * 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.codegen;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceGeneratorTestCase extends TestCase {
+ private static final String SEP = System.getProperty("line.separator");
+
+ private JavaInterfaceGenerator gen;
+ private StringWriter writer;
+ private MockType foo;
+
+ public void testHeaderNoBaseClass() {
+ gen.visitType(foo);
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo {\n}\n"), writer.toString());
+ }
+
+ public void testHeaderWithPackage() {
+ gen.visitType(new MockType("org.apache.Foo", null));
+ gen.visitEnd();
+ assertEquals(localize("package org.apache;\n\npublic interface Foo {\n}\n"), writer.toString());
+ }
+
+ public void testHeaderOneBaseClass() throws NoJavaImplementationException {
+ foo.addBaseType(new MockType("bar1", Bar1.class));
+ gen.visitType(foo);
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo extends org.apache.tuscany.sdo.codegen.Bar1 {\n}\n"), writer.toString());
+ }
+
+ public void testHeaderMultipleBaseClass() throws NoJavaImplementationException {
+ foo.addBaseType(new MockType("bar1", Bar1.class));
+ foo.addBaseType(new MockType("bar2", Bar2.class));
+ gen.visitType(foo);
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo extends org.apache.tuscany.sdo.codegen.Bar1, org.apache.tuscany.sdo.codegen.Bar2 {\n}\n"), writer.toString());
+ }
+
+ public void testBooleanProperty() throws NoJavaImplementationException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false));
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo {\n\tboolean isTrue();\n\tvoid setTrue(boolean value);\n}\n"), writer.toString());
+ }
+
+ public void testByteArrayProperty() throws NoJavaImplementationException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("bytes", byte[].class, false, false));
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo {\n\tbyte[] getBytes();\n\tvoid setBytes(byte[] value);\n}\n"), writer.toString());
+ }
+
+ public void testObjectProperty() throws NoJavaImplementationException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("bar", Bar1.class, false, false));
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo {\n\torg.apache.tuscany.sdo.codegen.Bar1 getBar();\n\tvoid setBar(org.apache.tuscany.sdo.codegen.Bar1 value);\n}\n"), writer.toString());
+ }
+
+ public void testReadOnlyProperty() throws NoJavaImplementationException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("int", Integer.TYPE, false, true));
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo {\n\tint getInt();\n}\n"), writer.toString());
+ }
+
+ public void testManyProperty() throws NoJavaImplementationException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("list", Integer.TYPE, true, false));
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo {\n\tjava.util.List getList();\n}\n"), writer.toString());
+ }
+
+ public void testTwoProperties() throws NoJavaImplementationException {
+ gen.visitType(foo);
+ gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false));
+ gen.visitProperty(new MockProperty("int", Integer.TYPE, false, false));
+ gen.visitEnd();
+ assertEquals(localize("public interface Foo {\n\tboolean isTrue();\n\tvoid setTrue(boolean value);\n\tint getInt();\n\tvoid setInt(int value);\n}\n"), writer.toString());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ writer = new StringWriter();
+ gen = new JavaInterfaceGenerator(new PrintWriter(writer));
+ foo = new MockType("foo", null);
+ }
+
+ private String localize(String s) {
+ StringBuffer b = new StringBuffer(s.length() + s.length()/10);
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+ if (ch == '\t') {
+ b.append(" ");
+ } else if (ch == '\n') {
+ b.append(SEP);
+ } else {
+ b.append(ch);
+ }
+ }
+ return b.toString();
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java
new file mode 100644
index 0000000000..3e3e87e47b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java
@@ -0,0 +1,94 @@
+/**
+ *
+ * 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.codegen;
+
+import java.util.List;
+
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+/**
+ * @version $Rev$ $Date$
+ */
+class MockProperty implements Property {
+ private final String name;
+ private final Type type;
+ private final boolean many;
+ private final boolean readOnly;
+
+ public MockProperty(String name, Class type, boolean many, boolean readOnly) {
+ this.name = name;
+ this.type = new MockType(null, type);
+ this.many = many;
+ this.readOnly = readOnly;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public boolean isContainment() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Type getContainingType() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getDefault() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public Property getOpposite() {
+ throw new UnsupportedOperationException();
+ }
+
+ public List /*String*/ getAliasNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isNullable() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isOpenContent() {
+ throw new UnsupportedOperationException();
+ }
+
+ public List getInstanceProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object get(Property property) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java
new file mode 100644
index 0000000000..ec848de4fa
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java
@@ -0,0 +1,104 @@
+/**
+ *
+ * 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.codegen;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import commonj.sdo.Type;
+import commonj.sdo.Property;
+
+/**
+ * @version $Rev$ $Date$
+ */
+class MockType implements Type {
+ private final String name;
+ private final Class javaClass;
+ private final List baseTypes = new ArrayList();
+
+ public MockType(String name, Class javaClass) {
+ this.javaClass = javaClass;
+ this.name = name;
+ }
+
+ public void addBaseType(Type baseType) {
+ baseTypes.add(baseType);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class getInstanceClass() {
+ return javaClass;
+ }
+
+ public boolean isInstance(Object object) {
+ throw new UnsupportedOperationException();
+ }
+
+ public List /*Property*/ getProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Property getProperty(String propertyName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDataType() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isOpen() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSequenced() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAbstract() {
+ throw new UnsupportedOperationException();
+ }
+
+ public List /*Type*/ getBaseTypes() {
+ return baseTypes;
+ }
+
+ public List /*Property*/ getDeclaredProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ public List /*String*/ getAliasNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ public List getInstanceProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object get(Property property) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
new file mode 100644
index 0000000000..79fed495de
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java
@@ -0,0 +1,84 @@
+
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sdo.test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class AllTests extends TestCase {
+
+
+ public static TestSuite suite() {
+
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(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);
+ suite.addTestSuite(DateConversionTestCase.class);
+ suite.addTestSuite(DefineOpenContentPropertyTestCase.class);
+ suite.addTestSuite(DefineTypeTestCase.class);
+ suite.addTestSuite(FormTestCase.class);
+ suite.addTestSuite(HelperContextTestCase.class);
+ suite.addTestSuite(IsManyTestCase.class);
+ suite.addTestSuite(JavaSerializeDeserializeTestCase.class);
+ suite.addTestSuite(MixedTypeTestCase.class);
+ suite.addTestSuite(NeverStaleChangeSummaryTestCase.class);
+ suite.addTestSuite(OpenTypeTestCase.class);
+ suite.addTestSuite(SchemaLocationTestCase.class);
+ suite.addTestSuite(SerializeTypesTestCase.class);
+ suite.addTestSuite(SimpleCopyTestCase.class);
+ suite.addTestSuite(SimpleDynamicTestCase.class);
+ suite.addTestSuite(SimpleEqualityTestCase.class);
+ suite.addTestSuite(SubstitutionValuesTestCase.class);
+ suite.addTestSuite(TypeConversionTestCase.class);
+ suite.addTestSuite(TypeRoundTripTestCase.class);
+ suite.addTestSuite(XMLDocumentTestCase.class);
+ suite.addTestSuite(XMLHelperTestCase.class);
+ suite.addTestSuite(XMLStreamHelperTestCase.class);
+ suite.addTestSuite(XPathTestCase.class);
+ suite.addTestSuite(XSDHelperTestCase.class);
+ suite.addTestSuite(XSDQNameTestCase.class);
+ suite.addTestSuite(XMLLoadOptionsTestCase.class);
+ suite.addTestSuite(XMLSaveOptionsTestCase.class);
+ suite.addTestSuite(XMLUnknownPropertiesTestCase.class);
+ suite.addTestSuite(ExpectedExceptionsTestCase.class);
+ suite.addTestSuite(TypeHelperTestCase.class);
+ return suite;
+ }
+
+
+
+ /**
+ * Runs the test suite using the textual runner.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+}
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java
new file mode 100644
index 0000000000..4d085eae28
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java
@@ -0,0 +1,112 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XSDHelper;
+
+public class AnyTypeTest extends TestCase {
+ private static TypeHelper typeHelper;
+ private static DataFactory dataFactory;
+ private static XMLStreamHelper streamHelper;
+ private static XSDHelper xsdHelper;
+
+ private static final String TEST_MODEL = "/anytype.xsd";
+ private static final String TEST_NAMESPACE = "http://www.example.com/anytype";
+
+ public void testAnySimpleType() throws Exception {
+ final Property property = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "globalElement");
+ final Type propertyType = property.getType();
+
+ DataObject dataObject = dataFactory.create(TEST_NAMESPACE, "Person");
+ dataObject.set("firstName", "Fuhwei");
+
+ DataObject rootObject = dataFactory.create(propertyType);
+ rootObject.set("anyTypeElement", dataObject);
+
+ dataObject = dataFactory.create(TEST_NAMESPACE, "Person");
+ dataObject.set("firstName", "Mindy");
+ rootObject.set("personElement", dataObject);
+
+ // XMLStreamHelper.saveObject has a problem to serialize the any type
+ final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ final StringWriter writer = new StringWriter();
+ final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
+ streamHelper.saveObject(rootObject, streamWriter);
+ streamWriter.flush();
+ // System.out.println(writer.toString());
+
+ final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ final StringReader reader = new StringReader(writer.toString());
+ final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(reader);
+ final XMLDocument doc = streamHelper.load(streamReader);
+ rootObject = doc.getRootObject();
+ DataObject testObject = rootObject.getDataObject("anyTypeElement");
+ // System.out.println("anyTypeElement dataobject: " + testObject);
+ testObject = rootObject.getDataObject("personElement");
+ // System.out.println("personElement dataobject: " + testObject);
+ }
+
+ public void testAbstractTypeFails() {
+ try {
+ final DataObject abstractObj = dataFactory.create("commonj.sdo","DataObject");
+ assertTrue("Should not succeed", false);
+ }
+ catch ( final IllegalArgumentException e) {
+ // expected result
+ }
+ }
+
+ protected void setUp() throws Exception {
+ final HelperContext hc = SDOUtil.createHelperContext();
+ typeHelper = hc.getTypeHelper();
+ dataFactory = hc.getDataFactory();
+ xsdHelper = hc.getXSDHelper();
+ streamHelper = SDOUtil.createXMLStreamHelper(hc);
+
+ // Populate the meta data for the test (Stock Quote) model
+ final URL url = getClass().getResource(TEST_MODEL);
+ final InputStream inputStream = url.openStream();
+ xsdHelper.define(inputStream, url.toString());
+ inputStream.close();
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java
new file mode 100644
index 0000000000..b9b9c0f2ea
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java
@@ -0,0 +1,216 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+
+public class ChangeSummaryOnDataObjectTestCase extends TestCase {
+
+
+ private final String TEST_DATA = "/simplechangesummary.xml";
+ HelperContext hc;
+ XSDHelper xh;
+ TypeHelper th;
+
+ public void testBasicsDO() {
+ Type cst = th.getType("commonj.sdo","ChangeSummaryType");
+ Type strt = th.getType("commonj.sdo", "String");
+
+ Type newt = SDOUtil.createType(hc, "testcases.changesummary", "simpleCS", false);
+ Property strProp = SDOUtil.createProperty(newt, "strElem", strt);
+ SDOUtil.createProperty(newt, "changeSummary", cst);
+
+ DataObject iNewt = hc.getDataFactory().create(newt);
+
+ testBasicsBody(strProp, iNewt);
+}
+
+ public void testBasicsDG() {
+
+ Type strt = th.getType("commonj.sdo", "String");
+
+
+ Type newt = SDOUtil.createType(hc, "testcases.changesummary", "simpleNOCS", false);
+ Property strProp = SDOUtil.createProperty(newt, "strElem", strt);
+
+ DataGraph graph = SDOUtil.createDataGraph();
+ DataObject iNewt = graph.createRootObject(newt);
+
+ testBasicsBody(strProp, iNewt);
+}
+
+
+ /**
+ * @param strProp
+ * @param iNewt
+ */
+ private void testBasicsBody(Property strProp, DataObject iNewt) {
+ ChangeSummary cs = iNewt.getChangeSummary();
+ cs.beginLogging();
+
+ List co = cs.getChangedDataObjects();
+ assertEquals(0, co.size());
+ iNewt.set(strProp, "some text");
+ assertEquals(0, co.size());
+ co = cs.getChangedDataObjects();
+ assertEquals(1, co.size());
+
+ List oldValues = cs.getOldValues((DataObject)co.get(0));
+
+ ChangeSummary.Setting ov1 = (ChangeSummary.Setting)oldValues.get(0);
+ Property p = ov1.getProperty();
+ assertEquals("strElem", p.getName());
+ Object v = ov1.getValue();
+ assertEquals(null, v);
+
+ assertTrue(cs.isLogging());
+ cs.endLogging();
+ assertFalse(cs.isLogging());
+
+ }
+
+
+
+ public void testDynamicNestedDataObjectsDG() throws Exception {
+ DataGraph dataGraph = SDOUtil.createDataGraph();
+ DataObject quote = dataGraph.createRootObject(th.getType("http://www.example.com/simple", "Quote"));
+
+ testDynamicNestedDOBody(quote);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.saveDataGraph(dataGraph, baos, null);
+ // SDOUtil.saveDataGraph(dataGraph, System.out, null);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
+
+
+ assertEquals(1, quote.getList("quotes").size());
+ assertEquals("fbnt", quote.getString("symbol"));
+ dataGraph.getChangeSummary().undoChanges();
+ // SDOUtil.saveDataGraph(dataGraph, System.out, null);
+ assertEquals(0, quote.getList("quotes").size());
+ assertNull(quote.getString("symbol"));
+
+
+ }
+
+ public void testDynamicNestedDataObjectsDO() throws Exception {
+ Type quoteType = th.getType("http://www.example.com/simpleCS", "RootQuote");
+ DataObject quote = hc.getDataFactory().create(quoteType);
+
+ testDynamicNestedDOBody(quote);
+ //hc.getXMLHelper().save(quote, "http://www.example.com/simpleCS", "stockQuote", System.out);
+ assertEquals(1, quote.getList("quotes").size());
+ assertEquals("fbnt", quote.getString("symbol"));
+
+ quote.getChangeSummary().undoChanges();
+
+ assertEquals(0, quote.getList("quotes").size());
+ assertNull(quote.getString("symbol"));
+
+
+
+ }
+
+ /**
+ * @param quote
+ */
+ private void testDynamicNestedDOBody(DataObject quote) {
+ // Begin logging changes
+ //
+ ChangeSummary changeSummary = quote.getChangeSummary();
+ assertNotNull(changeSummary);
+ assertFalse(changeSummary.isLogging());
+ changeSummary.beginLogging();
+
+
+ // Modify the data graph in various fun and interesting ways
+ //
+ quote.setString("symbol", "fbnt");
+ quote.setString("companyName", "FlyByNightTechnology");
+ quote.setBigDecimal("price", new BigDecimal("1000.0"));
+ quote.setBigDecimal("open1", new BigDecimal("1000.0"));
+ quote.setBigDecimal("high", new BigDecimal("1000.0"));
+ quote.setBigDecimal("low", new BigDecimal("1000.0"));
+ quote.setDouble("volume", 1000);
+ quote.setDouble("change1", 1000);
+
+ DataObject child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+ changeSummary.endLogging();
+ assertEquals(2, changeSummary.getChangedDataObjects().size()); // 2 DataObjects
+ assertTrue(changeSummary.getChangedDataObjects().contains(quote));
+ assertTrue(changeSummary.getChangedDataObjects().contains(child));
+ assertFalse(changeSummary.isCreated(quote));
+ assertTrue(changeSummary.isCreated(child));
+
+ ChangeSummary.Setting ov = changeSummary.getOldValue(quote, quote.getType().getProperty("symbol"));
+ assertNull(ov.getValue());
+
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+// uncomment these lines for sending aspect trace to a file
+// tracing.lib.TraceMyClasses tmc = (TraceMyClasses)Aspects.aspectOf(TraceMyClasses.class);
+// tmc.initStream(new PrintStream("c:\\temp\\trace.log"));
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource("/simple.xsd");
+ InputStream inputStream = url.openStream();
+ hc = SDOUtil.createHelperContext();
+ th = hc.getTypeHelper();
+ xh = hc.getXSDHelper();
+ xh.define(inputStream, url.toString());
+ inputStream.close();
+
+ URL url2 = getClass().getResource("/simpleWithChangeSummary.xsd");
+ InputStream inputStream2 = url2.openStream();
+ xh.define(inputStream2, url2.toString());
+ inputStream.close();
+
+
+
+}
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java
new file mode 100644
index 0000000000..4a62ec6135
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java
@@ -0,0 +1,219 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class ChangeSummaryPropertyTestCase extends TestCase {
+ private final String TEST_MODEL = "/simpleWithChangeSummary.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/simpleCS";
+
+ private final String TEST_DATA_BEFORE_UNDO = "/simpleWithChangeSummary.xml";
+ private final String TEST_DATA_AFTER_UNDO = "/simpleWithChangeSummaryUndone.xml";
+
+ HelperContext hc;
+ DataFactory dataFactory;
+ XMLHelper xmlHelper;
+
+ void verify(ChangeSummary cs, DataObject quote, String nameSpace, String element, String beforeUndo, String afterUndo) throws IOException {
+ // Stop logging changes and serialize the resulting data graph
+ //
+ cs.endLogging();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ xmlHelper.save(quote, nameSpace, element, baos);
+ //xmlHelper.save(quote, nameSpace, element, System.out);
+
+ byte[] bytes = baos.toByteArray();
+ URL url = getClass().getResource(beforeUndo);
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(bytes), url));
+
+ DataObject loaded = xmlHelper.load(new ByteArrayInputStream(bytes)).getRootObject();
+ baos.reset();
+ xmlHelper.save(loaded, nameSpace, element, baos);
+ //xmlHelper.save(loaded, nameSpace, element, System.out);
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), url));
+
+ // Undo all changes and then serialize the resulting data graph again
+ //
+ cs.undoChanges();
+
+ baos.reset();
+ xmlHelper.save(quote, nameSpace, element, baos);
+ //xmlHelper.save(quote, nameSpace, element, System.out);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(afterUndo)));
+ }
+
+ /**
+ * ChangeSummary property test.
+ */
+ protected final void change(String nameSpace, String beforeUndo, String afterUndo) throws Exception {
+ Type quoteType = hc.getTypeHelper().getType(nameSpace, "RootQuote");
+ DataObject quote = dataFactory.create(quoteType);
+
+ ChangeSummary cs = quote.getChangeSummary();
+ ChangeSummary csp = (ChangeSummary)quote.get("changes");
+
+ assertSame(cs, csp);
+
+ quote.setString("symbol", "fbnt");
+ quote.setString("companyName", "FlyByNightTechnology");
+ quote.setBigDecimal("price", new BigDecimal("1000.0"));
+ DataObject child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("1500.0"));
+ child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.0"));
+ child = child.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.99"));
+ child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2500.0"));
+
+ // Begin logging changes
+ //
+ cs.beginLogging();
+
+ // Modify the data graph in various ways
+ //
+ quote.setString("symbol", "FBNT");
+ quote.setBigDecimal("price", new BigDecimal("999.0"));
+ quote.setDouble("volume", 1000);
+
+ child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("3000.0"));
+ child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("4000.0"));
+
+ quote.getDataObject("quotes[2]").delete();
+
+ verify(cs, quote, nameSpace, "stockQuote", beforeUndo, afterUndo);
+ }
+
+ /**
+ * Simple ChangeSummary property test.
+ */
+ public void testChangeSummary() throws Exception {
+ change(TEST_NAMESPACE, TEST_DATA_BEFORE_UNDO, TEST_DATA_AFTER_UNDO);
+ }
+
+ static final String SequenceTest_NameSpace = "http://www.example.com/sequenceCS";
+
+ /**
+ * Mixed ChangeSummary property test.
+ */
+ public void testMixedChangeSummary() throws Exception {
+ change(SequenceTest_NameSpace, "/mixedChangeSummary.xml", "/mixedChangeSummaryUndone.xml");
+ }
+
+ protected final DataObject createDataObject(Type quoteType, Object value, Sequence sequence, Property property) {
+ DataObject child = dataFactory.create(quoteType);
+ child.set("symbol", value);
+ sequence.add(property, child);
+ return child;
+ }
+
+ static final String SequenceTest_ELEMENT = "openQuote";
+
+ private XSDHelper xsdHelper;
+
+ /**
+ * Open/any ChangeSummary property test.
+ */
+ public void testOpenChangeSummary() throws Exception {
+ DataObject quote = dataFactory.create(xsdHelper.getGlobalProperty(SequenceTest_NameSpace, SequenceTest_ELEMENT, true).getType());
+
+ ChangeSummary cs = quote.getChangeSummary();
+ ChangeSummary csp = (ChangeSummary)quote.get("changes");
+
+ assertSame(cs, csp);
+
+ quote.set("symbol", "fbnt");
+ Property property = xsdHelper.getGlobalProperty("http://www.example.com/open", "openStockQuote", true);
+ Type quoteType = property.getType();
+ List openStockQuotes = ((DataObject)quote).getList(property);
+
+ addQuote(openStockQuotes, quoteType, "1500.0");
+ DataObject osq2 = addQuote(openStockQuotes, quoteType, "2000.0");
+ addQuote(osq2.getList(property), quoteType, "2000.99");
+ addQuote(openStockQuotes, quoteType, "2500.0");
+
+ // Begin logging changes
+ //
+ cs.beginLogging();
+
+ // Modify the data graph in various ways
+ //
+ quote.set("symbol", "FBNT");
+
+ addQuote(openStockQuotes, quoteType, "3000.0");
+ addQuote(openStockQuotes, quoteType, "4000.0");
+
+ openStockQuotes.remove(osq2);
+
+
+ verify(cs, quote, SequenceTest_NameSpace, SequenceTest_ELEMENT, "/openChangeSummary.xml", "/openChangeSummaryUndone.xml");
+ }
+
+ private DataObject addQuote(List openStockQuotes, Type quoteType,
+ Object value) {
+ DataObject osq = dataFactory.create(quoteType);
+ osq.set("symbol", value);
+ openStockQuotes.add(osq);
+ return osq;
+ }
+
+ void define(String model) throws Exception {
+ // Populate the meta data for the test model
+ URL url = getClass().getResource(model);
+ xsdHelper.define(url.openStream(), url.toString());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+ xsdHelper = hc.getXSDHelper();
+ dataFactory = hc.getDataFactory();
+ xmlHelper = hc.getXMLHelper();
+
+ // Populate the meta data for the test (Stock Quote) model
+ define(TEST_MODEL);
+
+ define("/SequenceChangeSummary.xsd");
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java
new file mode 100644
index 0000000000..e956720117
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.XSDHelper;
+
+
+public class ChangeSummaryTestCase extends TestCase {
+ private final String TEST_MODEL = "/simple.xsd";
+ private final String TEST_DATA = "/simplechangesummary.xml";
+
+ /**
+ * Simple ChangeSummary test.
+ */
+ public void testChangeSummary() throws IOException {
+ // Create an empty data graph and add a root object, an instance of type Quote
+ //
+
+ DataGraph dataGraph = SDOUtil.createDataGraph();
+ DataObject quote = dataGraph.createRootObject("http://www.example.com/simple", "Quote");
+
+ // Begin logging changes
+ //
+ ChangeSummary changeSummary = dataGraph.getChangeSummary();
+ changeSummary.beginLogging();
+
+ // Modify the data graph in various fun and interesting ways
+ //
+ quote.setString("symbol", "fbnt");
+ quote.setString("companyName", "FlyByNightTechnology");
+ quote.setBigDecimal("price", new BigDecimal("1000.0"));
+ quote.setBigDecimal("open1", new BigDecimal("1000.0"));
+ quote.setBigDecimal("high", new BigDecimal("1000.0"));
+ quote.setBigDecimal("low", new BigDecimal("1000.0"));
+ quote.setDouble("volume", 1000);
+ quote.setDouble("change1", 1000);
+
+ DataObject child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+ // Stop logging changes and print the resulting data graph to stdout
+ //
+ changeSummary.endLogging();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.saveDataGraph(dataGraph, baos, null);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java
new file mode 100644
index 0000000000..843ab9b982
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java
@@ -0,0 +1,866 @@
+/**
+ *
+ * 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.api.XMLStreamHelper;
+import org.apache.tuscany.sdo.api.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() {
+ final 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() {
+ final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final 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() {
+ final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final 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() {
+ final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final 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() {
+ final 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() {
+ final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final 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() {
+ final 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() {
+ final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final 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() {
+ final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final 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() {
+ final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest();
+ final 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);
+
+ final 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);
+
+ final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final 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);
+
+ final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final 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);
+
+ final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final 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);
+
+ final 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);
+
+ final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final 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);
+
+ final 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);
+
+ final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI,
+ CONTAIN_TYPE);
+ final 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);
+
+ final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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);
+
+ final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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() {
+ final 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() {
+ final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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() {
+ final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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() {
+ final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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() {
+ final 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() {
+ final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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() {
+ final 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() {
+ final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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() {
+ final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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() {
+ final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE);
+ final 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(final DataObject dataObj, final HelperContext scope) {
+
+ assertTrue("Containment cycle was not established.",
+ containmentCycleExists(dataObj));
+
+ try {
+ serializeDataObjectXML(dataObj, scope);
+ } catch (final 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 (final 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 (final 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(final DataObject dataObject, final HelperContext scope) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final Type type = dataObject.getType();
+
+ try {
+ scope.getXMLHelper().save(dataObject, type.getURI(), type.getName(), baos);
+ }
+ catch (final 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(final DataObject dataObject, final HelperContext scope) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ final XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ XMLStreamWriter serializer;
+ final XMLStreamHelper xmlStreamHelper = SDOUtil.createXMLStreamHelper(scope);
+ try {
+ serializer = factory.createXMLStreamWriter(baos);
+ xmlStreamHelper.saveObject(dataObject, serializer);
+ serializer.flush();
+ }
+ catch (final 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(final DataObject dataObject) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try {
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
+ out.writeObject(dataObject);
+ out.close();
+ }
+ catch (final 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 (final 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(final DataObject dataObj1) {
+ dataObj1.setDataObject("Contain", dataObj1);
+ }
+
+ /**
+ * Use setDataObject to create an N-member containment cycle.
+ * @param dataObj1
+ * @param dataObj2
+ * @param dataobj3
+ */
+ private void setSingleValueNMember(final DataObject dataObj1, final DataObject dataObj2, final 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(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) {
+ final 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(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) {
+ final 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(final DataObject dataObj1) {
+ final 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(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) {
+ dataObj1.setDataObject("Contain", dataObj2);
+ dataObj2.setDataObject("Contain", dataObj3);
+
+ final 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(final DataObject dataObj1) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ final 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(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ final Sequence sequence1 = dataObj1.getSequence();
+ final Sequence sequence2 = dataObj2.getSequence();
+ final 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(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ final 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(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) {
+ assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced());
+
+ final List addList = new ArrayList();
+
+ addList.add(dataObj2);
+ dataObj1.setList("ContainMany", addList);
+
+ addList.clear();
+ addList.add(dataObj3);
+ dataObj2.setList("ContainMany", addList);
+
+ final 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;
+ }
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java
new file mode 100644
index 0000000000..f602555fa6
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java
new file mode 100644
index 0000000000..bba7fb4c1b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java
@@ -0,0 +1,474 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+public class CrossScopeCopyTestCase extends TestCase
+{
+ // Literals
+ private static final String TEST_NAMESPACE = "http://www.example.com/bank";
+ private static final String BANK_MODEL = "/bank.xsd";
+ private static final String BANK_TYPE = "bankType";
+ private static final String BRANCH_TYPE = "branchType";
+ private static final String SERVICE_TYPE = "serviceType";
+ private static final String ACCOUNT_TYPE = "accountType";
+ private static final String CUSTOMER_TYPE = "customerType";
+ private static final String ADDRESS_TYPE = "addressType";
+ private static final String DYNAMIC_TYPE = "dynamicType";
+
+ // SDO model objects
+ private HelperContext hca;
+ private HelperContext hcb;
+ private TypeHelper scopeA;
+ private TypeHelper scopeB;
+
+ // SDO instance objects
+ private DataObject bankSDO;
+ private DataObject branchSDO1;
+ private DataObject branchSDO2;
+ private DataObject serviceSDO1;
+ private DataObject serviceSDO2;
+ private DataObject serviceSDO3;
+ private DataObject customerSDO1;
+ private DataObject customerSDO2;
+ private DataObject customerSDO3;
+ private DataObject customerSDO4;
+
+ private int indent = 0;
+
+ public void testCrossScopeCopy() throws IOException
+ {
+ CopyHelper copyHelperB = SDOUtil.createCrossScopeCopyHelper(hcb);
+
+ // Perform Shallow Copy Test
+ DataObject copiedSDO = copyHelperB.copyShallow(bankSDO);
+ shallowCopyAssertions(bankSDO, copiedSDO);
+
+ // Perform Deep Copy Test
+ copiedSDO = copyHelperB.copy(bankSDO);
+ deepCopyAssertions(bankSDO, copiedSDO);
+
+ // Inter-Reference Copy
+ copiedSDO = copyHelperB.copy(customerSDO1);
+ DataObject prop = (DataObject)copiedSDO.get("HomeBranch");
+ assertTrue(prop==null);
+
+ // Perform invalid namespace test
+ DataObject sdo = hca.getDataFactory().create(TEST_NAMESPACE, DYNAMIC_TYPE );
+ sdo.set("custNum", "099" );
+ sdo.set("firstName", "John");
+ sdo.set("lastName", "Doe");
+ boolean failed = false;
+ try
+ {
+ // In this case, we are copying an object to a scope
+ // where the object's type has not been defined. That
+ // will generate a null pointer exception what we will
+ // catch.
+ copyHelperB.copy(sdo);
+ }
+ catch(java.lang.NullPointerException ex)
+ {
+ failed = true;
+ }
+ assertTrue(failed);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // Create Two Scopes
+ hca = SDOUtil.createHelperContext();
+ hcb = SDOUtil.createHelperContext();
+ scopeA = hca.getTypeHelper();
+ scopeB = hcb.getTypeHelper();
+
+ // Populate scopes with bank model now
+ URL url = getClass().getResource(BANK_MODEL);
+ InputStream inputStream = url.openStream();
+ hca.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ inputStream = url.openStream();
+ hcb.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+
+ // Now Populate scopeA with some dynamic models
+ populateScopeWithDynamicTypes(scopeA);
+
+ // Construct Source Tree
+ constructSourceTree(hca.getDataFactory());
+ }
+
+ private void shallowCopyAssertions(DataObject sdo, DataObject copiedSdo)
+ {
+ assertEquals(sdo.getType().getName(), copiedSdo.getType().getName());
+ assertEquals(sdo.getType().getURI(), copiedSdo.getType().getURI());
+ assertNotSame(sdo.getType(), copiedSdo.getType());
+ assertEquals(sdo.getInstanceProperties().size(), copiedSdo
+ .getInstanceProperties().size());
+
+ for(Iterator it = sdo.getInstanceProperties().iterator(), it2 = copiedSdo
+ .getInstanceProperties().iterator(); it.hasNext();)
+ {
+ Property p1 = (Property) it.next(), p2 = (Property) it2.next();
+ assertEquals(p1.getName(), p2.getName());
+ Object o1 = sdo.get(p1), o2 = copiedSdo.get(p2);
+ if(p1.getType().isDataType())
+ {
+ assertEquals(o1, o2);
+ // TODO is there a way I can distinguish between mutable and
+ // immutable types
+ // so that I can do some "same object" tests
+ }
+ else
+ {
+ assertNotSame(p1, p2);
+ if(p2.isMany())
+ {
+ assertEquals(copiedSdo.getList(p2).size(), 0);
+ }
+ else
+ {
+ assertNull(copiedSdo.get(p2));
+ }
+ }
+ try
+ {
+ sdo.get(p2);
+ assertTrue(false);
+ }
+ catch(Exception e)
+ {
+ // expected route
+ }
+ try
+ {
+ copiedSdo.get(p1);
+ assertTrue(false);
+ }
+ catch(Exception e2)
+ {
+ // expected route
+ }
+ }
+ }
+
+ private void deepCopyAssertions(DataObject sdo, DataObject copiedSdo)
+ {
+ //indent();
+
+ //System.out.println("checking objects of types: "
+ // + sdo.getType().getName() + ", "
+ // + copiedSdo.getType().getName());
+ indent++;
+
+ assertEquals(sdo.getType().getName(), copiedSdo.getType().getName());
+ assertEquals(sdo.getType().getURI(), copiedSdo.getType().getURI());
+ assertNotSame(sdo.getType(), copiedSdo.getType());
+ assertEquals(sdo.getInstanceProperties().size(), copiedSdo
+ .getInstanceProperties().size());
+
+ for(Iterator it = sdo.getInstanceProperties().iterator(), it2 = copiedSdo
+ .getInstanceProperties().iterator(); it.hasNext();)
+ {
+ Property p1 = (Property) it.next(), p2 = (Property) it2.next();
+ assertEquals(p1.getName(), p2.getName());
+ Object o1 = sdo.get(p1), o2 = copiedSdo.get(p2);
+ if(p1.getType().isDataType())
+ {
+ assertEquals(o1, o2);
+ // TODO is there a way I can distinguish between mutable and
+ // immutable types
+ // so that I can do some "same object" tests
+ }
+ else
+ {
+ assertNotSame(p1, p2);
+ if(p2.isMany())
+ {
+ assertEquals(sdo.getList(p1).size(), copiedSdo.getList(p2)
+ .size());
+ for(Iterator it3 = sdo.getList(p1).iterator(), it4 = copiedSdo
+ .getList(p2).iterator(); it3.hasNext();)
+ {
+ deepCopyAssertions((DataObject) it3.next(),
+ (DataObject) it4.next());
+ }
+ }
+ else
+ {
+ deepCopyAssertions(sdo.getDataObject(p1), copiedSdo
+ .getDataObject(p2));
+ }
+ }
+ try
+ {
+ sdo.get(p2);
+ assertTrue(false);
+ }
+ catch(Exception e)
+ {
+ // expected route
+ }
+ try
+ {
+ copiedSdo.get(p1);
+ assertTrue(false);
+ }
+ catch(Exception e2)
+ {
+ // expected route
+ }
+ }
+
+ indent--;
+ }
+
+ /*
+ private void indent()
+ {
+ for(int i=0; i " +
+ " " +
+ "fbnt " +
+ "FlyByNightTechnology " +
+ "1000.0 " +
+ "1000.0 " +
+ "1000.0 " +
+ "1000.0 " +
+ "1000.0 " +
+ "1000.0 " +
+ " " +
+ "2000.0 " +
+ " " +
+ "";
+
+ public void testLoadQuoteXMLDoc() throws IOException
+ {
+ XMLHelper xmlHelper = hc.getXMLHelper();
+/* URL url = getClass().getResource("/quote.xml");
+ InputStream inputStream = url.openStream();*/
+ XMLDocument doc = xmlHelper.load(xmlStr);
+ DataObject root = doc.getRootObject();
+
+ List symbols = root.getList("symbol");
+ DataObject symbol = (DataObject)symbols.get(0);
+
+ String seqValue = (String)symbol.getSequence().getValue(0);
+ assertEquals(seqValue, "fbnt");
+
+ //String symbol = root.getString("symbol");
+ //System.out.println("symbol: " + symbol);
+ }
+
+ public void testAnyTypeContainer() throws Exception
+ {
+ HelperContext hc = SDOUtil.createHelperContext();
+
+ URL url = getClass().getResource("/simple.xsd");
+ InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+
+ XMLHelper xmlHelper = hc.getXMLHelper();
+ url = getClass().getResource("/quoteInSOAP.xml");
+ inputStream = url.openStream();
+ XMLDocument doc = xmlHelper.load(inputStream);
+ DataObject root = doc.getRootObject();
+ DataObject body = (DataObject)root.getList("Body").get(0);
+ DataObject stockQuote = (DataObject)body.getList("stockQuote").get(0);
+
+ //xmlHelper.save(stockQuote, stockQuote.getType().getURI(), "stockQuote", System.out);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = SDOUtil.createObjectOutputStream(bos, hc);
+ oos.writeObject(stockQuote);
+ oos.close();
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ ObjectInputStream ois = SDOUtil.createObjectInputStream(bis, hc);
+ DataObject objectCopy = (DataObject)ois.readObject();
+ ois.close();
+ bis.close();
+
+ assertEquals(objectCopy.getString("symbol"), "fbnt");
+
+ //xmlHelper.save(objectCopy, stockQuote.getType().getURI(), "stockQuote", System.out);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ hc = SDOUtil.createHelperContext();
+ th = hc.getTypeHelper();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java
new file mode 100644
index 0000000000..476f34c328
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+
+public class DotNameTest extends TestCase {
+ private final String TEST_MODEL = "/dotNames.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/dotNames";
+ private HelperContext hc;
+ private TypeHelper th;
+ private DataFactory df;
+
+ /**
+ * Simple Dynamic SDO 2 test.
+ */
+ public void testDynamic() throws IOException {
+ Type quoteType = th.getType(TEST_NAMESPACE, "DotNameType");
+ DataObject quote = df.create(quoteType);
+
+
+ quote.getList("property.2.1").add(TEST_NAMESPACE);
+ assertTrue(quote.isSet("property.2.1"));
+ assertSame(quote.get("property.2.1.0"), TEST_NAMESPACE);
+ quote.getList("foo.bar").add(TEST_NAMESPACE);
+ assertTrue(quote.isSet("foo.bar"));
+ assertSame(quote.get("foo.bar.0"), TEST_NAMESPACE);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ hc = SDOUtil.createHelperContext();
+ th = hc.getTypeHelper();
+ df = hc.getDataFactory();
+
+ InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java
new file mode 100644
index 0000000000..1a9deaf775
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java
@@ -0,0 +1,256 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * Test to compare data objects created with SDO API with one created from XML
+ */
+public class DynamicTypesComparisonTestCase extends TestCase {
+ private final String COMMONJ_SDO = "commonj.sdo";
+
+ private final String DYNAMIC_ROOT_TYPE_0 = "TestType0";
+
+ private final String DYNAMIC_TYPES_SCHEMA_STRING = "\n" + "\n" + " \n"
+ + " \n" + " \n"
+ + " \n"
+ + " \n"
+ + " \n"
+ + " \n" + " \n" + " \n"
+ + " \n" + " \n" + "\n";
+
+ private final String DYNAMIC_TYPES_URI = "http://www.example.com/dynamicTypesFromSchemaSimple";
+
+ private final String SDO_FROM_API_AND_DYN = "object created with API with dynamic type ";
+
+ private final String SDO_FROM_API_AND_REF = "object created with API with type from XSD";
+
+ private final String SDO_FROM_XML_AND_REF = "object created with XML with type from XSD";
+
+ private final String TEST_XML_DOC_0_STRING = "\n"
+ + "\n"
+ + " This is a repeated string.\n" + " This is a repeated string.\n"
+ + " true\n" + " false\n" + " true\n"
+ + " 1\n" + " 0\n" + " 0\n"
+ + " 12.5\n" + " 0\n" + "\n";
+
+ private void comparePropertyObjects(String propName, String name1, String name2, Object propObj1, Object propObj2) {
+ if (propObj1 == null) {
+ if (propObj2 != null) {
+ localFail("property " + propName + " for " + name1 + " was null but " + name2 + " was '" + propObj2
+ + "'");
+ }
+ } else if (propObj2 == null) {
+ localFail("property " + propName + " for " + name2 + " was null but " + name1 + " was '" + propObj1 + "'");
+ } else {
+ if (!propObj1.equals(propObj2)) {
+ localFail("property " + propName + " for " + name1 + " was '" + propObj1 + "' but " + name2 + " was '"
+ + propObj2 + "'");
+ }
+ }
+ }
+
+ private void compareSequencesIgnoringWhitespace(String name1, String name2, Sequence sequence1, Sequence sequence2) {
+ if (sequence1 == null) {
+ if (sequence2 != null) {
+ localFail("sequence for " + name1 + " was null but " + name2 + " was not null");
+ }
+ } else if (sequence2 == null) {
+ localFail("sequence for " + name2 + " was null but " + name1 + " was not null");
+ } else {
+ List trimmedSeq1 = new ArrayList();
+ List trimmedSeq2 = new ArrayList();
+ trimWhitespaceFromSequence(trimmedSeq1, sequence1);
+ trimWhitespaceFromSequence(trimmedSeq2, sequence2);
+ int size1 = trimmedSeq1.size();
+ int size2 = trimmedSeq2.size();
+ if (size1 != size2) {
+ localFail("lengths of trimmed sequences differ: " + name1 + " was " + size1 + ", " + name2 + " was "
+ + size2);
+ } else {
+ Object[] objArr1 = trimmedSeq1.toArray();
+ Object[] objArr2 = trimmedSeq2.toArray();
+ for (int i = 0; i < size1; i++) {
+ Object obj1 = objArr1[i];
+ Object obj2 = objArr2[i];
+ if (obj1 == null) {
+ if (obj2 != null) {
+ localFail("sequence for " + name1 + " had null element for which " + name2 + " had '" + obj2
+ + "'");
+ }
+ } else if (obj2 == null) {
+ localFail("sequence for " + name2 + " had null element for which " + name1 + " had '" + obj1 + "'");
+ } else {
+ if (!obj1.equals(obj2)) {
+ localFail("sequences did not match: " + name1 + " had '" + obj1 + "' but " + name2 + " had '"
+ + obj2 + "'");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void getAndCompareProperties(String propName, DataObject xmlAndRefTypDO, DataObject apiAndDynTypDO,
+ DataObject apiAndRefTypDO) {
+ Object xmlRefProperty = xmlAndRefTypDO.get(propName);
+ Object apiDynProperty = apiAndDynTypDO.get(propName);
+ Object apiRefProperty = apiAndRefTypDO.get(propName);
+ comparePropertyObjects(propName, SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_DYN, xmlRefProperty, apiDynProperty);
+ comparePropertyObjects(propName, SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_REF, xmlRefProperty, apiRefProperty);
+ }
+
+ private void localFail(String message) {
+ // System.err.println(message);
+ fail(message);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ private void specifyProperty(DataObject containingTypeDO, String nameString, Type typ, boolean isMany) {
+ DataObject subordinateProperty = containingTypeDO.createDataObject("property");
+ subordinateProperty.set("name", nameString);
+ subordinateProperty.set("type", typ);
+ subordinateProperty.setBoolean("many", isMany);
+ }
+
+ /**
+ * test #0 of Data Object primitive datatypes
+ */
+ public void testDynamicTypesGroup0DO() throws IOException {
+ HelperContext hcDO = SDOUtil.createHelperContext();
+
+ TypeHelper thDO = hcDO.getTypeHelper();
+ DataFactory dfDO = hcDO.getDataFactory();
+
+ // create a container object type
+ DataObject containerTypeDO = dfDO.create("commonj.sdo", "Type");
+ containerTypeDO.set("uri", DYNAMIC_TYPES_URI);
+ containerTypeDO.set("name", DYNAMIC_ROOT_TYPE_0);
+ containerTypeDO.set("sequenced", Boolean.TRUE);
+
+ specifyProperty(containerTypeDO, "aString", thDO.getType(COMMONJ_SDO, "String"), true);
+ specifyProperty(containerTypeDO, "aBoolean", thDO.getType(COMMONJ_SDO, "Boolean"), true);
+ specifyProperty(containerTypeDO, "aFloat", thDO.getType(COMMONJ_SDO, "Float"), true);
+
+ Type containerType = thDO.define(containerTypeDO);
+ assertNotNull(containerType);
+
+ DataObject doFromApiAndDynTyp = dfDO.create(containerType);
+ assertNotNull(doFromApiAndDynTyp);
+ doFromApiAndDynTyp.getList("aString").add("This is a repeated string.");
+ doFromApiAndDynTyp.getList("aString").add("This is a repeated string.");
+ doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(true));
+ doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(false));
+ doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(true));
+ doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(true));
+ doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(false));
+ doFromApiAndDynTyp.getList("aFloat").add(new Float(0));
+ doFromApiAndDynTyp.getList("aFloat").add(new Float(12.5));
+ doFromApiAndDynTyp.getList("aFloat").add(new Float(0));
+
+ Type rootType = thDO.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_0);
+ assertNotNull(rootType);
+ assertSame(containerType, rootType);
+
+ // now load xml to get a reference data object using schema
+ HelperContext hcRef = SDOUtil.createHelperContext();
+ XSDHelper xsdHelper = hcRef.getXSDHelper();
+ List typeList = xsdHelper.define(DYNAMIC_TYPES_SCHEMA_STRING);
+ assertNotNull(typeList);
+ TypeHelper thRef = hcRef.getTypeHelper();
+ Type rootTypeRef = thRef.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_0);
+
+ assertNotNull(rootTypeRef);
+
+ XMLHelper xhRef = hcRef.getXMLHelper();
+ // XMLDocument docRef =
+ // xhRef.load(getClass().getResourceAsStream(TEST_XML_DOC_0));
+ XMLDocument docRef = xhRef.load(TEST_XML_DOC_0_STRING);
+ DataObject doFromXmlAndRefTyp = docRef.getRootObject();
+
+ assertNotNull(doFromXmlAndRefTyp);
+
+ // create a data object using dynamic API from reference type
+ DataFactory dfRef = hcRef.getDataFactory();
+ DataObject doFromApiAndRefTyp = dfRef.create(rootTypeRef);
+ assertNotNull(doFromApiAndRefTyp);
+ doFromApiAndRefTyp.getList("aString").add("This is a repeated string.");
+ doFromApiAndRefTyp.getList("aString").add("This is a repeated string.");
+ doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(true));
+ doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(false));
+ doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(true));
+ doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(true));
+ doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(false));
+ doFromApiAndRefTyp.getList("aFloat").add(new Float(0));
+ doFromApiAndRefTyp.getList("aFloat").add(new Float(12.5));
+ doFromApiAndRefTyp.getList("aFloat").add(new Float(0));
+
+ getAndCompareProperties("aString", doFromXmlAndRefTyp, doFromApiAndDynTyp, doFromApiAndRefTyp);
+ getAndCompareProperties("aBoolean", doFromXmlAndRefTyp, doFromApiAndDynTyp, doFromApiAndRefTyp);
+ getAndCompareProperties("aFloat", doFromXmlAndRefTyp, doFromApiAndDynTyp, doFromApiAndRefTyp);
+ Sequence seqFromXmlAndRefTyp = doFromXmlAndRefTyp.getSequence();
+ Sequence seqFromApiAndDynTyp = doFromApiAndDynTyp.getSequence();
+ Sequence seqFromApiAndRefTyp = doFromApiAndRefTyp.getSequence();
+ compareSequencesIgnoringWhitespace(SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_DYN, seqFromXmlAndRefTyp,
+ seqFromApiAndDynTyp);
+ compareSequencesIgnoringWhitespace(SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_REF, seqFromXmlAndRefTyp,
+ seqFromApiAndRefTyp);
+ }
+
+ private void trimWhitespaceFromSequence(List trimmedSeq, Sequence sequence) {
+ if (sequence != null) {
+ for (int i = 0; i < sequence.size(); i++) {
+ Object obj = sequence.getValue(i);
+ if (obj instanceof String) {
+ String str = ((String) obj).trim();
+ if (str.length() > 0) {
+ trimmedSeq.add(str);
+ }
+ } else {
+ trimmedSeq.add(obj);
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java
new file mode 100644
index 0000000000..7674cda42b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java
@@ -0,0 +1,1878 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import com.example.ExpectedException.ExpectedExceptionFactory;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+import junit.framework.TestCase;
+
+/**
+ * Verifies the Exception related behavior which is explicitly identified in
+ * the 2.1 SDO Specification.
+ */
+public class ExpectedExceptionsTestCase extends TestCase {
+
+ private static final String TEST_URI = "http://example.com/ExpectedException";
+ private static final String TEST_TYPE_NAME = "ExpectedExceptionType";
+ private static final String SEQ_TYPE_NAME = "SequenceReadOnlyType";
+ private static boolean typeDefined = false;
+ private static HelperContext helperContext;
+ private static DataObject testDO;
+ private static DataObject seqDO;
+
+ /**
+ * Verifies the following statement.
+ * Get(String path) will not throw exceptions other than ClassCastException
+ * if it is impossible to convert between the actual and expected types.
+ * Note: This test case will not be implmented because it is already covered
+ * by testCannnotConvertClassCastException.
+ */
+
+ public void testGetTStringClassCastExceptionOnly() {
+ // This test case will not be implemented.
+ }
+
+ /**
+ * Verifies the following statement.
+ * get(Property property) throws an IllegalArgumentException when
+ * getInstanceProperties().contains(property) == false.
+ */
+ public void testGetViaPropertyIllegalArgumentException() {
+ DataObject invalidPropDO = helperContext.getDataFactory().create(TEST_URI, SEQ_TYPE_NAME);
+ Property invalidProp = invalidPropDO.getInstanceProperty("uniqueName");
+
+ try {
+ testDO.get(invalidProp);
+ fail("get(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("get(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBoolean(invalidProp);
+ fail("getBoolean(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBoolean(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getByte(invalidProp);
+ fail("getByte(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getByte(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getChar(invalidProp);
+ fail("getChar(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getChar(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDouble(invalidProp);
+ fail("getDouble(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDouble(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getFloat(invalidProp);
+ fail("getFloat(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getFloat(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getInt(invalidProp);
+ fail("getInt(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getInt(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getLong(invalidProp);
+ fail("getLong(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getLong(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getShort(invalidProp);
+ fail("getShort(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getShort(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBytes(invalidProp);
+ fail("getBytes(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBytes(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigDecimal(invalidProp);
+ fail("getBigDecimal(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigDecimal(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigInteger(invalidProp);
+ fail("getBigInteger(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigInteger(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDataObject(invalidProp);
+ fail("getDataObject(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDataObject(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDate(invalidProp);
+ fail("getDate(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDate(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getString(invalidProp);
+ fail("getString(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getString(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getList(invalidProp);
+ fail("getList(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getList(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(property)== false. " + e.getClass().getName() + " was thrown.");
+ }
+ }
+
+ /**
+ * Verfies the following statement.
+ * get(int propertyIndex) throws an IllegalArgumentException when
+ * propertIndex <0 or >= getInstanceProerties().size()
+ */
+ public void testGetViaIndexIllegalArgumentException() {
+ int numProps = testDO.getInstanceProperties().size();
+
+ try {
+ testDO.get(-1);
+ fail("get(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("get(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBoolean(-1);
+ fail("getBoolean(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBoolean(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getByte(-1);
+ fail("getByte(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getByte(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getChar(-1);
+ fail("getChar(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getChar(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDouble(-1);
+ fail("getDouble(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDouble(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getFloat(-1);
+ fail("getFloat(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getFloat(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getInt(-1);
+ fail("getInt(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getInt(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getLong(-1);
+ fail("getLong(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getLong(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getShort(-1);
+ fail("getShort(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getShort(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBytes(-1);
+ fail("getBytes(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBytes(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigDecimal(-1);
+ fail("getBigDecimal(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigDecimal(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigInteger(-1);
+ fail("getBigInteger(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigInteger(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDataObject(-1);
+ fail("getDataObject(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDataObject(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDate(-1);
+ fail("getDate(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDate(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getString(-1);
+ fail("getString(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getString(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getList(-1);
+ fail("getList(-1) should throw an IllegalArgumentException. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getList(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown.");
+ }
+
+ try {
+ testDO.get(numProps);
+ fail("get(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("get(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBoolean(numProps);
+ fail("getBoolean(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBoolean(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getByte(numProps);
+ fail("getByte(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getByte(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getChar(numProps);
+ fail("getChar(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getChar(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDouble(numProps);
+ fail("getDouble(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDouble(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getFloat(numProps);
+ fail("getFloat(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getFloat(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getInt(numProps);
+ fail("getInt(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getInt(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getLong(numProps);
+ fail("getLong(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getLong(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getShort(numProps);
+ fail("getShort(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getShort(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBytes(numProps);
+ fail("getBytes(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBytes(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigDecimal(numProps);
+ fail("getBigDecimal(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigDecimal(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigInteger(numProps);
+ fail("getBigInteger(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigInteger(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDataObject(numProps);
+ fail("getDataObject(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDataObject(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDate(numProps);
+ fail("getDate(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDate(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getString(numProps);
+ fail("getString(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getString(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getList(numProps);
+ fail("getList(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getList(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ }
+
+ /**
+ * Verifies the following statement.
+ * Using an Index out of range (index < 0 or >= getList(Property property).size())
+ * will result in an IndexOutOfBoundsException.
+ */
+ public void testListIndexOutOfBoundsException() {
+ List list = testDO.getList("listVal");
+
+// Not fixed in TUSCANY-578
+// try {
+// list.get(-1);
+// fail("list.get(-1) should throw an IndexOutOfBoundsException. No Exception was thrown.");
+// } catch (IndexOutOfBoundsException e) {
+// // Success - do nothing
+// } catch (Exception e) {
+// fail("list.get(-1) should throw an IndexOutOfBoundsException. " + e.getClass().getName() + " was thrown.");
+// }
+// try {
+// list.get(list.size());
+// fail("list.get(int) should throw an IndexOutOfBoundsException when int >= list.size(). No Exception was thrown.");
+// } catch (IndexOutOfBoundsException e) {
+// // Success - do nothing
+// } catch (Exception e) {
+// fail("list.get(int) should throw an IndexOutOfBoundsException when int >= list.size(). " + e.getClass().getName() + " was thrown.");
+// }
+// try {
+// list.remove(-1);
+// fail("list.remove(-1) should throw an IndexOutOfBoundsException. No Exception was thrown.");
+// } catch (IndexOutOfBoundsException e) {
+// // Success - do nothing
+// } catch (Exception e) {
+// fail("list.remove(-1) should throw an IndexOutOfBoundsException. " + e.getClass().getName() + " was thrown.");
+// }
+ try {
+ list.remove(list.size());
+ fail("list.remove(int) should throw an IndexOutOfBoundsException when int >= list.size(). No Exception was thrown.");
+ } catch (IndexOutOfBoundsException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("list.remove(int) should throw an IndexOutOfBoundsException when int >= list.size(). " + e.getClass().getName() + " was thrown.");
+ }
+ }
+
+ /**
+ * Verifies the following statement.
+ * Modification of a read-only property results in UnsupportedOperationException.
+ * This test case is for modifications done through the DataObject API.
+ */
+ public void testModifyReadOnlyUnsupportedOperationException() {
+ Property readOnlyProp = testDO.getInstanceProperty("readOnlyVal");
+ List properties = testDO.getInstanceProperties();
+ Property currProp;
+ int readOnlyIndex = -1, i = 0, size = properties.size();
+
+ // Verify the precondition
+ assertTrue("readOnlyVal should be read-only.", readOnlyProp.isReadOnly());
+
+ while (readOnlyIndex < 0 && i < size) {
+ currProp = (Property) properties.get(i);
+ if (currProp.equals(readOnlyProp))
+ readOnlyIndex = i;
+ i++;
+ }
+
+ try {
+ testDO.set("readOnlyVal", "NewValue");
+ fail("DataObject.set(string, value) should throw an UnsupportedOperationException when the Property represented by string is read-only. No Exception was thrown.");
+ } catch (UnsupportedOperationException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataObject.set(string, value) should throw an UnsupportedOperationException when the Property represented by string is read-only. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.set(readOnlyProp, "NewValue");
+ System.out.println("propname =" + readOnlyProp.getName());
+ fail("DataObject.set(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. No Exception was thrown.");
+ } catch (UnsupportedOperationException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataObject.set(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. " + e.getClass().getName() + " was thrown.");
+ }
+ assertTrue("The test case could not procede because the index of the read only Property was not found.", readOnlyIndex > -1);
+ try {
+ testDO.set(readOnlyIndex, "NewValue");
+ fail("DataObject.set(index, value) should throw an UnsupportedOperationException when the Property represented by index is read-only. No Exception was thrown.");
+ } catch (UnsupportedOperationException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataObject.set(index, value) should throw an UnsupportedOperationException when the Property represented by index is read-only. " + e.getClass().getName() + " was thrown.");
+ }
+
+ try {
+ testDO.unset("readOnlyVal");
+ fail("DataObject.unset(string) should throw an UnsupportedOperationException when the Property represented by string is read-only. No Exception was thrown.");
+ } catch (UnsupportedOperationException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataObject.unset(string) should throw an UnsupportedOperationException when the Property represented by string is read-only. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.unset(readOnlyProp);
+ fail("DataObject.unset(property) should throw an UnsupportedOperationException when the Property represented by property is read-only. No Exception was thrown.");
+ } catch (UnsupportedOperationException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataObject.unset(property) should throw an UnsupportedOperationException when the Property represented by property is read-only. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.unset(readOnlyIndex);
+ fail("DataObject.unset(index) should throw an UnsupportedOperationException when the Property represented by index is read-only. No Exception was thrown.");
+ } catch (UnsupportedOperationException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataObject.unset(index) should throw an UnsupportedOperationException when the Property represented by index is read-only. " + e.getClass().getName() + " was thrown.");
+ }
+ }
+
+ /**
+ * Verifies the following statement.
+ * Modification of a read-only property results in UnsupportedOperationException.
+ * This test case is for modification done through the List API.
+ */
+ public void testModifyReadOnlyUnsupportedOperationExceptionList() {
+ Property readOnlyProp = testDO.getInstanceProperty("readOnlyVal");
+ List properties = testDO.getInstanceProperties();
+ Property currProp;
+ int readOnlyIndex = -1, i = 0, size = properties.size();
+
+ while (readOnlyIndex < 0 && i < size) {
+ currProp = (Property) properties.get(i);
+ if (currProp.equals(readOnlyProp))
+ readOnlyIndex = i;
+ i++;
+ }
+
+// Not fixed in TUSCANY-578
+// try {
+// List temp = testDO.getList("readOnlyListVal");
+// temp.add("String to add.");
+// fail("DataObject.getList(path).add(value) should throw an UnsupportedOperationException when the Property represented by path is read-only. No Exception was thrown.");
+// } catch (UnsupportedOperationException e) {
+// // Success - do nothing
+// } catch (Exception e) {
+// fail("DataObject.getList(path).add(value) should throw an IllegalArgumentException when the Property represented by path is read-only. " + e.getClass().getName() + " was thrown.");
+// }
+// try {
+// Sequence temp = testDO.getSequence();
+// temp.add("readOnlyListVal", "String to add.");
+// fail("DataObject.getSequence().add(path, value) should throw an UnsupportedOperationException when the Property represtend by path is read-only. No Exception was thrown.");
+// } catch (UnsupportedOperationException e) {
+// // Success - do nothing
+// } catch (Exception e) {
+// fail("DataObject.getSequence().add(path, value) should throw an UnsupportedOperationException when the Property represtend by path is read-only. " + e.getClass().getName() + " was thrown.");
+// }
+ }
+
+ /**
+ * Verifies the following statement.
+ * Modification of a read-only property results in UnsupportedOperationException.
+ * This test case is for modification done through the List API.
+ */
+ public void testModifyReadOnlyUnsupportedOperationExceptionSequence() {
+ Property readOnlyProp = seqDO.getInstanceProperty("readOnlyVal");
+ List properties = seqDO.getInstanceProperties();
+ Property currProp;
+ int readOnlyIndex = -1, i = 0, size = properties.size();
+
+ while (readOnlyIndex < 0 && i < size) {
+ currProp = (Property) properties.get(i);
+ if (currProp.equals(readOnlyProp))
+ readOnlyIndex = i;
+ i++;
+ }
+
+// Not fixed in TUSCANY-578
+// try {
+// Sequence sequence = seqDO.getSequence();
+// sequence.add(readOnlyProp, "New Value");
+// fail("Sequence.add(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. No Exception was thrown.");
+// } catch (UnsupportedOperationException e) {
+// // Success - do nothing
+// } catch (Exception e) {
+// fail("Sequence.add(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. " + e.getClass().getName() + " was thrown.");
+// }
+ }
+
+ /**
+ * Verifies the following statement.
+ * A ClassCastException results when cannot convert between value and requested Type.
+ */
+
+ public void testCannotConvertClassCastException() {
+ // Attempt conversion from boolean
+
+ try {
+ testDO.getByte("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDouble("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getFloat("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getInt("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getLong("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getShort("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigDecimal("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigInteger("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("booleanVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+ // Attempt conversion from byte
+ try {
+ testDO.getBoolean("byteVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("byteVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigDecimal("byteVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigInteger("byteVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("byteVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("byteVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ // Attempt conversion from character
+ try {
+ testDO.getBoolean("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getByte("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDouble("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getFloat("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getInt("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getLong("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getShort("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigDecimal("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigInteger("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("charVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from double
+ try {
+ testDO.getBoolean("doubleVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("doubleVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("doubleVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("doubleVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from float
+ try {
+ testDO.getBoolean("floatVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("floatVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("floatVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("floatVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from int
+ try {
+ testDO.getBoolean("intVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("intVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("intVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("intVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from long
+ try {
+ testDO.getBoolean("longVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("longVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("longVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from short
+ try {
+ testDO.getBoolean("shortVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("shortVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("shortVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigDecimal("shortVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigInteger("shortVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("shortVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from bytes
+ try {
+ testDO.getBoolean("bytesVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getByte("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDouble("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getFloat("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getInt("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getLong("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getShort("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigDecimal("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("bytesVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from decimal
+ try {
+ testDO.getBoolean("decimalVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getByte("decimalVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("decimalVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getShort("decimalVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("decimalVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("decimalVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from BigInteger
+ try {
+ testDO.getBoolean("integerVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getByte("integerVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("integerVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getShort("integerVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDate("integerVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+
+// Attempt conversion from date
+ try {
+ testDO.getBoolean("dateVal");
+ } catch (ClassCastException e) {
+ // success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getByte("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getChar("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getDouble("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getFloat("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getInt("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getShort("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBytes("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigDecimal("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ try {
+ testDO.getBigInteger("dateVal");
+ } catch (ClassCastException e) {
+// success - do nothing
+ } catch (Exception e) {
+ fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName());
+ }
+ }
+
+
+ /**
+ * Verifies the following statement.
+ * Mixing single-valued and multi-valued Property access results in
+ * ClassCastException.
+ */
+ public void testMixSingleMultiValueClassCastException() {
+ Property testedProp = testDO.getInstanceProperty("intVal");
+ List properties = testDO.getInstanceProperties();
+ Property currProp;
+ int testedIndex = -1, i = 0, size = properties.size();
+
+ while (testedIndex < 0 && i < size) {
+ currProp = (Property) properties.get(i);
+
+ if (currProp.equals(testedProp))
+ testedIndex = i;
+ i++;
+ }
+
+ try {
+ testDO.getList("intVal");
+ fail("getList(string) should throw a ClassCastException when the property represented by string is single-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getList(string) should throw a ClassCastException when the property represented by string is single-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getList(testedProp);
+ fail("getList(property) should throw a ClassCastException when the property represented by property is single-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getList(property) should throw a ClassCastException when the property represented by property is single-valued. " + e.getClass().getName() + " was thrown.");
+ }
+
+ assertTrue("The test case could not procede because the index of the single-valued Property was not found.", testedIndex > -1);
+
+ try {
+ testDO.getList(testedIndex);
+ fail("getList(index) should throw a ClassCastException when the property represented by index is single-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getList(index) should throw a ClassCastException when the property represented by index is single-valued. " + e.getClass().getName() + " was thrown.");
+ }
+
+ testedProp = testDO.getInstanceProperty("listVal");
+ testedIndex = -1;
+ i = 0;
+ while (testedIndex < 0 && i < size) {
+ currProp = (Property) properties.get(i);
+ if (currProp.equals(testedProp))
+ testedIndex = i;
+ i++;
+ }
+
+ try {
+ testDO.getBoolean("listVal");
+ fail("getBoolean(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBoolean(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getByte("listVal");
+ fail("getByte(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getByte(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getChar("listVal");
+ fail("getChar(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getChar(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDouble("listVal");
+ fail("getDouble(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDouble(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getFloat("listVal");
+ fail("getFloat(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getFloat(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getInt("listVal");
+ fail("getInt(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getInt(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getLong("listVal");
+ fail("getLong(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getLong(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getShort("listVal");
+ fail("getShort(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getShort(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBytes("listVal");
+ fail("getBytes(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBytes(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigDecimal("listVal");
+ fail("getBigDecimal(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigDecimal(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigInteger("listVal");
+ fail("getBigInteger(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigInteger(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDataObject("listVal");
+ fail("getDataObject(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDataObject(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDate("listVal");
+ fail("getDate(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDate(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getString("listVal");
+ fail("getString(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getString(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+
+ try {
+ testDO.getBoolean(testedProp);
+ fail("getBoolean(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBoolean(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getByte(testedProp);
+ fail("getByte(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getByte(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getChar(testedProp);
+ fail("getChar(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getChar(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDouble(testedProp);
+ fail("getDouble(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDouble(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getFloat(testedProp);
+ fail("getFloat(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getFloat(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getInt(testedProp);
+ fail("getInt(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getInt(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getLong(testedProp);
+ fail("getLong(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getLong(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getShort(testedProp);
+ fail("getShort(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getShort(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBytes(testedProp);
+ fail("getBytes(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBytes(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigDecimal(testedProp);
+ fail("getBigDecimal(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigDecimal(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigInteger(testedProp);
+ fail("getBigInteger(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigInteger(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDataObject(testedProp);
+ fail("getDataObject(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDataObject(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDate(testedProp);
+ fail("getDate(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDate(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getString(testedProp);
+ fail("getString(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getString(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+
+ assertTrue("The test case could not procede because the index of the multi-valued Property was not found.", testedIndex > -1);
+
+ try {
+ testDO.getBoolean(testedIndex);
+ fail("getBoolean(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBoolean(index) should throw a ClassCastException when the property represented by is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getByte(testedIndex);
+ fail("getByte(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getByte(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getChar(testedIndex);
+ fail("getChar(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getChar(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDouble(testedIndex);
+ fail("getDouble(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDouble(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getFloat(testedIndex);
+ fail("getFloat(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getFloat(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getInt(testedIndex);
+ fail("getInt(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getInt(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getLong(testedIndex);
+ fail("getLong(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getLong(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getShort(testedIndex);
+ fail("getShort(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getShort(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBytes(testedIndex);
+ fail("getBytes(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBytes(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigDecimal(testedIndex);
+ fail("getBigDecimal(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigDecimal(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getBigInteger(testedIndex);
+ fail("getBigInteger(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getBigInteger(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDataObject(testedIndex);
+ fail("getDataObject(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDataObject(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getDate(testedIndex);
+ fail("getDate(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getDate(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ try {
+ testDO.getString(testedIndex);
+ fail("getString(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown.");
+ } catch (ClassCastException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("getString(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown.");
+ }
+ }
+
+ /*
+ /**
+ * Verifies the following statement.
+ * Establishing circular containment results in an IllegalArgumentException.
+ * Note: This test case will not be implemented because it has been determined
+ * that the statement will be removed from the spec.
+ */
+ /*
+ public void testContainmentCycleIllegalArgumentException() {
+ // This test case will not be implemented.
+ }
+ */
+
+ /**
+ * Verifies the following statement.
+ * An empty DataGraph can have a root assigned by the createRootObject() methods.
+ * However, if a previous root DataObject exists than an IllegalStateException is
+ * thrown.
+ */
+ public void testCreateRootObjectAgainIllegalStateException() {
+ DataGraph dataGraph = SDOUtil.createDataGraph();
+ Type type = testDO.getType();
+
+ // verify the initial condition
+ assertNull("The DataGraph should have been created without a root DataObject.", dataGraph.getRootObject());
+ assertNotNull("DataObject.getType() returned null.", type);
+
+ dataGraph.createRootObject(type);
+
+ // verify the pre-condition
+ assertNotNull("The DataGraph.createRootObject() should have created a root DataObject for the DataGraph.", dataGraph.getRootObject());
+
+ try {
+ dataGraph.createRootObject(type);
+ fail("DataGraph.createRootObject(Type) should throw an IllegalStateException a root Object already exists for the DataGraph. No Exception was thrown.");
+ } catch (IllegalStateException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataGraph.createRootObject(Type) should throw an IllegalStateException a root Object already exists for the DataGraph. " + e.getClass().getName() + " was thrown.");
+ }
+ }
+
+ /**
+ * Verifies the following statement.
+ * DataFactory.create() throws an IllegalArgumentException if the instanceClass does
+ * not correspond to a Type this factory can instantiate.
+ */
+ public void testDataFactoryCreateIllegalArgumentException() {
+ try {
+ helperContext.getDataFactory().create(java.lang.Object.class);
+ fail("DataFactory.create(Object) should throw an IllegalArgumentException when it cannot instantiate the Type specified. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataFactory.create(Object) should throw an IllegalArgumentException when it cannot instantiate the Type specified. " + e.getClass().getName() + " was thrown.");
+ }
+
+ try {
+ helperContext.getDataFactory().create(commonj.sdo.DataObject.class);
+ fail("DataFactory.create(DataObject) should throw an IllegalArgumentException when it cannot instantiate the Type specified. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataFactory.create(DataObject) should throw an IllegalArgumentException when it cannot instantiate the Type specified. " + e.getClass().getName() + " was thrown.");
+ }
+
+ try {
+ helperContext.getDataFactory().create(commonj.sdo.ChangeSummary.class);
+ fail("DataFactory.create(ChangeSummary) should throw an IllegalArgumentException when it cannot instantiate the Type specified. No Exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Success - do nothing
+ } catch (Exception e) {
+ fail("DataFactory.create(ChangeSummary) should throw an IllegalArgumentException when it cannot instantiate the Type specified. " + e.getClass().getName() + " was thrown.");
+ }
+ }
+
+ /**
+ * Defines the Type the first time through.
+ */
+ public void setUp() {
+ if (!typeDefined) {
+ helperContext = SDOUtil.createHelperContext();
+// createWithXSD(helperContext);
+// createDynamically(helperContext);
+ createStatically(helperContext);
+ typeDefined = true;
+ }
+// testDO = helperContext.getDataFactory().create(TEST_URI, TEST_TYPE_NAME);
+// seqDO = helperContext.getDataFactory().create(TEST_URI, SEQ_TYPE_NAME);
+ testDO = (DataObject) ExpectedExceptionFactory.INSTANCE.createExpectedExceptionType();
+ seqDO = (DataObject) ExpectedExceptionFactory.INSTANCE.createSequenceReadOnlyType();
+ }
+
+ public static void createStatically(HelperContext hc) {
+ ExpectedExceptionFactory.INSTANCE.register(hc);
+ }
+
+ public static void createWithXSD(HelperContext hc) {
+ // Populate the meta data for the test model
+ URL url = ExpectedExceptionsTestCase.class.getResource("/expectedExceptions.xsd");
+ try {
+ InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 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");
+ Type intType = types.getType("commonj.sdo", "Int");
+ Type booleanType = types.getType("commonj.sdo", "Boolean");
+ Type byteType = types.getType("commonj.sdo", "Byte");
+ Type decimalType = types.getType("commonj.sdo", "Decimal");
+ Type floatType = types.getType("commonj.sdo", "Float");
+ Type doubleType = types.getType("commonj.sdo", "Double");
+ Type dateType = types.getType("commonj.sdo", "Date");
+ Type shortType = types.getType("commonj.sdo", "Short");
+ Type longType = types.getType("commonj.sdo", "Long");
+ Type bytesType = types.getType("commonj.sdo", "Bytes");
+ Type integerType = types.getType("commonj.sdo", "Integer");
+ Type charType = types.getType("commonj.sdo", "Character");
+
+ DataObject testType = hc.getDataFactory().create("commonj.sdo", "Type");
+ testType.set("uri", TEST_URI);
+ testType.set("name", TEST_TYPE_NAME);
+
+ DataObject stringProperty = testType.createDataObject("property");
+ stringProperty.set("name", "stringVal");
+ stringProperty.set("type", stringType);
+
+ DataObject booleanProperty = testType.createDataObject("property");
+ booleanProperty.set("name", "booleanVal");
+ booleanProperty.set("type", booleanType);
+
+ DataObject byteProperty = testType.createDataObject("property");
+ byteProperty.set("name", "byteVal");
+ byteProperty.set("type", byteType);
+
+ DataObject decimalProperty = testType.createDataObject("property");
+ decimalProperty.set("name", "decimalVal");
+ decimalProperty.set("type", decimalType);
+
+ DataObject intProperty = testType.createDataObject("property");
+ intProperty.set("name", "intVal");
+ intProperty.set("type", intType);
+
+ DataObject floatProperty = testType.createDataObject("property");
+ floatProperty.set("name", "floatVal");
+ floatProperty.set("type", floatType);
+
+ DataObject doubleProperty = testType.createDataObject("property");
+ doubleProperty.set("name", "doubleVal");
+ doubleProperty.set("type", doubleType);
+
+ DataObject dateProperty = testType.createDataObject("property");
+ dateProperty.set("name", "dateVal");
+ dateProperty.set("type", dateType);
+
+ DataObject shortProperty = testType.createDataObject("property");
+ shortProperty.set("name", "shortVal");
+ shortProperty.set("type", shortType);
+
+ DataObject longProperty = testType.createDataObject("property");
+ longProperty.set("name", "longVal");
+ longProperty.set("type", longType);
+
+ DataObject childrenProperty = testType.createDataObject("property");
+ childrenProperty.set("name", "listVal");
+ childrenProperty.setBoolean("many", true);
+ childrenProperty.set("type", stringType);
+
+ DataObject bytesProperty = testType.createDataObject("property");
+ bytesProperty.set("name", "bytesVal");
+ bytesProperty.set("type", bytesType);
+
+ DataObject integerProperty = testType.createDataObject("property");
+ integerProperty.set("name", "integerVal");
+ integerProperty.set("type", integerType);
+
+ DataObject charProperty = testType.createDataObject("property");
+ charProperty.set("name", "charVal");
+ charProperty.set("type", charType);
+
+ DataObject readOnlyProperty = testType.createDataObject("property");
+ readOnlyProperty.set("name", "readOnlyVal");
+ readOnlyProperty.set("type", stringType);
+ readOnlyProperty.setBoolean("readOnly", true);
+
+ DataObject readOnlyListProperty = testType.createDataObject("property");
+ readOnlyListProperty.set("name", "readOnlyListVal");
+ readOnlyListProperty.set("type", stringType);
+ readOnlyListProperty.setBoolean("readOnly", true);
+ readOnlyListProperty.setBoolean("many", true);
+
+ types.define(testType);
+
+ DataObject seqType = hc.getDataFactory().create("commonj.sdo", "Type");
+ seqType.set("uri", TEST_URI);
+ seqType.set("name", SEQ_TYPE_NAME);
+ seqType.setBoolean("sequenced", true);
+
+ DataObject seqROProperty = seqType.createDataObject("property");
+ seqROProperty.set("name", "readOnlyVal");
+ seqROProperty.set("type", stringType);
+ seqROProperty.setBoolean("readOnly", true);
+
+ DataObject seqROListProperty = seqType.createDataObject("property");
+ seqROListProperty.set("name", "readOnlyListVal");
+ seqROListProperty.set("type", stringType);
+ seqROListProperty.setBoolean("readOnly", true);
+ seqROListProperty.setBoolean("many", true);
+
+ DataObject uniqueNameProperty = seqType.createDataObject("property");
+ uniqueNameProperty.set("name", "uniqueName");
+ uniqueNameProperty.set("type", stringType);
+
+ types.define(seqType);
+ }
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java
new file mode 100644
index 0000000000..e630a8f903
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java
@@ -0,0 +1,112 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.resource.Resource;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLHelper;
+
+public class FormTestCase extends TestCase {
+ XMLHelper xmlHelper;
+ Map options;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ HelperContext hc = SDOUtil.createHelperContext();
+ hc.getXSDHelper().define(
+""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+"");
+ xmlHelper = hc.getXMLHelper();
+ options = new HashMap();
+ /*
+ * turn off default behaviour of tolerating malformed xml
+ * tests using this option and bad xml should demonstrate failure to load
+ */
+ options.put(SDOUtil.XML_LOAD_LaxForm, new Integer(0));
+ }
+
+ void load(String xml, Object options) throws IOException {
+ assertNotNull(xmlHelper.load(new StringReader(xml), null, options).getRootObject());
+ }
+
+ /*
+ * this malformed xml will load, as it uses the default lax approach
+ */
+ public void testLaxForm() throws IOException {
+ load(
+""+
+ ""+
+ ""+
+"", null);
+ }
+
+ /*
+ * any malformed xml through this method will fail to load
+ * since the options instance member disables lax processing
+ */
+ protected final void load(String xml) throws IOException {
+ try {
+ load(xml, options);
+ fail();
+ } catch (Resource.IOWrappedException featureNotFound) {
+ }
+ }
+
+ public void testUnqualifiedAttribute() throws IOException {
+ load("");
+ }
+
+ public void testQualifiedAttribute() throws IOException {
+ load("");
+ }
+
+ public void testUnqualifiedElement() throws IOException {
+ load(
+""+
+ ""+
+"");
+ }
+
+ public void testQualifiedElement() throws IOException {
+ load(
+""+
+ ""+
+"");
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java
new file mode 100644
index 0000000000..14e81b6a32
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java
@@ -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 junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.DataHelper;
+import commonj.sdo.helper.EqualityHelper;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import commonj.sdo.impl.HelperProvider;
+
+public class HelperContextTestCase extends TestCase {
+
+ public void testDefaultHelperContext() {
+ HelperContext defaultHelperContext = HelperProvider.getDefaultContext();
+
+ assertNotNull(defaultHelperContext.getCopyHelper());
+ assertEquals(defaultHelperContext.getCopyHelper(), CopyHelper.INSTANCE);
+ assertNotNull(defaultHelperContext.getDataFactory());
+ assertEquals(defaultHelperContext.getDataFactory(), DataFactory.INSTANCE);
+ assertNotNull(defaultHelperContext.getDataHelper());
+ assertEquals(defaultHelperContext.getDataHelper(), DataHelper.INSTANCE);
+ assertNotNull(defaultHelperContext.getEqualityHelper());
+ assertEquals(defaultHelperContext.getEqualityHelper(), EqualityHelper.INSTANCE);
+ assertNotNull(defaultHelperContext.getTypeHelper());
+ assertEquals(defaultHelperContext.getTypeHelper(), TypeHelper.INSTANCE);
+ assertNotNull(defaultHelperContext.getXMLHelper());
+ assertEquals(defaultHelperContext.getXMLHelper(), XMLHelper.INSTANCE);
+ assertNotNull(defaultHelperContext.getXSDHelper());
+ assertEquals(defaultHelperContext.getXSDHelper(), XSDHelper.INSTANCE);
+
+ }
+
+ public void testCreateHelperContext() {
+ HelperContext hc = SDOUtil.createHelperContext();
+ assertNotNull(hc.getCopyHelper());
+ assertNotNull(hc.getDataFactory());
+ assertNotNull(hc.getDataHelper());
+ assertNotNull(hc.getEqualityHelper());
+ assertNotNull(hc.getTypeHelper());
+ assertNotNull(hc.getXMLHelper());
+ assertNotNull(hc.getXSDHelper());
+
+ assertNotSame(hc.getDataFactory(), DataFactory.INSTANCE);
+ assertNotSame(hc.getTypeHelper(), TypeHelper.INSTANCE);
+ assertNotSame(hc.getXMLHelper(), XMLHelper.INSTANCE);
+ assertNotSame(hc.getXSDHelper(), XSDHelper.INSTANCE);
+ // the other "stateless" helpers may be the same as the singletons
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java
new file mode 100644
index 0000000000..1eef4ea657
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java
@@ -0,0 +1,65 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.*;
+import commonj.sdo.helper.*;
+
+public class IsManyTestCase extends TestCase {
+ private final String TEST_MODEL = "/open.xsd";
+ private final String TEST_MODEL1ANY = "/open1any.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/open";
+ private final String TEST_NAMESPACE1ANY = "http://www.example.com/open1any";
+
+ public void testIsMany() {
+ Property priceProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "price", true);
+
+ Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "OpenQuote");
+ DataObject quote = DataFactory.INSTANCE.create(quoteType);
+ assertTrue( SDOUtil.isMany(priceProperty, quote));
+
+ quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE1ANY, "OpenQuote");
+ quote = DataFactory.INSTANCE.create(quoteType);
+ assertFalse( SDOUtil.isMany(priceProperty, quote));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+
+ // Populate the meta data for the test (Stock Quote) model with maxOccurs=1
+ url = getClass().getResource(TEST_MODEL1ANY);
+ inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java
new file mode 100644
index 0000000000..56a293cde0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java
@@ -0,0 +1,297 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+public class JavaSerializeDeserializeTestCase extends TestCase
+{
+
+ public void testScopeDefinedSerializeDeserializeOfDataObject()
+ {
+ HelperContext hc = SDOUtil.createHelperContext();
+ Object originalDataObject = createDynamically(hc,true);
+
+ runSerializeDeserialize((DataObject)originalDataObject, hc);
+ }
+
+ public void testScopeDefinedSerializeDeserializeOfDataGraph()
+ {
+ HelperContext hc = SDOUtil.createHelperContext();
+ DataGraph testDO = (DataGraph)createDynamically(hc,false);
+
+ runSerializeDeserializeWithDataGraph(testDO, hc);
+ }
+
+ private String xsdString = "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "";
+
+ public void testLargePayload()
+ {
+ HelperContext hc = SDOUtil.createHelperContext();
+ hc.getXSDHelper().define(xsdString);
+ DataObject company = hc.getDataFactory().create("http://www.example.com/simple", "Company");
+ company.setString("symbol", "EXAMPLE");
+ company.setString("companyName", "Example Inc.");
+ List employees = company.getList("employees");
+ DataObject employee;
+ for (int i=0; i<1000; i++) {
+ employee = hc.getDataFactory().create("http://www.example.com/simple", "Employee");
+ employee.setString("employeeID", "ID #" + i);
+ employee.setString("employeeName", "Empoyee #" + i);
+ employees.add(employee);
+ }
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = SDOUtil.createObjectOutputStream(bos, hc);
+ oos.writeObject(company);
+ oos.flush();
+ byte[] bytes = bos.toByteArray();
+ oos.close();
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = SDOUtil.createObjectInputStream(bis, hc);
+ ois.readObject();
+ ois.close();
+ bis.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("An Exception occurred while deserializing the output of the serialization: " + e.toString());
+ }
+ }
+
+
+ /**
+ * Serialize the DataObject then Deserialize the output.
+ * to testDO.
+ * @param testDO
+ * @param scope
+ */
+
+ public void runSerializeDeserialize(DataObject originalDataObject, HelperContext hc)
+ {
+
+ populateFields(originalDataObject);
+ DataObject tempDO = null;
+ ByteArrayOutputStream baos = null;
+
+ try
+ {
+ baos = serialize(originalDataObject, hc);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("An Exception occurred while serializing the DataObject: " + e.toString());
+ }
+
+ try
+ {
+ tempDO = deserialize(baos, hc);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("An Exception occurred while deserializing the output of the serialization: " + e.toString());
+ }
+
+ assertNotNull("Deserialization returned a null value.", tempDO);
+
+ assertSame(tempDO.getType(), originalDataObject.getType());
+
+
+ }
+
+ /**
+ * Serialize the DataGraph
+ * @param dataGraph
+ * @param scope
+ */
+ public void runSerializeDeserializeWithDataGraph(DataGraph dataGraph, HelperContext hc)
+ {
+ DataObject originalDataObject = dataGraph.getRootObject();
+ populateFields(originalDataObject);
+ DataObject tempDO = null;
+ ByteArrayOutputStream baos = null;
+
+ try
+ {
+ baos = serialize(dataGraph, hc);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("An Exception occurred while serializing the DataObject: " + e.toString());
+ }
+
+ try
+ {
+ tempDO = deserialize(baos, hc);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("An Exception occurred while deserializing the output of the serialization: " + e.toString());
+ }
+
+ assertNotNull("Deserialization returned a null value.", tempDO);
+
+ assertSame(tempDO.getType(), originalDataObject.getType());
+
+
+
+ }
+
+ /**
+ * serializeDataObject is a private method to be called by the other methods
+ * in the ScrenarioLibrary
+ *
+ * @param dataObject
+ * @param fileName
+ * @throws IOException
+ */
+ public ByteArrayOutputStream serialize(Object object, HelperContext hc) throws IOException
+ {
+ //FileOutputStream fos = new FileOutputStream("temp");
+ ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
+ ObjectOutputStream out = SDOUtil.createObjectOutputStream(byteArrayOutput, hc);
+ out.writeObject(object);
+ out.close();
+ return byteArrayOutput;
+ }
+
+ /**
+ * deserializeDataObject is a private method to be called by the other
+ * methods in the ScrenarioLibrary
+ *
+ * @param fileName
+ * @return
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ public DataObject deserialize(ByteArrayOutputStream baos, HelperContext hc) throws IOException, ClassNotFoundException
+ {
+ //FileInputStream fis = new FileInputStream("temp");
+ ObjectInputStream input = null;
+ ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(baos.toByteArray());
+
+ input = SDOUtil.createObjectInputStream(byteArrayInput, hc);
+
+ Object object = input.readObject();
+ input.close();
+ if(object instanceof DataGraph)
+ return ((DataGraph)object).getRootObject();
+ else
+ return (DataObject)object;
+ }
+
+ /**
+ * populateFields uses set to set each of the fields in the
+ * DataObject. It is used to ensure a known set of expected values that are
+ * not other than the default values for the various fields.
+ *
+ * @param testDO
+ * @throws ExpectedConditionError
+ */
+ public static void populateFields(DataObject testDO)
+ {
+
+ testDO.setString("stringVal", "Testing");
+
+ }
+ /**
+ * 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 Object createDynamically(HelperContext hc, boolean createDataObject)
+ {
+
+ TypeHelper types = hc.getTypeHelper();
+ DataFactory dataFactory = hc.getDataFactory();
+
+ Type stringType = types.getType("commonj.sdo", "String");
+
+ DataObject testType = dataFactory.create("commonj.sdo", "Type");
+ testType.set("uri", "http://www.example.com/api_test");
+ testType.set("name", "APITest");
+
+ DataObject stringProperty = testType.createDataObject("property");
+ stringProperty.set("name", "stringVal");
+ stringProperty.set("type", stringType);
+
+
+ List types2Define = new ArrayList();
+ types2Define.add(testType);
+ List apiXSD = types.define(types2Define);
+ Type apiXSDType = (Type) apiXSD.get(0);
+
+ if(createDataObject)
+ return dataFactory.create(apiXSDType);;
+
+ // Create an empty DataGraph and attach the document root to it. Otherwise, where is the documentRoot ?
+ DataGraph dataGraph = SDOUtil.createDataGraph();
+ /*DataObject testDO =*/ dataGraph.createRootObject(apiXSDType);
+
+
+ return dataGraph;
+
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java
new file mode 100644
index 0000000000..bd66949c89
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java
@@ -0,0 +1,184 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+import commonj.sdo.*;
+import commonj.sdo.helper.*;
+import commonj.sdo.impl.HelperProvider;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import java.util.HashMap;
+
+/**
+ * The follow test cases are based upon code snipets in the SDO specification.
+ * They are also implemented as working samples in the sample-sdo artifact
+ *
+ */
+public class JiraTestCases extends TestCase {
+
+ /**
+ * Bogus company namespace
+ */
+ public static final String COMPANY_NAMESPACE = "company.xsd";
+
+ /**
+ * previously defined XSD file used
+ */
+ public static final String COMPANY_XSD = "/company.xsd";
+
+ /**
+ * XML file containing DataGraph representing a company. This xml file
+ * conforms to the company model defined in 'Complete DataGraph for Company
+ * Example' section of the SDO specification
+ */
+ public static final String COMPANY_DATAGRAPH_XML = "/companyDataGraphGenerated.xml";
+
+ /**
+ * Generated DataGraph
+ * {@link org.apache.tuscany.samples.sdo.company.CreateCompany}
+ */
+ public static final String COMPANY_DATAOBJECT_XML = "/companyGenerated.xml";
+
+ /**
+ * Defines xsd resource contained within jar file for PurchaseOrder
+ * DataObject
+ */
+ public static final String PO_XSD_RESOURCE = "/po.xsd";
+
+ /**
+ * Defines xml resource contained within jar file that is used to populate
+ * PurchaseOrder DataObjects
+ */
+ public static final String PO_XML_RESOURCE = "/po.xml";
+
+ /**
+ * previously created XSD file used
+ */
+ public static final String LETTER_XSD = "/letter.xsd";
+
+ /**
+ * JIRA Details : Add a method to SDOUtil to return all Types associated
+ * with a specific URI
+ */
+ public void test_TUSCANY583() {
+ HelperContext hc = HelperProvider.getDefaultContext();
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ // define some types
+ try {
+ xsdHelper.define(getClass().getResourceAsStream(
+ PO_XSD_RESOURCE), null);
+
+ xsdHelper.define(getClass().getResourceAsStream(
+ COMPANY_XSD), null);
+
+ createDynamicType();
+
+ String[] expectedPoTypeNames = {"item", "Items",
+ "PurchaseOrderType", "quantity", "SKU", "USAddress"};
+
+ String[] expectedCompanyTypeNames = {"EmployeeType", "DepartmentType", "CompanyType"};
+
+ String[] expectedCustomerTypeNames = {"Customer"};
+
+ confirmTypes("http://www.example.com/PO", expectedPoTypeNames);
+ confirmTypes("company.xsd", expectedCompanyTypeNames);
+ confirmTypes("http://example.com/customer",
+ expectedCustomerTypeNames);
+
+ } catch (Exception e) {
+ fail("Unexpected error " + e.toString());
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Dynamically define customer Type
+ */
+ public static void createDynamicType() {
+ // get an instance of the type helper
+ TypeHelper typeH = TypeHelper.INSTANCE;
+ Type intType = typeH.getType("commonj.sdo", "Int");
+ Type stringType = typeH.getType("commonj.sdo", "String");
+
+ // create a new Type for Customers
+ DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo",
+ "Type");
+
+ customerType.set("uri", "http://example.com/customer");
+ customerType.set("name", "Customer");
+
+ // create a customer number property
+ DataObject custNumProperty = customerType.createDataObject("property");
+ custNumProperty.set("name", "custNum");
+ custNumProperty.set("type", intType);
+
+ // create a last name property
+ DataObject lastNameProperty = customerType.createDataObject("property");
+ lastNameProperty.set("name", "lastName");
+ lastNameProperty.set("type", stringType);
+
+ // create a first name property
+ DataObject firstNameProperty = customerType
+ .createDataObject("property");
+ firstNameProperty.set("name", "firstName");
+ firstNameProperty.set("type", stringType);
+
+ // now define the Customer type so that customers can be made
+ typeH.define(customerType);
+ }
+
+ private void confirmTypes(String uri, String[] expectedTypeNames) {
+ HelperContext hc = HelperProvider.getDefaultContext();
+ try {
+
+ List actualTypes = SDOUtil.getTypes(hc, uri);
+ assertNotNull("Testing that list of types for " + uri
+ + " is not null", actualTypes);
+
+ // test the number of Types
+ assertEquals("Testing number of types for " + uri,
+ expectedTypeNames.length, actualTypes.size());
+
+ // put into a HashMap for easy lookup
+ HashMap typeLookup = new HashMap();
+ for (int i = 0; i < actualTypes.size(); i++) {
+ Type type = (Type) actualTypes.get(i);
+ typeLookup.put(type.getName(), type);
+ }
+
+ // check that we have the same types
+ for (int i = 0; i < expectedTypeNames.length; i++) {
+ assertTrue("testing that type " + expectedTypeNames[i]
+ + "was returned for " + uri, typeLookup
+ .containsKey(expectedTypeNames[i]));
+ }
+
+ } catch (Exception e) {
+ fail("Exception caught comparing expected types to actual types for uri "
+ + uri + ":" + e.toString());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java
new file mode 100644
index 0000000000..360ffe3cab
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java
@@ -0,0 +1,220 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+
+public class MetadataInstancePropertiesTestCase extends TestCase
+{
+ private final String TEST_MODEL = "/TypePropertyMetadataInfo.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/metadata/retrievaltest";
+ private final String DYNAMIC_TEST_NAMESPACE = "http://www.example.com/metadata/dynamicmetadata";
+
+ private HelperContext helperContext;
+ private TypeHelper typeHelper;
+ private XSDHelper xsdHelper;
+ private DataFactory dataFactory;
+
+ public void testXSDTypeProperties()
+ {
+ // Note: We won't check the actual value of XSD instance properties yet since they're not defined
+ // in the SDO spec yet.
+
+ //displayInstanceProperties(TEST_NAMESPACE);
+
+ Type type = typeHelper.getType(TEST_NAMESPACE, "Example");
+ assertTrue(getInstanceProperty(type, "appinfo") != null);
+ assertTrue(getInstanceProperty(type, "foo") == null);
+
+ Property property = type.getProperty("number");
+ assertTrue(getInstanceProperty(property, "appinfo") != null);
+ assertTrue(getInstanceProperty(property, "foo") == null);
+
+ property = type.getProperty("Exampletype");
+ assertTrue(getInstanceProperty(property, "appinfo") != null);
+ assertTrue(getInstanceProperty(property, "foo") == null);
+
+ type = typeHelper.getType(TEST_NAMESPACE, "ExampleNumber");
+ assertTrue(getInstanceProperty(type, "appinfo") != null);
+ assertTrue(getInstanceProperty(type, "minInclusive") != null);
+ assertTrue(getInstanceProperty(type, "maxInclusive") != null);
+ assertTrue(getInstanceProperty(type, "foo") == null);
+
+ type = typeHelper.getType(TEST_NAMESPACE, "ExampleRating");
+ assertTrue(getInstanceProperty(type, "enumeration") != null);
+ assertTrue(getInstanceProperty(type, "foo") == null);
+
+ type = typeHelper.getType(TEST_NAMESPACE, "PhoneNumber");
+ assertTrue(getInstanceProperty(type, "appinfo") != null);
+ assertTrue(getInstanceProperty(type, "length") != null);
+ assertTrue(getInstanceProperty(type, "pattern") != null);
+ assertTrue(getInstanceProperty(type, "foo") == null);
+ }
+
+ public void testDynamicTypeProperties()
+ {
+ // Create dynamic model
+ Type intType = typeHelper.getType("commonj.sdo", "Int");
+ Type stringType = typeHelper.getType("commonj.sdo", "String");
+
+ Property openContentProperty = typeHelper.getOpenContentProperty("commonj.sdo/xml", "xmlElement");
+
+ // create a new Type for Customers
+ DataObject customerType = dataFactory.create("commonj.sdo", "Type");
+ customerType.set("uri", DYNAMIC_TEST_NAMESPACE);
+ customerType.set("name", "Customer");
+ customerType.set(openContentProperty, Boolean.TRUE);
+
+ // create a customer number property
+ DataObject custNumProperty = customerType.createDataObject("property");
+ custNumProperty.set("name", "custNum");
+ custNumProperty.set("type", intType);
+
+ // create a first name property
+ DataObject firstNameProperty =
+ customerType.createDataObject("property");
+ firstNameProperty.set("name", "firstName");
+ firstNameProperty.set("type", stringType);
+ firstNameProperty.set(openContentProperty, Boolean.FALSE);
+
+ // create a last name property
+ DataObject lastNameProperty = customerType.createDataObject("property");
+ lastNameProperty.set("name", "lastName");
+ lastNameProperty.set("type", stringType);
+
+ // now define the Customer type so that customers can be made
+ typeHelper.define(customerType);
+
+ //displayInstanceProperties(DYNAMIC_TEST_NAMESPACE);
+
+ Type type = typeHelper.getType(DYNAMIC_TEST_NAMESPACE, "Customer");
+ assertTrue(getInstanceProperty(type, "xmlElement") == openContentProperty);
+ assertTrue(type.get(openContentProperty) == Boolean.TRUE);
+ assertTrue(getInstanceProperty(type, "foo") == null);
+
+ Property property = type.getProperty("custNum");
+ assertTrue(getInstanceProperty(property, "xmlElement") == null);
+ assertTrue(getInstanceProperty(property, "foo") == null);
+
+ property = type.getProperty("firstName");
+ assertTrue(getInstanceProperty(property, "xmlElement") == openContentProperty);
+ assertTrue(property.get(openContentProperty) == Boolean.FALSE);
+ assertTrue(getInstanceProperty(property, "foo") == null);
+
+ property = type.getProperty("lastName");
+ assertTrue(getInstanceProperty(property, "xmlElement") == null);
+ assertTrue(getInstanceProperty(property, "foo") == null);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ helperContext = SDOUtil.createHelperContext();
+
+ typeHelper = helperContext.getTypeHelper();
+ xsdHelper = helperContext.getXSDHelper();
+ dataFactory = helperContext.getDataFactory();
+
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+
+ xsdHelper.define(inputStream, url.toString());
+ inputStream.close();
+ }
+
+ public Property getInstanceProperty(Type type, String propertyName)
+ {
+ return getInstanceProperty(type.getInstanceProperties(), propertyName);
+ }
+
+ public Property getInstanceProperty(Property property, String propertyName)
+ {
+ return getInstanceProperty(property.getInstanceProperties(), propertyName);
+ }
+
+ private Property getInstanceProperty(List instProps, String propertyName)
+ {
+ for (int i = 0; i < instProps.size(); i++)
+ {
+ Property prop = (Property)instProps.get(i);
+ if (propertyName.equals(prop.getName()))
+ return prop;
+ }
+ return null;
+ }
+
+ private void displayInstanceProperties(Type type)
+ {
+ System.out.println("Type's name: " + type.getName());
+ List instProps = type.getInstanceProperties();
+ for (int i = 0; i < instProps.size(); i++)
+ {
+ Property prop = (Property)instProps.get(i);
+ System.out.println("\tType's instance property name: " + prop.getName());
+ System.out.println("\tType's instance property value: \"" + type.get(prop) + "\"");
+ }
+ }
+
+ private void displayInstanceProperties(Property prop)
+ {
+ System.out.println("\tProperty's name: " + prop.getName());
+ List propsInstProps = prop.getInstanceProperties();
+ for (int j = 0; j < propsInstProps.size(); j++)
+ {
+ Property propsInstProp = (Property)propsInstProps.get(j);
+ System.out.println("\t\tProperty's instance property name: " + propsInstProp.getName());
+ System.out.println("\t\tProperty's instance property value: \"" + prop.get(propsInstProp) + "\"");
+ }
+ }
+
+ public void displayInstanceProperties(String namespace)
+ {
+ List types = SDOUtil.getTypes(helperContext, namespace);
+ for (int i = 0; i < types.size(); i++)
+ {
+ Type type = (Type)types.get(i);
+ displayInstanceProperties(type);
+ List properties = type.getProperties();
+ for (int j = 0; j < properties.size(); j++)
+ {
+ Property property = (Property)properties.get(j);
+ displayInstanceProperties(property);
+ }
+ System.out.println("**************************************");
+ }
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java
new file mode 100644
index 0000000000..806662a83c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java
@@ -0,0 +1,89 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import junit.framework.TestCase;
+
+
+public class MixedTypeTestCase extends TestCase {
+ private final String TEST_MODEL = "/mixed.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/mixed";
+ private final String TEST_DATA = "/mixed.xml";
+
+ /**
+ * Sequenced type SDO 2 test.
+ */
+ public void testSequencedType() throws IOException {
+ Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "MixedQuote");
+ DataObject quote = DataFactory.INSTANCE.create(quoteType);
+
+ Sequence sequence = quote.getSequence();
+
+ sequence.add("\n ");
+
+ quote.setString("symbol", "fbnt");
+
+ sequence.add("\n ");
+
+ quote.setString("companyName", "FlyByNightTechnology");
+
+ sequence.add("\n some text\n ");
+
+ DataObject child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+ sequence.add("\n more text\n ");
+
+ // quote.setBigDecimal("price", new BigDecimal("1000.0"));
+ sequence.add("price", new BigDecimal("1000.0"));
+
+ sequence.add("\n");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "mixedStockQuote", baos);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java
new file mode 100644
index 0000000000..69c8e447df
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class NeverStaleChangeSummaryTestCase extends TestCase {
+ private final String TEST_MODEL = "/simpleWithChangeSummary.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/simpleCS";
+
+ /**
+ * Simple ChangeSummary test.
+ */
+ public void testChangeSummary() throws Exception {
+ Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "RootQuote");
+ DataObject quote = DataFactory.INSTANCE.create(quoteType);
+
+ ChangeSummary cs = quote.getChangeSummary();
+
+ // Begin logging changes
+ //
+ cs.beginLogging();
+
+ DataObject child = quote.createDataObject("quotes");
+ cs.isCreated(child);
+ child = quote.createDataObject("quotes");
+ assertTrue(cs.isCreated(child));
+
+ // Stop logging changes and print the resulting data graph to stdout
+ //
+ cs.endLogging();
+
+ cs.isCreated(child);
+
+ cs.undoChanges();
+
+ assertFalse(cs.isCreated(child));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java
new file mode 100644
index 0000000000..0f2e09354c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java
@@ -0,0 +1,139 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.Iterator;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import junit.framework.TestCase;
+
+
+public class OpenTypeTestCase extends TestCase {
+ private HelperContext hc;
+ private TypeHelper th;
+ private XSDHelper xsdh;
+ private XMLHelper xmlh;
+ private DataFactory df;
+ private final String TEST_MODEL = "/open.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/open";
+ private final String TEST_DATA = "/open.xml";
+
+ /**
+ * Open content SDO 2 test.
+ */
+ public void testOpenType() throws IOException {
+ Type quoteType = th.getType(TEST_NAMESPACE, "OpenQuote");
+ DataObject quote = df.create(quoteType);
+
+ quote.setString("symbol", "s1");
+
+ for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) {
+ Property property = (Property) iter.next();
+ }
+
+ Property companyProperty = xsdh.getGlobalProperty(TEST_NAMESPACE, "company", true);
+ DataObject company = quote.createDataObject(companyProperty);
+ company.setString("name", "FlyByNightTechnology");
+
+ Property priceProperty = xsdh.getGlobalProperty(TEST_NAMESPACE, "price", true);
+ quote.getList(priceProperty).add(new BigDecimal("1000.0"));
+
+ for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) {
+ Property property = (Property) iter.next();
+ }
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ xmlh.save(quote, TEST_NAMESPACE, "openStockQuote", baos);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
+ }
+
+
+ public void testOpenType_Tuscany_396() throws IOException {
+ Type quoteType = th.getType(TEST_NAMESPACE, "OpenQuote2");
+ DataObject quote = df.create(quoteType);
+
+ Property priceProperty = xsdh.getGlobalProperty(TEST_NAMESPACE, "price", true);
+ // the importance of this is that the maxOccurs=1 attribute on the xsd:any
+ // allows is to use the !isMany getters and setters for open content
+ quote.set(priceProperty, new BigDecimal("1000.0"));
+
+ }
+
+ /**
+ * Although this behavior is not mandated by the SDO 2.1 specification it should be possible
+ * to demand-create DataObject properties by calling createDataObject(String name).
+ * The behavior should be the same as that specified in section 9.10 for parsing XML that has
+ * no types defined e.g. the property should be created as an open, sequenced type with many=true.
+ *
+ * See https://issues.apache.org/jira/browse/TUSCANY-1397 for more information.
+ *
+ * @throws Exception
+ */
+ public void testOnDemandCreateDataObject() throws Exception {
+ // define an open type with no properties
+ DataObject typeDef = df.create( "commonj.sdo", "Type" );
+ typeDef.set( "uri", TEST_NAMESPACE );
+ typeDef.set( "name", "testOnDemandCreateDataObjectType" );
+ typeDef.setBoolean( "open", true );
+ Type t = th.define( typeDef );
+
+ // create a DataObject that uses this type
+ DataObject testDO = df.create(t);
+
+ // create an on-demand property
+ DataObject foo = testDO.createDataObject( "foo" );
+ assertNotNull( "createDataObject() demand created a DataObject", foo );
+ assertTrue( "DataObject is open", foo.getType().isOpen() );
+ assertTrue( "DataObject is sequenced", foo.getType().isSequenced() );
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ hc = SDOUtil.createHelperContext();
+ th = hc.getTypeHelper();
+ xsdh = hc.getXSDHelper();
+ df = hc.getDataFactory();
+ xmlh = hc.getXMLHelper();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java
new file mode 100644
index 0000000000..eaec327007
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.tuscany.sdo.SDOPackage;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.helper.*;
+
+public class SchemaLocationTestCase extends TestCase {
+ private final String TEST_XML_DOCUMENT = "/SchemaLocationTestCase.xml";
+
+ /**
+ * This method will load an xml document consisting of a xsi:schemaLocation and xsi:noNamespaceSchemaLocation defined. It will then use the
+ * XMLDocument API to get and set the schemaLocation property.
+ *
+ * @throws IOException
+ */
+ public void testSchemaLocation() throws IOException {
+ // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
+ Map options = new HashMap();
+ options.put(SDOUtil.XML_LOAD_SCHEMA, Boolean.TRUE);
+ XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT), "whatever", options);
+ assertNotSame(doc.getRootObject().getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject());
+ }
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java
new file mode 100644
index 0000000000..b547f45d1c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java
@@ -0,0 +1,100 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XSDHelper;
+
+public class SequenceTestCase extends TestCase {
+ HelperContext hc;
+ Type type;
+ Property localA, choiceX, choiceY, localB, open;
+
+ String xml = ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ "";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+ hc.getXSDHelper().define(xml);
+ type = hc.getTypeHelper().getType("testNS", "Sequenced");
+ localA = type.getProperty("localA");
+ choiceX = type.getProperty("choiceX");
+ choiceY = type.getProperty("choiceY");
+ localB = type.getProperty("localB");
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ open = xsdHelper.getGlobalProperty("testNS", "open", true);
+ }
+
+ public void testSequenced() {
+ DataObject dataObject = hc.getDataFactory().create(type);
+ Sequence sequence = dataObject.getSequence();
+
+ sequence.add(choiceX, "x1");
+ sequence.add(0, localA, "a");
+ sequence.add(choiceY, "y1");
+ sequence.add(choiceX, "x2");
+ sequence.add(localB, "b");
+ sequence.add(open, "open");
+
+ List list = dataObject.getList(localA);
+ assertEquals(list.size(), 1);
+ assertEquals(list.get(0), "a");
+
+ assertEquals(dataObject.getString(localB), "b");
+
+ list = dataObject.getList(choiceX);
+ assertEquals(list.size(), 2);
+ assertEquals(list.get(0), "x1");
+ assertEquals(list.get(1), "x2");
+
+ list = dataObject.getList(choiceY);
+ assertEquals(list.size(), 1);
+ assertEquals(list.get(0), "y1");
+
+ list = dataObject.getList(open);
+ assertEquals(list.size(), 1);
+ assertEquals(list.get(0), "open");
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java
new file mode 100644
index 0000000000..7fe1196eb6
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java
@@ -0,0 +1,190 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+
+public class SerializeTypesTestCase extends TestCase {
+
+ HelperContext hc;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+ }
+
+ public void testSerializeTypesRoundTrip() throws Exception {
+ TypeHelper types = hc.getTypeHelper();
+ DataFactory factory = hc.getDataFactory();
+
+ Type intType = types.getType("commonj.sdo", "Int");
+ Type stringType = types.getType("commonj.sdo", "String");
+
+ // create a new Type for Addresses
+ DataObject addressType = factory.create("commonj.sdo", "Type");
+ addressType.set("uri", "http://example.com/address");
+ addressType.set("name", "Address");
+
+ // create a address street property
+ DataObject addrStProperty = addressType.createDataObject("property");
+ addrStProperty.set("name", "addrSt");
+ addrStProperty.set("type", stringType);
+
+ // create a new Type for Customers
+ DataObject customerType = factory.create("commonj.sdo", "Type");
+ customerType.set("uri", "http://example.com/customer");
+ customerType.set("name", "Customer");
+
+ // create a customer number property
+ DataObject custNumProperty = customerType.createDataObject("property");
+ custNumProperty.set("name", "custNum");
+ custNumProperty.set("type", intType);
+
+ // create a first name property
+ DataObject firstNameProperty = customerType.createDataObject("property");
+ firstNameProperty.set("name", "firstName");
+ firstNameProperty.set("type", stringType);
+
+ // create a last name property
+ DataObject lastNameProperty = customerType.createDataObject("property");
+ lastNameProperty.set("name", "lastName");
+ lastNameProperty.set("type", stringType);
+
+ // create an address property
+ DataObject addressProperty = customerType.createDataObject("property");
+ addressProperty.set("name", "address");
+ addressProperty.set("type", addressType);
+ addressProperty.setBoolean("containment", true);
+
+ // now define the Address and Customer type so that addresses and customers can be made
+ List types2define = new ArrayList();
+ types2define.add(addressType);
+ types2define.add(customerType);
+ List typesDefined = types.define(types2define);
+
+ // Create an empty data graph and add a root object, an instance of customerType
+ //
+
+ DataGraph dataGraph = SDOUtil.createDataGraph();
+ Type customerTypeDefined = (Type) typesDefined.get(1);
+ DataObject customer1 = dataGraph.createRootObject(customerTypeDefined);
+
+ customer1.setInt("custNum", 1);
+ customer1.set("firstName", "John");
+ customer1.set("lastName", "Adams");
+ DataObject address = customer1.createDataObject("address");
+ address.set("addrSt", "577 Airport Blvd");
+
+ SDOUtil.registerDataGraphTypes(dataGraph, typesDefined);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.saveDataGraph(dataGraph, baos, null);
+ //SDOUtil.saveDataGraph(dataGraph, System.out, null);
+
+ byte[] serialized = baos.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
+ DataGraph loadedDataGraph = SDOUtil.loadDataGraph(bais, null, hc);
+
+ DataObject loadedRootObject = loadedDataGraph.getRootObject();
+ assertNotSame(loadedRootObject.getType(), customer1.getType());
+
+ // EqualityHelper requires same Type
+ assertEquals(loadedRootObject.getInt("custNum"), customer1.getInt("custNum"));
+ assertEquals(loadedRootObject.get("firstName"), customer1.get("firstName"));
+ assertEquals(loadedRootObject.get("lastName"), customer1.get("lastName"));
+ DataObject loadedAddress = loadedRootObject.getDataObject("address");
+ assertEquals(loadedAddress.get("addrSt"), address.get("addrSt"));
+ }
+
+ private String xsdString =
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ "";
+
+
+ private String testString = "Hello World";
+ private String testStringInBase64 = "SGVsbG8gV29ybGQ=";
+ private String testStringInHex = "48656C6C6F20576F726C64";
+
+ public void testSerializeXSDBase64BinaryRoundTrip() throws Exception {
+ hc.getXSDHelper().define(xsdString);
+
+ DataObject typeTest = hc.getDataFactory().create("http://www.example.com/simple", "BytesTypeTest");
+ typeTest.setBytes("base64Binary", testString.getBytes());
+
+ String output = hc.getXMLHelper().save(typeTest, typeTest.getType().getURI(), "bytesTypeTest");
+
+ String startTag = "";
+ String endTag = "";
+ int start = output.indexOf(startTag) + startTag.length();
+ int end = output.indexOf(endTag);
+
+ String value = output.substring(start, end);
+ assertEquals(testStringInBase64, value);
+
+ XMLDocument xmlDoc = hc.getXMLHelper().load(output);
+ typeTest = xmlDoc.getRootObject();
+ assertEquals(testString, new String(typeTest.getBytes("base64Binary")));
+ }
+
+ public void testSerializeXSDHexBinaryRoundTrip() throws Exception {
+ hc.getXSDHelper().define(xsdString);
+
+ DataObject typeTest = hc.getDataFactory().create("http://www.example.com/simple", "BytesTypeTest");
+ typeTest.setBytes("hexBinary", testString.getBytes());
+
+ String output = hc.getXMLHelper().save(typeTest, typeTest.getType().getURI(), "bytesTypeTest");
+
+ String startTag = "";
+ String endTag = "";
+ int start = output.indexOf(startTag) + startTag.length();
+ int end = output.indexOf(endTag);
+
+ String value = output.substring(start, end);
+ assertEquals(testStringInHex, value);
+
+ XMLDocument xmlDoc = hc.getXMLHelper().load(output);
+ typeTest = xmlDoc.getRootObject();
+ assertEquals(testString, new String(typeTest.getBytes("hexBinary")));
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java
new file mode 100644
index 0000000000..36f038d779
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java
@@ -0,0 +1,71 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import junit.framework.TestCase;
+
+public class SimpleCopyTestCase extends TestCase {
+
+ private final String TEST_MODEL = "/simple.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/simple";
+ private final String QUOTE_XML = "/quote.xml";
+ private final String SHALLOW_QUOTE_XML = "/shallowquote.xml";
+
+ public void testSimpleCopy() throws IOException {
+ XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML));
+ DataObject sdo = doc.getRootObject();
+
+ DataObject copiedSdo = CopyHelper.INSTANCE.copyShallow(sdo);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos);
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML)));
+ assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML)));
+
+ copiedSdo = CopyHelper.INSTANCE.copy(sdo);
+
+ baos.reset();
+ XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos);
+ assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML)));
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML)));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java
new file mode 100644
index 0000000000..55aae9d396
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java
@@ -0,0 +1,123 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+
+public class SimpleDynamicTestCase extends TestCase {
+ private final String TEST_MODEL = "/simple.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/simple";
+ private final String QUOTE_XML = "/quote.xml";
+
+ //private final String TEST_MODEL2 = "/simple2.xsd";
+ //private final String TEST_NAMESPACE2 = "http://www.example.com/simple2";
+ //private final String QUOTE_XML2 = "/quote2.xml";
+
+ HelperContext hc;
+ TypeHelper th;
+
+ /**
+ * Simple Dynamic SDO 2 test.
+ */
+ public void testDynamic() throws IOException {
+ Type quoteType = th.getType(TEST_NAMESPACE, "Quote");
+ DataObject quote = hc.getDataFactory().create(quoteType);
+
+ quote.setString("symbol", "fbnt");
+ quote.setString("companyName", "FlyByNightTechnology");
+ quote.setBigDecimal("price", new BigDecimal("1000.0"));
+ quote.setBigDecimal("open1", new BigDecimal("1000.0"));
+ quote.setBigDecimal("high", new BigDecimal("1000.0"));
+ quote.setBigDecimal("low", new BigDecimal("1000.0"));
+ quote.setDouble("volume", 1000);
+ quote.setDouble("change1", 1000);
+
+ DataObject child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ hc.getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote", baos);
+
+ assertFalse(quote.isSet("undefined"));
+ assertSame(quote.get("undefined"), null);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML)));
+ }
+
+ /*
+ public void dontTestResolveXSDWithoutSchemaLocation() throws IOException {
+
+ URL url = getClass().getResource(TEST_MODEL2);
+ InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, null);
+ inputStream.close();
+
+ Type quote2Type = th.getType(TEST_NAMESPACE2, "Quote2");
+ DataObject quote2 = hc.getDataFactory().create(quote2Type);
+
+ quote2.setString("symbol", "fbnt");
+ quote2.setString("companyName", "FlyByNightTechnology");
+ quote2.setBigDecimal("price", new BigDecimal("1000.0"));
+ quote2.setBigDecimal("open1", new BigDecimal("1000.0"));
+ quote2.setBigDecimal("high", new BigDecimal("1000.0"));
+ quote2.setBigDecimal("low", new BigDecimal("1000.0"));
+ quote2.setDouble("volume", 1000);
+ quote2.setDouble("change1", 1000);
+
+ DataObject child = quote2.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ hc.getXMLHelper().save(quote2, TEST_NAMESPACE2, "stockQuote", System.out);
+ }
+ */
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hc = SDOUtil.createHelperContext();
+ th = hc.getTypeHelper();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+
+
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java
new file mode 100644
index 0000000000..c3fffa4f10
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java
@@ -0,0 +1,63 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.EqualityHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import junit.framework.TestCase;
+
+public class SimpleEqualityTestCase extends TestCase {
+ private static final String TEST_MODEL = "/simple.xsd";
+ private static final String QUOTE_XML = "/quote.xml";
+ private static final String SHALLOW_QUOTE_XML = "/shallowquote.xml";
+
+ public void testEquality() throws IOException {
+
+ XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML));
+ DataObject sdo = doc.getRootObject();
+
+ doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(SHALLOW_QUOTE_XML));
+ DataObject shallowSdo = doc.getRootObject();
+
+ boolean result = EqualityHelper.INSTANCE.equalShallow(sdo, shallowSdo);
+ assertTrue(result);
+
+ result = EqualityHelper.INSTANCE.equal(sdo, shallowSdo);
+ assertFalse(result);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java
new file mode 100644
index 0000000000..fb729ea125
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java
@@ -0,0 +1,83 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public final class SubstitutionValuesTestCase extends TestCase
+{
+ public void test() throws IOException
+ {
+ HelperContext hc = SDOUtil.createHelperContext();
+ URL url = getClass().getResource("/SubstitutionValues.xsd");
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ xsdHelper.define(url.openStream(), url.toString());
+
+ XMLHelper xmlHelper = hc.getXMLHelper();
+ DataObject loadedObject =
+ xmlHelper.load(getClass().getResourceAsStream("/substitutionValues1.xml")).getRootObject();
+ Type type = loadedObject.getType();
+ Sequence groupHeadSubstitutionValues = SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("groupHead"));
+ assertNotNull(groupHeadSubstitutionValues);
+ assertNull(SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("nonGroupHead")));
+
+ String nsURI = "http://www.apache.org/tuscany/SubstitutionValues";
+ DataObject createdObject = hc.getDataFactory().create(nsURI, "TestObject");
+ Property groupMemberProperty = xsdHelper.getGlobalProperty(nsURI, "groupMember", true);
+ createdObject.set(groupMemberProperty, groupHeadSubstitutionValues.getValue(0));
+ createdObject.setString("nonGroupHead", loadedObject.getString("nonGroupHead"));
+
+ assertTrue(hc.getEqualityHelper().equal(loadedObject, createdObject));
+
+ ByteArrayOutputStream loadedBaos = new ByteArrayOutputStream();
+ xmlHelper.save(loadedObject, nsURI, "testObject", loadedBaos);
+ ByteArrayOutputStream createdBaos = new ByteArrayOutputStream();
+ xmlHelper.save(createdObject, nsURI, "testObject", createdBaos);
+ assertTrue(
+ TestUtil.equalXmlFiles(
+ new ByteArrayInputStream(loadedBaos.toByteArray()),
+ new ByteArrayInputStream(createdBaos.toByteArray())));
+
+ loadedObject =
+ xmlHelper.load(getClass().getResourceAsStream("/substitutionValues2.xml")).getRootObject();
+ groupHeadSubstitutionValues = SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("groupHead"));
+
+ createdObject = hc.getDataFactory().create(nsURI, "TestObject");
+ createdObject.set("groupHead", groupHeadSubstitutionValues.getValue(0));
+ createdObject.setString("nonGroupHead", loadedObject.getString("nonGroupHead"));
+
+ assertTrue(hc.getEqualityHelper().equal(loadedObject, createdObject));
+ }
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
new file mode 100644
index 0000000000..a7ab3f954a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
@@ -0,0 +1,285 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class TestUtil
+{
+ private static void getAllNodes(NodeList nodeList, List nodes)
+ {
+ int length = nodeList.getLength();
+ if (length == 0)
+ {
+ return;
+ }
+
+ for (int i=0; i, but within
+ // the array exist the get(index), get(property), and get(path). Rather than
+ // referring to each of the three in every circumstance, the more compact array appears.
+
+ private static ConversionType TO_BOOLEAN = new ConversionType("getBoolean");
+ private static ConversionType TO_BYTE = new ConversionType("getByte");
+ private static ConversionType TO_CHAR = new ConversionType("getChar");
+ private static ConversionType TO_DOUBLE = new ConversionType("getDouble");
+ private static ConversionType TO_FLOAT = new ConversionType("getFloat");
+ private static ConversionType TO_INT = new ConversionType("getInt");
+ private static ConversionType TO_LONG = new ConversionType("getLong");
+ private static ConversionType TO_SHORT = new ConversionType("getShort");
+ private static ConversionType TO_BYTES = new ConversionType("getBytes");
+ private static ConversionType TO_BIGDECIMAL = new ConversionType("getBigDecimal");
+ private static ConversionType TO_BIGINTEGER = new ConversionType("getBigInteger");
+ private static ConversionType TO_DATAOBJECT = new ConversionType("getDataObject");
+ private static ConversionType TO_DATE = new ConversionType("getDate");
+ private static ConversionType TO_STRING = new ConversionType("getString");
+ private static ConversionType TO_LIST = new ConversionType("getList");
+ private static ConversionType TO_SEQUENCE = new ConversionType("getSequence");
+
+ private static GeneralComparator COMPARE_ANY;
+
+ // There will be several instances where a Property must be passed as a parameter. Have available the Type
+ // to call getProperty() as needed.
+
+ private static Type API_TEST_TYPE;
+
+ // The default constructor establishes each of the Method and Method[] variables.
+
+ public TypeConversionTestCase() throws Exception
+ {
+ COMPARE_ANY = new GeneralComparator();
+
+ // Populate the meta data for the test model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ XSDHelper.INSTANCE.define(inputStream, url.toString());
+ inputStream.close();
+
+ API_TEST_TYPE = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "APITest");
+ }
+
+ private static class ConversionType
+ {
+ // The following constants are used because the getMethod function requires an Class
+ // array describing the parameters to the functions.
+
+ private static final Class[] INT_CLASS_ARRAY = {int.class};
+ private static final Class[] PROPERTY_CLASS_ARRAY = {Property.class};
+ private static final Class[] STRING_CLASS_ARRAY = {String.class};
+
+ Method index_method;
+ Method property_method;
+ Method path_method;
+
+ public ConversionType (String method_name)
+ {
+ try
+ {
+ this.index_method = DataObject.class.getMethod(method_name, INT_CLASS_ARRAY);
+ this.property_method = DataObject.class.getMethod(method_name, PROPERTY_CLASS_ARRAY);
+ this.path_method = DataObject.class.getMethod(method_name, STRING_CLASS_ARRAY);
+ }
+ catch (NoSuchMethodException e)
+ {
+ this.index_method = null;
+ this.property_method = null;
+ this.path_method = null;
+ }
+ }
+
+ public Method getIndexMethod()
+ {
+ return this.index_method;
+ }
+
+ public Method getPropertyMethod()
+ {
+ return this.property_method;
+ }
+
+ public Method getPathMethod()
+ {
+ return this.path_method;
+ }
+ }
+
+ // Each instance of Test describes a convert-from type. The index, property and path parms
+ // will refer to the same field, which is a field of the convert-from type.
+
+ private static class Test
+ {
+ DataObject test_obj;
+ Object[] index_parm;
+ Object[] property_parm;
+ Object[] path_parm;
+ Object expected_value;
+ String from_type;
+
+ // The constructor prepares a test DataObject and determines how to access the field
+ // in three different ways - index, property, and path.
+
+ Test(String path, int index)
+ {
+ this.test_obj = DataFactory.INSTANCE.create(API_TEST_TYPE);
+ this.index_parm = new Object[] {new Integer(index)};
+ this.property_parm = new Object[] {API_TEST_TYPE.getProperty(path)};
+ this.path_parm = new Object[] {path};
+ this.expected_value = null;
+ }
+
+ // The initialize() function establishes the initial value of the test field.
+
+ public void initialize(Class type, String type_name, Object initial_value) throws Exception
+ {
+ Class[] classArray = {int.class, type};
+ Object[] initValueArray = new Object[] {this.index_parm[0], initial_value};
+
+ Method setter = DataObject.class.getMethod("set" + type_name, classArray);
+ setter.invoke(test_obj, initValueArray);
+ this.expected_value = initial_value;
+ this.from_type = type_name;
+ }
+
+ // Attempts the conversion to the specified type, using DataObject.get____().
+ // The get___() function can be called with an index, path, and property. attemptConversion()
+ // calls each of those three.
+
+ public void attemptConversion(ConversionType to_type) throws Exception
+ {
+ performConversion(to_type.getIndexMethod(), this.index_parm);
+ performConversion(to_type.getPathMethod(), this.path_parm);
+ performConversion(to_type.getPropertyMethod(), this.property_parm);
+ }
+
+ public void checkConversionException(ConversionType to_type, Class expected_exception) throws Exception
+ {
+ boolean index_err, path_err, property_err, consistency_err = false;
+
+ index_err = executeExceptionCase(to_type.getIndexMethod(), this.index_parm, expected_exception);
+ path_err = executeExceptionCase(to_type.getPathMethod(), this.path_parm, expected_exception);
+ property_err = executeExceptionCase(to_type.getPropertyMethod(), this.property_parm, expected_exception);
+
+ if (index_err != path_err || path_err != property_err)
+ consistency_err = true;
+ else if (index_err == false)
+ attemptConversion(to_type);
+
+ assertFalse("An exception inconsistency exists for " + to_type.getPathMethod().getName() + " when called "
+ + "for a " + this.from_type + " property.", consistency_err);
+ }
+
+ private void performConversion (Method convert, Object[] parm) throws Exception
+ {
+ try
+ {
+ assertTrue("Conversion did not yield expected value for " + convert.getName() + " on a " + this.from_type + " property.",
+ COMPARE_ANY.compare(convert.invoke(test_obj, parm), this.expected_value) == 0);
+ }
+ catch (Exception e)
+ {
+ Throwable cause = e.getCause();
+ if (cause == null)
+ {
+ System.err.println("An exception of type " + e.getClass() + " occurred while performing " + convert.getName()
+ + " on a " + this.from_type + " property.");
+ }
+ else
+ {
+ System.err.println("An exception of type " + cause.getClass() + " occurred while performing " + convert.getName()
+ + " on a " + this.from_type + " property.");
+ }
+
+ throw e;
+ }
+
+ }
+
+ private boolean executeExceptionCase (Method convert, Object[] parm, Class expected_exception) throws Exception
+ {
+ boolean exception_thrown = false;
+ try
+ {
+ convert.invoke(test_obj, parm);
+ }
+ catch (Exception e)
+ {
+ exception_thrown = true;
+ Throwable cause = e.getCause();
+ if (cause == null)
+ {
+ assertEquals("An unexpected exception occurred while performing " + convert.getName()
+ + " on a " + this.from_type + " property.", expected_exception, e.getClass());
+ }
+ else
+ {
+ assertEquals("An unexpected exception occurred while performing " + convert.getName()
+ + " on a " + this.from_type + " property.", expected_exception, cause.getClass());
+ }
+ }
+
+ return exception_thrown;
+ }
+ }
+
+ private static class GeneralComparator implements Comparator
+ {
+ public int compare(Object obj1, Object obj2)
+ {
+ if (obj1.getClass() == obj2.getClass())
+ {
+ if (obj1.equals(obj2))
+ return 0;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Date.class)
+ {
+ if (obj2.getClass() == String.class)
+ {
+ try
+ {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'H':'mm':'ss.S");
+
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+ obj2 = sdf.parse((String) obj2);
+
+ if (obj1.equals(obj2))
+ return 0;
+ }
+ catch (Exception e)
+ {
+ System.out.println(e.getMessage());
+ }
+
+ return 1;
+ }
+
+ else
+ {
+ Date temp = (Date) obj1;
+
+ return compare(new Long(temp.getTime()), obj2);
+ }
+
+ }
+
+ else if (obj2.getClass() == Date.class)
+ {
+ return compare(obj2, obj1);
+ }
+
+ else if (obj1.getClass() == Boolean.class)
+ {
+ Boolean temp = (Boolean) obj1;
+
+ if (temp.booleanValue())
+ {
+ if (obj2.toString().equalsIgnoreCase("true"))
+ return 0;
+ else
+ return 1;
+ }
+
+ else
+ {
+ if (obj2.toString().equalsIgnoreCase("true"))
+ return 1;
+ else
+ return 0;
+ }
+ }
+
+ else if (obj2.getClass() == Boolean.class)
+ return compare(obj2, obj1);
+
+ else if (obj1.getClass() == Byte.class || obj2.getClass() == Byte.class)
+ {
+ byte b1 = (Double.valueOf(obj1.toString())).byteValue();
+ byte b2 = (Double.valueOf(obj2.toString())).byteValue();
+
+ if (b1 == b2)
+ return 0;
+ else if (b1 < b2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass().toString().charAt(6) == '[')
+ {
+ long result = 0;
+ long multiplier = 1;
+
+ byte[] array = (byte[]) obj1;
+ for (int i = 0; i < array.length; i++)
+ {
+ result += array[array.length - i - 1] * multiplier;
+ multiplier *= 256;
+ }
+
+ return compare(obj2, new Long(result));
+ }
+
+ else if (obj2.getClass().toString().charAt(6) == '[')
+ {
+ return compare(obj2, obj1);
+ }
+
+ else if (obj1.getClass() == Short.class || obj2.getClass() == Short.class)
+ {
+ short s1 = (Double.valueOf(obj1.toString())).shortValue();
+ short s2 = (Double.valueOf(obj2.toString())).shortValue();
+
+ if (s1 == s2)
+ return 0;
+ else if (s1 < s2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Integer.class || obj2.getClass() == Integer.class)
+ {
+ int i1 = (Double.valueOf(obj1.toString())).intValue();
+ int i2 = (Double.valueOf(obj2.toString())).intValue();
+
+ if (i1 == i2)
+ return 0;
+ else if (i1 < i2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if ( obj1.getClass() == Long.class || obj2.getClass() == Long.class
+ || obj1.getClass() == BigInteger.class || obj2.getClass() == BigInteger.class)
+ {
+ long l1 = (Double.valueOf(obj1.toString())).longValue();
+ long l2 = (Double.valueOf(obj2.toString())).longValue();
+
+ if (l1 == l2)
+ return 0;
+ else if (l1 < l2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Float.class || obj2.getClass() == Float.class)
+ {
+ float f1 = (Double.valueOf(obj1.toString())).floatValue();
+ float f2 = (Double.valueOf(obj2.toString())).floatValue();
+
+ if (f1 == f2)
+ return 0;
+ else if (f1 < f2)
+ return -1;
+ else
+ return 1;
+ }
+
+ else if (obj1.getClass() == Double.class || obj2.getClass() == Double.class)
+ {
+ Double b1 = Double.valueOf(obj1.toString());
+ Double b2 = Double.valueOf(obj2.toString());
+
+ return b1.compareTo(b2);
+ }
+
+ else if (obj1.getClass() == BigDecimal.class || obj2.getClass() == BigDecimal.class)
+ {
+ BigDecimal b1 = new BigDecimal(obj1.toString());
+ BigDecimal b2 = new BigDecimal(obj2.toString());
+
+ return b1.compareTo(b2);
+ }
+
+ else
+ {
+ if (obj1.toString().equals(obj2.toString()))
+ return 0;
+ else
+ return 1;
+ }
+ }
+
+ }
+
+ /**********************************************************
+ * In the following test cases, several instances are commented out.
+ * For these cases, the test case currently fails. A JIRA issue (TUSCANY-581) has
+ * been opened to either correct the behavior (then uncomment the lines) or to
+ * alter the specification against which the test cases were designed (and then
+ * remove the lines - assuming the alteration is to remove stating the
+ * nature of the exception).
+ */
+
+ public void testBooleanConversion() throws Exception
+ {
+ Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX);
+
+ FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true));
+
+ FromBoolean.attemptConversion(TO_BOOLEAN);
+ FromBoolean.attemptConversion(TO_STRING);
+ }
+
+ public void testBooleanExceptions() throws Exception
+ {
+ Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX);
+
+ FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true));
+
+// FromBoolean.checkConversionException(TO_BYTE, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_DOUBLE, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_FLOAT, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_INT, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_LONG, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_SHORT, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_BYTES, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_BIGDECIMAL, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_BIGINTEGER, ClassCastException.class);
+ FromBoolean.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromBoolean.checkConversionException(TO_DATE, ClassCastException.class);
+ FromBoolean.checkConversionException(TO_LIST, ClassCastException.class);
+ FromBoolean.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testByteConversion() throws Exception
+ {
+ Test FromByte = new Test("byteVal", BYTE_VAL_INDEX);
+
+ FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127"));
+
+ FromByte.attemptConversion(TO_BYTE);
+ FromByte.attemptConversion(TO_DOUBLE);
+ FromByte.attemptConversion(TO_FLOAT);
+ FromByte.attemptConversion(TO_INT);
+ FromByte.attemptConversion(TO_LONG);
+ FromByte.attemptConversion(TO_SHORT);
+ FromByte.attemptConversion(TO_STRING);
+ }
+
+ public void testByteExceptions() throws Exception
+ {
+ Test FromByte = new Test("byteVal", BYTE_VAL_INDEX);
+
+ FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127"));
+
+// FromByte.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromByte.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromByte.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromByte.checkConversionException(TO_BIGDECIMAL, ClassCastException.class);
+ FromByte.checkConversionException(TO_BIGINTEGER, ClassCastException.class);
+ FromByte.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromByte.checkConversionException(TO_DATE, ClassCastException.class);
+ FromByte.checkConversionException(TO_LIST, ClassCastException.class);
+ FromByte.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testCharConversion() throws Exception
+ {
+ Test FromChar = new Test("charVal", CHAR_VAL_INDEX);
+
+ FromChar.initialize(char.class, "Char", new Character('?'));
+
+ FromChar.attemptConversion(TO_CHAR);
+ FromChar.attemptConversion(TO_STRING);
+ }
+
+ public void testCharExceptions() throws Exception
+ {
+ Test FromChar = new Test("charVal", CHAR_VAL_INDEX);
+
+ FromChar.initialize(char.class, "Char", new Character('?'));
+
+// FromChar.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromChar.checkConversionException(TO_BYTE, ClassCastException.class);
+// FromChar.checkConversionException(TO_DOUBLE, ClassCastException.class);
+// FromChar.checkConversionException(TO_FLOAT, ClassCastException.class);
+// FromChar.checkConversionException(TO_INT, ClassCastException.class);
+// FromChar.checkConversionException(TO_LONG, ClassCastException.class);
+// FromChar.checkConversionException(TO_SHORT, ClassCastException.class);
+// FromChar.checkConversionException(TO_BYTES, ClassCastException.class);
+// FromChar.checkConversionException(TO_BIGDECIMAL, ClassCastException.class);
+// FromChar.checkConversionException(TO_BIGINTEGER, ClassCastException.class);
+ FromChar.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromChar.checkConversionException(TO_DATE, ClassCastException.class);
+ FromChar.checkConversionException(TO_LIST, ClassCastException.class);
+ FromChar.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testDoubleConversion() throws Exception
+ {
+ Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX);
+
+ FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE));
+
+ FromDouble.attemptConversion(TO_BYTE);
+ FromDouble.attemptConversion(TO_DOUBLE);
+ FromDouble.attemptConversion(TO_FLOAT);
+ FromDouble.attemptConversion(TO_INT);
+ FromDouble.attemptConversion(TO_LONG);
+ FromDouble.attemptConversion(TO_SHORT);
+ FromDouble.attemptConversion(TO_BIGDECIMAL);
+ FromDouble.attemptConversion(TO_BIGINTEGER);
+ FromDouble.attemptConversion(TO_STRING);
+ }
+
+ public void testDoubleExceptions() throws Exception
+ {
+ Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX);
+
+ FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE));
+
+// FromDouble.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromDouble.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromDouble.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromDouble.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromDouble.checkConversionException(TO_DATE, ClassCastException.class);
+ FromDouble.checkConversionException(TO_LIST, ClassCastException.class);
+ FromDouble.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testFloatConversion() throws Exception
+ {
+ Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX);
+
+ FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE));
+
+ FromFloat.attemptConversion(TO_BYTE);
+ FromFloat.attemptConversion(TO_DOUBLE);
+ FromFloat.attemptConversion(TO_FLOAT);
+ FromFloat.attemptConversion(TO_INT);
+ FromFloat.attemptConversion(TO_LONG);
+ FromFloat.attemptConversion(TO_SHORT);
+ FromFloat.attemptConversion(TO_BIGDECIMAL);
+ FromFloat.attemptConversion(TO_BIGINTEGER);
+ FromFloat.attemptConversion(TO_STRING);
+ }
+
+ public void testFloatExceptions() throws Exception
+ {
+ Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX);
+
+ FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE));
+
+// FromFloat.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromFloat.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromFloat.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromFloat.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromFloat.checkConversionException(TO_DATE, ClassCastException.class);
+ FromFloat.checkConversionException(TO_LIST, ClassCastException.class);
+ FromFloat.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testIntConversion() throws Exception
+ {
+ Test FromInt = new Test("intVal", INT_VAL_INDEX);
+
+ FromInt.initialize(int.class, "Int", new Integer(5));
+
+ FromInt.attemptConversion(TO_BYTE);
+ FromInt.attemptConversion(TO_DOUBLE);
+ FromInt.attemptConversion(TO_FLOAT);
+ FromInt.attemptConversion(TO_INT);
+ FromInt.attemptConversion(TO_LONG);
+ FromInt.attemptConversion(TO_SHORT);
+ FromInt.attemptConversion(TO_BIGDECIMAL);
+ FromInt.attemptConversion(TO_BIGINTEGER);
+ FromInt.attemptConversion(TO_STRING);
+ }
+
+ public void testIntExceptions() throws Exception
+ {
+ Test FromInt = new Test("intVal", INT_VAL_INDEX);
+
+ FromInt.initialize(int.class, "Int", new Integer(5));
+
+// FromInt.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromInt.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromInt.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromInt.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromInt.checkConversionException(TO_DATE, ClassCastException.class);
+ FromInt.checkConversionException(TO_LIST, ClassCastException.class);
+ FromInt.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testLongConversion() throws Exception
+ {
+ Test FromLong = new Test("longVal", LONG_VAL_INDEX);
+
+ FromLong.initialize(long.class, "Long", new Long(7000L));
+
+ FromLong.attemptConversion(TO_BYTE);
+ FromLong.attemptConversion(TO_DOUBLE);
+ FromLong.attemptConversion(TO_FLOAT);
+ FromLong.attemptConversion(TO_INT);
+ FromLong.attemptConversion(TO_LONG);
+ FromLong.attemptConversion(TO_SHORT);
+ FromLong.attemptConversion(TO_BIGDECIMAL);
+ FromLong.attemptConversion(TO_BIGINTEGER);
+ FromLong.attemptConversion(TO_DATE);
+ FromLong.attemptConversion(TO_STRING);
+ }
+
+ public void testLongExceptions() throws Exception
+ {
+ Test FromLong = new Test("longVal", LONG_VAL_INDEX);
+
+ FromLong.initialize(long.class, "Long", new Long(7000L));
+
+// FromLong.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromLong.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromLong.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromLong.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+ FromLong.checkConversionException(TO_LIST, ClassCastException.class);
+ FromLong.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testShortConversion() throws Exception
+ {
+ Test FromShort = new Test("shortVal", SHORT_VAL_INDEX);
+
+ FromShort.initialize(short.class, "Short", new Short("-8000"));
+
+ FromShort.attemptConversion(TO_BYTE);
+ FromShort.attemptConversion(TO_DOUBLE);
+ FromShort.attemptConversion(TO_FLOAT);
+ FromShort.attemptConversion(TO_INT);
+ FromShort.attemptConversion(TO_LONG);
+ FromShort.attemptConversion(TO_SHORT);
+ FromShort.attemptConversion(TO_STRING);
+ }
+
+ public void testShortExceptions() throws Exception
+ {
+ Test FromShort = new Test("shortVal", SHORT_VAL_INDEX);
+
+ FromShort.initialize(short.class, "Short", new Short("-8000"));
+
+// FromShort.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromShort.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromShort.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromShort.checkConversionException(TO_BIGDECIMAL, ClassCastException.class);
+ FromShort.checkConversionException(TO_BIGINTEGER, ClassCastException.class);
+ FromShort.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromShort.checkConversionException(TO_DATE, ClassCastException.class);
+ FromShort.checkConversionException(TO_LIST, ClassCastException.class);
+ FromShort.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testStringConversion() throws Exception
+ {
+ Test FromString = new Test("stringVal", STRING_VAL_INDEX);
+
+ FromString.initialize(String.class, "String", "5");
+
+ FromString.attemptConversion(TO_BOOLEAN);
+ FromString.attemptConversion(TO_BYTE);
+ FromString.attemptConversion(TO_CHAR);
+ FromString.attemptConversion(TO_DOUBLE);
+ FromString.attemptConversion(TO_FLOAT);
+ FromString.attemptConversion(TO_INT);
+ FromString.attemptConversion(TO_LONG);
+ FromString.attemptConversion(TO_SHORT);
+ FromString.attemptConversion(TO_BIGDECIMAL);
+ FromString.attemptConversion(TO_BIGINTEGER);
+ FromString.attemptConversion(TO_STRING);
+
+ FromString.initialize(String.class, "String", "1999-07-25T8:50:14.33Z");
+ FromString.attemptConversion(TO_DATE);
+ }
+
+ public void testStringExceptions() throws Exception
+ {
+ Test FromString = new Test("stringVal", STRING_VAL_INDEX);
+
+ FromString.initialize(String.class, "String", "5");
+
+// FromString.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromString.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+ FromString.checkConversionException(TO_LIST, ClassCastException.class);
+ FromString.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testBytesConversion() throws Exception
+ {
+ Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX);
+
+ FromBytes.initialize(byte[].class, "Bytes", new byte[] {10,100});
+
+ FromBytes.attemptConversion(TO_BYTES);
+ FromBytes.attemptConversion(TO_BIGINTEGER);
+ }
+
+ public void testBytesExceptions() throws Exception
+ {
+ Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX);
+
+ FromBytes.initialize(byte[].class, "Bytes", new byte[] {10,100});
+
+// FromBytes.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromBytes.checkConversionException(TO_BYTE, ClassCastException.class);
+// FromBytes.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromBytes.checkConversionException(TO_DOUBLE, ClassCastException.class);
+// FromBytes.checkConversionException(TO_FLOAT, ClassCastException.class);
+// FromBytes.checkConversionException(TO_INT, ClassCastException.class);
+// FromBytes.checkConversionException(TO_LONG, ClassCastException.class);
+// FromBytes.checkConversionException(TO_SHORT, ClassCastException.class);
+// FromBytes.checkConversionException(TO_BIGDECIMAL, ClassCastException.class);
+ FromBytes.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromBytes.checkConversionException(TO_DATE, ClassCastException.class);
+// FromBytes.checkConversionException(TO_STRING, ClassCastException.class);
+ FromBytes.checkConversionException(TO_LIST, ClassCastException.class);
+ FromBytes.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testBigDecimalConversion() throws Exception
+ {
+ Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX);
+
+ FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3"));
+
+ FromBigDecimal.attemptConversion(TO_DOUBLE);
+ FromBigDecimal.attemptConversion(TO_FLOAT);
+ FromBigDecimal.attemptConversion(TO_INT);
+ FromBigDecimal.attemptConversion(TO_LONG);
+ FromBigDecimal.attemptConversion(TO_BIGDECIMAL);
+ FromBigDecimal.attemptConversion(TO_BIGINTEGER);
+ FromBigDecimal.attemptConversion(TO_STRING);
+ }
+
+ public void testBigDecimalExceptions() throws Exception
+ {
+ Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX);
+
+ FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3"));
+
+// FromBigDecimal.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromBigDecimal.checkConversionException(TO_BYTE, ClassCastException.class);
+// FromBigDecimal.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromBigDecimal.checkConversionException(TO_SHORT, ClassCastException.class);
+// FromBigDecimal.checkConversionException(TO_BYTES, ClassCastException.class);
+ FromBigDecimal.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromBigDecimal.checkConversionException(TO_DATE, ClassCastException.class);
+ FromBigDecimal.checkConversionException(TO_LIST, ClassCastException.class);
+ FromBigDecimal.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testBigIntegerConversion() throws Exception
+ {
+ Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX);
+
+ FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500"));
+
+ FromBigInteger.attemptConversion(TO_DOUBLE);
+ FromBigInteger.attemptConversion(TO_FLOAT);
+ FromBigInteger.attemptConversion(TO_INT);
+ FromBigInteger.attemptConversion(TO_LONG);
+ FromBigInteger.attemptConversion(TO_SHORT);
+ FromBigInteger.attemptConversion(TO_BYTES);
+ FromBigInteger.attemptConversion(TO_BIGDECIMAL);
+ FromBigInteger.attemptConversion(TO_BIGINTEGER);
+ FromBigInteger.attemptConversion(TO_STRING);
+ }
+
+ public void testBigIntegerExceptions() throws Exception
+ {
+ Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX);
+
+ FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500"));
+
+// FromBigInteger.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromBigInteger.checkConversionException(TO_BYTE, ClassCastException.class);
+// FromBigInteger.checkConversionException(TO_CHAR, ClassCastException.class);
+ FromBigInteger.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+// FromBigInteger.checkConversionException(TO_DATE, ClassCastException.class);
+ FromBigInteger.checkConversionException(TO_LIST, ClassCastException.class);
+ FromBigInteger.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testDateConversion() throws Exception
+ {
+ Test FromDate = new Test("dateVal", DATE_VAL_INDEX);
+
+ FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis()));
+
+ FromDate.attemptConversion(TO_LONG);
+ FromDate.attemptConversion(TO_DATE);
+ FromDate.attemptConversion(TO_STRING);
+ }
+
+ public void testDateExceptions() throws Exception
+ {
+ Test FromDate = new Test("dateVal", DATE_VAL_INDEX);
+
+ FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis()));
+
+// FromDate.checkConversionException(TO_BOOLEAN, ClassCastException.class);
+// FromDate.checkConversionException(TO_BYTE, ClassCastException.class);
+// FromDate.checkConversionException(TO_CHAR, ClassCastException.class);
+// FromDate.checkConversionException(TO_DOUBLE, ClassCastException.class);
+// FromDate.checkConversionException(TO_FLOAT, ClassCastException.class);
+// FromDate.checkConversionException(TO_INT, ClassCastException.class);
+// FromDate.checkConversionException(TO_SHORT, ClassCastException.class);
+// FromDate.checkConversionException(TO_BYTES, ClassCastException.class);
+// FromDate.checkConversionException(TO_BIGDECIMAL, ClassCastException.class);
+// FromDate.checkConversionException(TO_BIGINTEGER, ClassCastException.class);
+ FromDate.checkConversionException(TO_DATAOBJECT, ClassCastException.class);
+ FromDate.checkConversionException(TO_LIST, ClassCastException.class);
+ FromDate.checkConversionException(TO_SEQUENCE, ClassCastException.class);
+ }
+
+ public void testTuscany_836() {
+ if (System.getProperty("java.version").indexOf("1.4") == -1) {
+ // Work around a bug in SUN and IBM 1.4 JDKs
+ assertEquals(DataObjectUtil.getBigDecimal(new Long(Long.MAX_VALUE)).longValue(), Long.MAX_VALUE);
+ }
+ }
+}
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java
new file mode 100644
index 0000000000..8fad877d4b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java
@@ -0,0 +1,45 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.helper.HelperContext;
+
+
+public class TypeHelperTestCase extends TestCase {
+
+
+ HelperContext hc;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+ }
+
+ public void testGetType() {
+ assertTrue(hc.getTypeHelper().getType(List.class) == null );
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java
new file mode 100644
index 0000000000..f718a3f330
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java
@@ -0,0 +1,147 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataHelper;
+import commonj.sdo.helper.TypeHelper;
+
+public class TypeRoundTripTestCase extends TestCase {
+
+ private static class Test {
+ Type type;
+ String value;
+ Object obj;
+ Comparator comp;
+
+ Test(Type type, String value, Object obj) {
+ this.type = type;
+ this.value = value;
+ this.obj = obj;
+ }
+
+ Test(Type type, String value, Object obj, Comparator comp) {
+ this.type = type;
+ this.value = value;
+ this.obj = obj;
+ this.comp = comp;
+ }
+ }
+
+ private static class ListComparator implements Comparator {
+ public int compare(Object list1, Object list2) {
+ int answer = 1;
+ if (list1 instanceof List && list2 instanceof List) {
+ List l1 = (List) list1;
+ List l2 = (List) list2;
+ if (l1.size() == l2.size()) {
+ for (int n = 0; n < l1.size(); n++) {
+ if (!l1.get(n).equals(l2.get(n))) {
+ answer = 0;
+ break;
+ }
+ }
+ } else {
+ answer = 0;
+ }
+ } else {
+ answer = 0;
+ }
+ return answer;
+ }
+ }
+
+ private static class BytesComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ o2 = new String((byte[])o2);
+ if (o1.equals(o2)) return 1;
+ else return 0;
+ }
+ }
+
+ public void testTypeRoundTrips() throws Exception {
+ String URI = "commonj.sdo";
+ TypeHelper types = TypeHelper.INSTANCE;
+
+ List list = new ArrayList();
+ list.add("foo");
+ list.add("bar");
+ list.add("test");
+ Test[] tests = {
+ new Test(types.getType(URI, "Boolean"), "true", new Boolean(true)),
+ new Test(types.getType(URI, "Byte"), "49", new Byte((byte)49)),
+ new Test(types.getType(URI, "Bytes"), "666F6F", "foo", new BytesComparator()),
+ new Test(types.getType(URI, "Character"), "a", new Character('a')),
+ new Test(types.getType(URI, "Date"), "2005-12-12T12:12:12.012Z", DataHelper.INSTANCE.toDate("2005-12-12T12:12:12.012Z")),
+ new Test(types.getType(URI, "DateTime"), "2005-12-12T12:12:12zz", "2005-12-12T12:12:12zz"),
+ new Test(types.getType(URI, "Day"), "---12", "---12"),
+ new Test(types.getType(URI, "Decimal"), "12.12", new BigDecimal("12.12")),
+ new Test(types.getType(URI, "Double"), "12.12", new Double(12.12)),
+ new Test(types.getType(URI, "Duration"), "P5Y2M10D", "P5Y2M10D"),
+ new Test(types.getType(URI, "Float"), "12.12", new Float(12.12f)),
+ new Test(types.getType(URI, "Int"), "12", new Integer(12)),
+ new Test(types.getType(URI, "Integer"), "12", new BigInteger("12")),
+ new Test(types.getType(URI, "Long"), "12", new Long(12l)),
+ new Test(types.getType(URI, "Month"), "--12", "--12"),
+ new Test(types.getType(URI, "MonthDay"), "--12-12", "--12-12"),
+ new Test(types.getType(URI, "Object"), "test", "test"),
+ new Test(types.getType(URI, "Short"), "12", new Short((short)12)),
+ new Test(types.getType(URI, "String"), "test", "test"),
+ new Test(types.getType(URI, "Strings"), "foo bar test", list, new ListComparator()),
+ new Test(types.getType(URI, "Time"), "12:12:12.12", "12:12:12.12"),
+ new Test(types.getType(URI, "URI"), "http://example.org", "http://example.org"),
+ new Test(types.getType(URI, "Year"), "2005", "2005"),
+ new Test(types.getType(URI, "YearMonth"), "2005-12", "2005-12"),
+ new Test(types.getType(URI, "YearMonthDay"), "2005-12-12", "2005-12-12")
+ };
+
+ for (int n = 0; n < tests.length; n++) {
+ assertEquals(
+ SDOUtil.convertToString(tests[n].type, SDOUtil.createFromString(tests[n].type, tests[n].value)),
+ tests[n].value
+ );
+
+ //System.out.print(".");
+
+ if (tests[n].comp == null) {
+ assertEquals(
+ SDOUtil.createFromString(tests[n].type, SDOUtil.convertToString(tests[n].type, tests[n].obj)),
+ tests[n].obj
+ );
+ } else {
+ String o1 = SDOUtil.convertToString(tests[n].type, tests[n].obj);
+ Object o2 = SDOUtil.createFromString(tests[n].type, o1);
+ assertEquals(tests[n].comp.compare(tests[n].obj, o2), 1);
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java
new file mode 100644
index 0000000000..1cf59757ef
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java
@@ -0,0 +1,110 @@
+/**
+ *
+ * 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 commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+
+public class XMLDocumentTestCase extends TestCase
+{
+ private final String TEST_XML_DOCUMENT = "/XMLDocumentTestCase.xml";
+
+ // remember that NS1... and NS2... items are expected in sorted order by name
+ private final String NS1_SCHEMA_NAME = "http://www.example.com/open";
+
+ private final String NS1_SCHEMA_LOCATION = "/open.xsd";
+
+ private final String NS2_SCHEMA_NAME = "http://www.example.com/xmlDocumentSchemaLocation";
+
+ private final String NS2_SCHEMA_LOCATION = "/XMLDocumentSchemaLocation.xsd";
+
+ private final String NS_SET_NAME_LOCATION = "namespace schemaLocation";
+
+ //private final String NNS_SCHEMA_LOCATION = "http://www.example.com/XMLDocumentNoNamespaceSchemaLocation.xsd";
+ private final String NNS_SCHEMA_LOCATION = "/XMLDocumentNoNamespaceSchemaLocation.xsd";
+
+ private final String NNS_SET_LOCATION = "noNamespaceSchemaLocation";
+
+ /**
+ * This method will load an xml document consisting of a xsi:schemaLocation and
+ * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and
+ * set the schemaLocation property.
+ *
+ * @throws IOException
+ */
+ public void testSchemaLocation() throws IOException
+ {
+ // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
+ XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));
+
+ // get the schemaLocation
+ assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());
+
+ // set the schemaLocation to another value and test to see if the value was set
+ doc.setSchemaLocation(NS_SET_NAME_LOCATION);
+ assertEquals(NS_SET_NAME_LOCATION, doc.getSchemaLocation());
+
+ // remove the schemaLocation and ensure it returns null
+ doc.setSchemaLocation(null);
+ assertNull(doc.getSchemaLocation());
+
+ // ensure changes to schemaLocation have not changed noNamespaceSchemaLocation
+ assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());
+ }
+
+ /**
+ * This method will load an xml document consisting of a xsi:schemaLocation and
+ * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and
+ * set the noNamespaceSchemaLocation property.
+ *
+ * @throws IOException
+ */
+ public void testNoNamespaceSchemaLocation() throws IOException
+ {
+ // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
+ XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));
+
+ // get the noNamespaceSchemaLocation
+ assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());
+
+ // set the noNameSpaceSchemaLocation to another value and test to see if the value was set
+ doc.setNoNamespaceSchemaLocation(NNS_SET_LOCATION);
+ assertEquals(NNS_SET_LOCATION, doc.getNoNamespaceSchemaLocation());
+
+ // remove the noNameSpaceSchemaLocation and ensure it returns null
+ doc.setNoNamespaceSchemaLocation(null);
+ assertNull(doc.getNoNamespaceSchemaLocation());
+
+ // ensure changes to noNameSpaceSchemaLocation have not changed schemaLocation
+ assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java
new file mode 100644
index 0000000000..62daeeafdf
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java
@@ -0,0 +1,286 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class XMLHelperTestCase extends TestCase {
+
+ HelperContext hc;
+ private XSDHelper xsdHelper;
+ XMLHelper xmlh;
+ static final String INDENT = " ", MARGIN = " ", LINE_BREAK = "\n\n";
+
+ void define(String model) throws Exception {
+ // Populate the meta data for the test model
+ URL url = getClass().getResource(model);
+ xsdHelper.define(url.openStream(), url.toString());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+ xsdHelper = hc.getXSDHelper();
+ xmlh = hc.getXMLHelper();
+
+ // Populate the meta data for the test (Stock Quote) model
+ define("/simpleWithChangeSummary.xsd");
+
+ define("/SequenceChangeSummary.xsd");
+
+ define("/simple.xsd");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testLoadInputStreamStringObject() throws IOException {
+
+ }
+
+ protected final void format(String xml,String formatted) throws IOException {
+ XMLDocument doc = xmlh.load(getClass().getResource(xml).openStream());
+ Map options = new HashMap();
+
+ options.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT);
+ options.put(SDOHelper.XMLOptions.XML_SAVE_MARGIN, MARGIN);
+ options.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ // doc declares NameSpaces at root
+ xmlh.save(xmlh.createDocument(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName()), baos, options);
+ //xmlh.save(xmlh.createDocument(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName()), System.out, options);
+
+ assertEquals(formatted, baos.toString());
+ }
+
+ public void notestSaveXMLDocumentOutputStreamObject() throws IOException {
+ format("/simpleWithChangeSummary.xml",
+MARGIN+ "" +LINE_BREAK+
+MARGIN+ "" +LINE_BREAK+
+MARGIN+INDENT+ "FBNT" +LINE_BREAK+
+MARGIN+INDENT+ "FlyByNightTechnology" +LINE_BREAK+
+MARGIN+INDENT+ "999.0" +LINE_BREAK+
+MARGIN+INDENT+ "1000.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "1500.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "2500.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "3000.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "4000.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "fbnt" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "1000.0" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+ "");
+ }
+
+ public void notestSaveMixedOutputStreamObject() throws IOException {
+ format("/mixedChangeSummary.xml",
+MARGIN+ "" +LINE_BREAK+
+MARGIN+ "" +LINE_BREAK+
+INDENT+ "" +LINE_BREAK+
+INDENT+INDENT+ "fbnt" +LINE_BREAK+
+INDENT+INDENT+ "FlyByNightTechnology" +LINE_BREAK+
+INDENT+INDENT+ "1000.0" +LINE_BREAK+
+INDENT+INDENT+ "" +LINE_BREAK+
+INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+
+INDENT+INDENT+ "" +LINE_BREAK+
+INDENT+ "" +LINE_BREAK+
+"FBNTFlyByNightTechnology999.01500.02500.01000.03000.04000.0");
+ }
+
+ public void notestOpenMixedOutputStreamObject() throws IOException {
+ format("/openChangeSummary.xml",
+MARGIN+ "" +LINE_BREAK+
+MARGIN+ "" +LINE_BREAK+
+MARGIN+INDENT+ "FBNT" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "1500.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "2500.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "3000.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "4000.0" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "fbnt" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+
+MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+INDENT+ "" +LINE_BREAK+
+MARGIN+INDENT+ "" +LINE_BREAK+
+MARGIN+ "");
+ }
+
+ private String quoteXML =
+ "" +
+ "" +
+ "fbnt" +
+ "FlyByNightTechnology" +
+ "1000.0" +
+ "1000.0" +
+ "1000.0" +
+ "1000.0" +
+ "1000.0" +
+ "1000.0" +
+ "" +
+ "2000.0" +
+ "" +
+ "";
+
+ public void testLoadDOMSource() throws IOException, ParserConfigurationException, SAXException
+ {
+ DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
+ dFactory.setNamespaceAware(true);
+
+ DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
+ Document document = dBuilder.parse(new ByteArrayInputStream(quoteXML.getBytes()));
+
+ DOMSource domSource = new DOMSource(document);
+
+ XMLDocument xmlDocument = hc.getXMLHelper().load(domSource, null, null);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Map options = new HashMap();
+ options.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, "");
+ options.put(SDOHelper.XMLOptions.XML_SAVE_MARGIN, "");
+ options.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, "");
+
+ hc.getXMLHelper().save(xmlDocument, baos, options);
+
+ boolean isEqual = TestUtil.equalXmlFiles(new ByteArrayInputStream(quoteXML.getBytes()), new ByteArrayInputStream(baos.toByteArray()));
+ assertTrue(isEqual);
+ }
+
+ private String xsdStr =
+ "" +
+ "" +
+// "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "";
+
+ /**
+ * Test the scenario of serializing and deserializing an SDO with an undefined global SDO property
+ * In this scenario, the target XSD namespace doesn't have any global element defined
+ *
+ */
+ public void testDemandCreateRootObject() {
+ HelperContext hc = SDOUtil.createHelperContext();
+ hc.getXSDHelper().define(xsdStr);
+ DataObject quote = hc.getDataFactory().create("http://www.example.com/simple", "Quote");
+ quote.set("symbol", "abc");
+
+ String xmlStr = hc.getXMLHelper().save(quote, quote.getType().getURI(), "demandcreate");
+
+ XMLDocument doc = hc.getXMLHelper().load(xmlStr);
+ try {
+ doc.getRootObject();
+ }
+ catch (ClassCastException e) {
+ fail(e.toString());
+ }
+ }
+
+ /**
+ * This test case is similar to the testDemandCreateRootObject above. The only difference is
+ * the data model was created using SDO APIs instead of XSD.
+ *
+ */
+ public void testDemandCreateRootObject2() {
+ HelperContext hc1 = SDOUtil.createHelperContext();
+ Type stringType = hc1.getTypeHelper().getType("commonj.sdo", "String");
+
+ DataObject quoteTypeDef = hc1.getDataFactory().create("commonj.sdo", "Type");
+ quoteTypeDef.set("uri", "http://www.example.com/simple");
+ quoteTypeDef.set("name", "Quote");
+
+ DataObject symbolPropDef = quoteTypeDef.createDataObject("property");
+ symbolPropDef.set("name", "symbol");
+ symbolPropDef.set("type", stringType);
+
+ hc1.getTypeHelper().define(quoteTypeDef);
+
+ DataObject quote = hc1.getDataFactory().create("http://www.example.com/simple", "Quote");
+ quote.set("symbol", "abc");
+
+ String xmlStr = hc1.getXMLHelper().save(quote, quote.getType().getURI(), "demandcreate");
+
+ HelperContext hc2 = SDOUtil.createHelperContext();
+ hc2.getXSDHelper().define(xsdStr);
+
+ XMLDocument doc = hc2.getXMLHelper().load(xmlStr);
+ try {
+ doc.getRootObject();
+ }
+ catch (ClassCastException e) {
+ fail(e.toString());
+ }
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java
new file mode 100644
index 0000000000..ac8d04b683
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java
@@ -0,0 +1,192 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.SDOPackage;
+import org.apache.tuscany.sdo.api.SDOHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+import org.eclipse.emf.ecore.resource.Resource;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+public class XMLLoadOptionsTestCase extends TestCase {
+ XMLHelper xmlHelper;
+ Map options;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ //SDOUtil->SDOHelper->SDOHelperImpl->HelperContextImpl->XMLHelperImpl
+ public void testXMLOptionsSchema1() throws IOException{
+ final String TEST_XML_DOCUMENT = "/SchemaLocationTestCase.xml";
+
+ options = new HashMap();
+ options.put(SDOHelper.XMLOptions.XML_LOAD_SCHEMA, Boolean.TRUE);
+
+ final XMLHelper xmlHelper = SDOUtil.createHelperContext(true, options).getXMLHelper();
+
+ final XMLDocument xmlDoc = xmlHelper.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT), "whatever", null);
+ final DataObject root = xmlDoc.getRootObject();
+ assertNotSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject());
+ }
+
+// SDOUtil->SDOHelper->SDOHelperImpl->HelperContextImpl->XMLHelperImpl
+ public void testXMLOptionsSchema2() throws IOException{
+ final String TEST_XML_DOCUMENT = "/SchemaLocationTestCase.xml";
+
+ options = new HashMap();
+ options.put(SDOHelper.XMLOptions.XML_LOAD_SCHEMA, Boolean.FALSE);
+ final XMLHelper xmlHelper = SDOUtil.createHelperContext(true, options).getXMLHelper();
+ final XMLDocument xmlDoc = xmlHelper.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT), "whatever", null);
+ final DataObject root = xmlDoc.getRootObject();
+ assertSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject());
+ }
+
+ public void testXMLOptionsLax1() throws IOException{
+ options = new HashMap();
+ /*
+ * turn off default behaviour of tolerating malformed xml
+ * tests using this option and bad xml should demonstrate failure to load
+ */
+ options.put(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM, new Integer(0));
+ final HelperContext hc = SDOUtil.createHelperContext(true, options);
+ hc.getXSDHelper().define(
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ "");
+
+ final String xml=""+
+ ""+
+"";
+
+ /*
+ * this malformed xml will not load, as lax is forced OFF
+ * changing p:unqualifiedElement to unqualifiedElement
+ * will work */
+ try{
+ hc.getXMLHelper().load(new StringReader(xml), null, null);
+ fail();
+ } catch (final Resource.IOWrappedException featureNotFound) {
+ assertTrue(true);
+ }
+
+ }
+
+ public void testXMLOptionsLax2() throws IOException{
+ options = new HashMap();
+ /*
+ * turn on default behaviour of tolerating malformed xml
+ * tests using this option and bad xml will load
+ */
+ options.put(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM, new Integer(1));
+ final HelperContext hc = SDOUtil.createHelperContext(true, options);
+ hc.getXSDHelper().define(
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ "");
+
+ final String xml=""+
+ ""+
+ ""+
+ "";
+
+ /*
+ * this malformed xml will load, as lax is forced ON
+ */
+ assertNotNull(hc.getXMLHelper().load(new StringReader(xml), null, null).getRootObject());
+ }
+
+ //SDOUtil->SDOHelper->SDOHelperImpl->XMLStreamHelperImpl->XMLDocumentImpl
+ public void testXMLStreamHelper() throws IOException, XMLStreamException{
+ options = new HashMap();
+ /*
+ * turn off default behaviour of tolerating malformed xml
+ * tests using this option and bad xml will load
+ */
+ options.put(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM, new Integer(1));
+ final HelperContext hc = SDOUtil.createHelperContext(false, options);
+ final XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(hc);
+ hc.getXSDHelper().define(
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ ""+
+ "");
+
+ final String xml=""+
+ ""+
+ ""+
+ "";
+
+ final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ final XMLStreamReader reader1 = inputFactory.createXMLStreamReader(new StringReader(xml));
+ int event = reader1.getEventType();
+ while (!(event == XMLStreamConstants.START_ELEMENT)){
+ event = reader1.next();
+ }
+ final DataObject dataObject = streamHelper.loadObject(reader1);
+ /*
+ * this malformed xml will load, as lax is forced ON
+ */
+ assertNotNull(dataObject);
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java
new file mode 100644
index 0000000000..50c32a8023
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java
@@ -0,0 +1,147 @@
+/**
+ *
+ * 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.HashMap;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class XMLSaveOptionsTestCase extends TestCase {
+ HelperContext hc;
+ private XSDHelper xsdHelper;
+ XMLHelper xmlh;
+ XMLStreamHelper xmlStreamHelper;
+ static final String INDENT = " ", MARGIN = " ", LINE_BREAK = "\n";
+ String formatted1 = MARGIN+ "" +LINE_BREAK+
+ MARGIN+ "" +LINE_BREAK+
+ MARGIN+INDENT+ "FBNT" +LINE_BREAK+
+ MARGIN+INDENT+ "FlyByNightTechnology" +LINE_BREAK+
+ MARGIN+INDENT+ "999.0" +LINE_BREAK+
+ MARGIN+INDENT+ "1000.0" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "1500.0" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "2500.0" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "3000.0" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "4000.0" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "fbnt" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "1000.0" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "" +LINE_BREAK+
+ MARGIN+INDENT+ "" +LINE_BREAK+
+ MARGIN+ "";
+
+ String formatted2 =
+ //MARGIN+ "" +LINE_BREAK+
+ MARGIN+ "" +LINE_BREAK+
+ MARGIN+INDENT+"fbnt" +LINE_BREAK+
+ MARGIN+INDENT+"FlyByNightTechnology" +LINE_BREAK+
+ MARGIN+INDENT+"1000.0" +LINE_BREAK+
+ MARGIN+INDENT+"1000.0" +LINE_BREAK+
+ MARGIN+INDENT+"1000.0" +LINE_BREAK+
+ MARGIN+INDENT+"1000.0" +LINE_BREAK+
+ MARGIN+INDENT+"1000.0" +LINE_BREAK+
+ MARGIN+INDENT+"1000.0" +LINE_BREAK+
+ MARGIN+"" +LINE_BREAK;
+
+ void define(final String model) throws IOException {
+ // Populate the meta data for the test model
+ final URL url = getClass().getResource(model);
+ xsdHelper.define(url.openStream(), url.toString());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ //use XMLHelper
+ public void testSaveXMLDocumentXMLHelper() throws IOException {
+ final HashMap options = new HashMap();
+ options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT);
+ options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_MARGIN, MARGIN);
+ options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK);
+ hc = SDOUtil.createHelperContext(false,options);
+ xsdHelper = hc.getXSDHelper();
+ xmlh = hc.getXMLHelper();
+
+ // Populate the meta data for the test (Stock Quote) model
+ define("/simpleWithChangeSummary.xsd");
+ final XMLDocument doc = xmlh.load(getClass().getResource("/simpleWithChangeSummary.xml").openStream());
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ xmlh.save(xmlh.createDocument(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName()), baos, null);
+ assertEquals(formatted1, baos.toString());
+ }
+
+ //use XMLStreamHelper
+ public void testSaveXMLDocumentXMLStreamHelper() throws Exception {
+ final HashMap options = new HashMap();
+ options.put(SDOHelper.XMLOptions.XML_LOAD_SCHEMA, Boolean.FALSE);
+ options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT);
+ options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_MARGIN, MARGIN);
+ options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK);
+ final HelperContext hc = SDOUtil.createHelperContext(false, options);
+ xmlStreamHelper = SDOUtil.createXMLStreamHelper(hc);
+
+ xsdHelper = hc.getXSDHelper();
+ define("/simple.xsd");
+
+ final InputStream inStrm = getClass().getResourceAsStream("/shallowquote.xml");
+ final XMLDocument document = hc.getXMLHelper().load(inStrm, null, null);
+
+ final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ final StringWriter writer = new StringWriter();
+ final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
+
+ xmlStreamHelper.save(document, streamWriter, null);
+ streamWriter.flush();
+ assertEquals(formatted2, writer.toString());
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java
new file mode 100644
index 0000000000..ef701059c4
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * 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.*;
+import java.math.BigDecimal;
+import java.net.URL;
+
+import javax.xml.stream.*;
+
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.*;
+import commonj.sdo.helper.*;
+
+
+public class XMLStreamHelperPerformanceTestCase extends TestCase {
+ private final String TEST_MODEL = "/XMLStreamHelper.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/simple";
+
+ HelperContext hc;
+
+ /**
+ * Simple Dynamic SDO 2 test.
+ */
+ public void testDynamic() throws Exception {
+ final TypeHelper typeHelper = hc.getTypeHelper();
+ final Type quoteType = typeHelper.getType(TEST_NAMESPACE, "Quote");
+ final DataObject quote = hc.getDataFactory().create(quoteType);
+
+ quote.setString("symbol", "fbnt");
+ quote.setString("companyName", "FlyByNightTechnology");
+ quote.setBigDecimal("price", new BigDecimal("1000.0"));
+ quote.setBigDecimal("open1", new BigDecimal("1000.0"));
+ quote.setBigDecimal("high", new BigDecimal("1000.0"));
+ quote.setBigDecimal("low", new BigDecimal("1000.0"));
+ quote.setDouble("volume", 1000);
+ quote.setDouble("change1", 1000);
+
+ final DataObject child = quote.createDataObject("quotes");
+ child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+ final DataObject quote3 = quote.createDataObject("quotes3");
+ quote3.setString("symbol3", "IBM");
+ quote3.setString("company3", "IBM Corp.");
+
+ final XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(hc);
+ final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ final StringWriter writer = new StringWriter();
+ final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
+
+ final XMLDocument doc = hc.getXMLHelper().createDocument(quote, TEST_NAMESPACE, "stockQuote");
+ streamHelper.save(doc, streamWriter);
+ streamWriter.flush();
+ assertEquals("fbntFlyByNightTechnology1000.01000.01000.01000.01000.01000.02000.0IBMIBM Corp.",writer.toString());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+
+ // Populate the meta data for the test (Stock Quote) model
+ final URL url = getClass().getResource(TEST_MODEL);
+ final InputStream inputStream = url.openStream();
+ hc.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java
new file mode 100644
index 0000000000..35df4909ba
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java
@@ -0,0 +1,169 @@
+/**
+ *
+ * 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.*;
+import java.net.URL;
+import java.util.*;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.*;
+
+public class XMLStreamHelperTestCase extends TestCase {
+
+ private HelperContext hc;
+
+ private XMLStreamHelper streamHelper;
+
+ private XMLInputFactory inputFactory;
+
+ private XMLOutputFactory outputFactory;
+
+ private final QName module = new QName("http://foo", "module");
+
+ private final QName name = new QName("http://bar", "implementation.mock");
+
+ private final String testName = "foo-ext";
+ // private String testName = "complex";
+
+ private String xml;
+
+ // = "1Dummy2";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hc = SDOUtil.createHelperContext();
+ streamHelper = SDOUtil.createXMLStreamHelper(hc);
+
+ URL url = getClass().getClassLoader().getResource(testName + ".xsd");
+ hc.getXSDHelper().define(url.openStream(), url.toExternalForm());
+ url = getClass().getResource("/mixed.xsd");
+ hc.getXSDHelper().define(url.openStream(), url.toString());
+
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+
+ url = getClass().getClassLoader().getResource(testName + ".xml");
+ final InputStreamReader reader = new InputStreamReader(url.openStream());
+ final StringBuffer stringBuffer = new StringBuffer();
+ final char buf[] = new char[1024];
+ int size;
+ while ((size = reader.read(buf)) != -1) {
+ stringBuffer.append(buf, 0, size);
+ }
+ xml = stringBuffer.toString();
+ reader.close();
+ }
+
+ public void testLoadObject() throws Exception {
+ final XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
+ int event = reader.getEventType();
+ while (!((event == XMLStreamConstants.START_ELEMENT) && reader.getName().equals(name)) && reader.hasNext()) {
+ event = reader.next();
+ }
+ final DataObject dataObject = streamHelper.loadObject(reader);
+ Assert.assertNotNull(dataObject);
+ Assert.assertTrue(dataObject.getString("myAttr").equals("helloworld.HelloWorldImpl"));
+ }
+
+ public void testLoadUnqualifiedObject() throws Exception {
+ final XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml.replaceAll("bar:", "")));
+ int event = reader.getEventType();
+ while (!((event == XMLStreamConstants.START_ELEMENT) && reader.getName().getLocalPart().equals(name.getLocalPart())) && reader.hasNext()) {
+ event = reader.next();
+ }
+ final Map options = new HashMap();
+ options.put(XMLStreamHelper.OPTION_DEFAULT_ROOT_TYPE, hc.getTypeHelper().getType(name.getNamespaceURI(), "MockImplementation"));
+ final DataObject dataObject = streamHelper.loadObject(reader, options);
+ Assert.assertNotNull(dataObject);
+ Assert.assertTrue(dataObject.getString("myAttr").equals("helloworld.HelloWorldImpl"));
+ }
+
+ public void testLoad() throws Exception {
+ final XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
+ final XMLDocument document = streamHelper.load(reader);
+ Assert.assertNotNull(document);
+ Assert.assertEquals(document.getRootElementURI(), module.getNamespaceURI());
+ Assert.assertEquals(document.getRootElementName(), module.getLocalPart());
+ final DataObject moduleObject = document.getRootObject();
+ final List components = moduleObject.getList("component");
+ final DataObject componentObject = (DataObject) components.get(0);
+ final DataObject implObject = componentObject.getDataObject("implementation.mock");
+ Assert.assertTrue(implObject.getString("myAttr").equals("helloworld.HelloWorldImpl"));
+ }
+
+ public void testSave() throws XMLStreamException {
+ final XMLDocument document = hc.getXMLHelper().load(xml);
+ final StringWriter writer = new StringWriter();
+ final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
+ streamHelper.save(document, streamWriter);
+ streamWriter.flush();
+ final String xmlStr = writer.toString();
+ //System.out.println(xmlStr);
+ Assert.assertTrue(xmlStr.indexOf("myAttr=\"helloworld.HelloWorldImpl\"")!=-1);
+ }
+
+ public void testSaveObject() throws XMLStreamException {
+ final XMLDocument document = hc.getXMLHelper().load(xml);
+ final DataObject moduleObject = document.getRootObject();
+ final List components = moduleObject.getList("component");
+ final DataObject componentObject = (DataObject) components.get(0);
+ final StringWriter writer = new StringWriter();
+ final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
+ streamHelper.saveObject(componentObject, streamWriter);
+ streamWriter.flush();
+ Assert.assertTrue(writer.toString().indexOf("myAttr=\"helloworld.HelloWorldImpl\"")!=-1);
+ }
+
+ public void testSaveSequence() throws IOException, XMLStreamException {
+ final DataObject quote = hc.getDataFactory().create("http://www.example.com/mixed", "MixedQuote");
+ quote.setString("symbol", "fbnt");
+ quote.getSequence().addText(0, "testing");
+ quote.getSequence().addText("more testing");
+
+ final StringWriter writer = new StringWriter();
+ final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
+ streamHelper.saveObject(quote, streamWriter);
+ streamWriter.flush();
+ //System.out.println(writer);
+ assertTrue(writer.toString().indexOf("fbnt") != -1);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java
new file mode 100644
index 0000000000..63e92503c1
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java
@@ -0,0 +1,132 @@
+/**
+ *
+ * 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.SDOPackage;
+import org.apache.tuscany.sdo.api.SDOHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+public class XMLUnknownPropertiesTestCase extends TestCase {
+ XMLHelper xmlHelper;
+ Map options;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // SDOUtil->SDOHelper->SDOHelperImpl->HelperContextImpl->XMLHelperImpl
+ public void testOptionUnknownProperties() throws IOException {
+ options = new HashMap();
+ options.put(SDOHelper.XMLOptions.XML_LOAD_UNKNOWN_PROPERTIES, Boolean.TRUE);
+
+ final HelperContext hc = SDOUtil.createHelperContext(true);
+ hc
+ .getXSDHelper()
+ .define("" + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + "");
+
+ final String xml =
+ "" + ""
+ + "my test data0"
+ + "my test data1"
+ + "";
+
+ try {
+ final XMLDocument xmlDoc = hc.getXMLHelper().load(new StringReader(xml), null, options);// pass
+ // during
+ // invoke
+
+ final DataObject root = xmlDoc.getRootObject();
+ assertNotSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject());
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ hc.getXMLHelper().save(xmlDoc, baos, null);
+ assertTrue(baos.toString().indexOf("my test data0") != -1);
+ assertTrue(baos.toString().indexOf("my test data1") != -1);
+ } catch (final Exception e) {// (Resource.IOWrappedException featureNotFound)
+ e.printStackTrace();
+ }
+ }
+
+ public void testOptionUnknownProperties2() throws IOException {
+ options = new HashMap();
+ options.put(SDOHelper.XMLOptions.XML_LOAD_UNKNOWN_PROPERTIES, Boolean.FALSE);
+
+ final HelperContext hc = SDOUtil.createHelperContext(true);
+ hc
+ .getXSDHelper()
+ .define("" + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + "");
+
+ final String xml =
+ "" + ""
+ + "my test data"
+ + "my test data"
+ + "";
+
+ try {
+ final XMLDocument xmlDoc = hc.getXMLHelper().load(new StringReader(xml), null, options);// pass
+ // on
+ // invokation
+ final DataObject root = xmlDoc.getRootObject();
+ assertNotSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject());
+ fail();
+ } catch (final Exception e) {// (Resource.IOWrappedException featureNotFound)
+ // e.printStackTrace();
+ if (e.getMessage().indexOf("telem") != -1) {
+ Assert.assertTrue(true);
+ }
+ }
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
new file mode 100644
index 0000000000..45f92a73b2
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class XPathTestCase extends TestCase {
+
+ HelperContext hc;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+ }
+
+ private final String TEST_MODEL = "/xpath.xsd";
+ private final String XPATH_XML = "/xpath.xml";
+
+ /**
+ * The presence or absence of the @ sign in a path has no meaning.
+ * Properties are always matched by name independent of their XML representation.
+ * @throws IOException
+ */
+ public void testAtSignProperty() throws IOException {
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ XMLHelper xmlHelper = hc.getXMLHelper();
+
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ xsdHelper.define(inputStream, url.toString());
+
+ inputStream.close();
+
+ XMLDocument doc = xmlHelper.load(getClass().getResourceAsStream(XPATH_XML));
+
+ DataObject drive = doc.getRootObject();
+ DataObject folder1 = (DataObject) drive.get("Folder.1");
+ String value = folder1.getString("@creation_date");
+
+ assertEquals(value, "2000-03-23");
+ }
+
+ public void testListIndexing() throws Exception {
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ XMLHelper xmlHelper = hc.getXMLHelper();
+
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ xsdHelper.define(inputStream, url.toString());
+
+ inputStream.close();
+
+ XMLDocument doc = xmlHelper.load(getClass().getResourceAsStream(XPATH_XML));
+
+ DataObject root = doc.getRootObject();
+ DataObject folder1 = root.getDataObject("Folder[1]");
+ assertNotNull(folder1);
+ DataObject folder1a = root.getDataObject("Folder.0");
+ assertEquals(folder1, folder1a);
+ folder1a = root.getDataObject("Folder[FolderName=Folder00000000000]");
+ assertEquals(folder1, folder1a);
+
+ DataObject noFolder = null;
+
+ try {
+ noFolder = root.getDataObject("Folder[3]");
+ assertNull(noFolder);
+ } catch (Exception e) {
+ assertFalse("bad indexing generated exception" + e, true);
+ }
+
+ try {
+ noFolder = root.getDataObject("Folder[0]");
+ assertNull(noFolder);
+ } catch (Exception e) {
+ assertFalse("bad indexing generated exception" + e, true);
+ }
+
+ try {
+ noFolder = root.getDataObject("Folder.2");
+ assertNull(noFolder);
+ } catch (Exception e) {
+ assertFalse("bad indexing generated exception" + e, true);
+ }
+
+ try {
+ noFolder = root.getDataObject("Folder.-1");
+ assertNull(noFolder);
+ } catch (Exception e) {
+ assertFalse("bad indexing generated exception" + e, true);
+ }
+
+ noFolder = root.getDataObject("Folder[FolderName=foo]");
+ assertNull(noFolder);
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java
new file mode 100644
index 0000000000..b8d3402172
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java
@@ -0,0 +1,224 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import com.example.simple.SimpleFactory;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class XSDHelperTestCase extends TestCase {
+ private static final String TEST_MODEL = "/simple.xsd";
+ private static final String TEST_MODEL2 = "/xsdCorners.xsd";
+ private URL modelURL;
+ private URL xsdCornersURL;
+
+ HelperContext hc;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hc = SDOUtil.createHelperContext();
+ modelURL = getClass().getResource(TEST_MODEL);
+ xsdCornersURL = getClass().getResource(TEST_MODEL2);
+ }
+
+ public void testDefineWithLocation() throws IOException {
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ List types = xsdHelper.define(modelURL.openStream(), modelURL.toString());
+ assertEquals(2, types.size());
+ }
+
+ public void testDefineWithNoLocation() {
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ List types = xsdHelper.define(getClass().getResourceAsStream(TEST_MODEL), null);
+ assertEquals(2, types.size());
+ }
+
+ public void testDuplicateDefineWithLocation() throws IOException {
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ List types = xsdHelper.define(modelURL.openStream(), modelURL.toString());
+ assertEquals(2, types.size());
+
+ List types2 = xsdHelper.define(modelURL.openStream(), modelURL.toString());
+ assertEquals(0, types2.size());
+ }
+
+ public void testXSDGeneration_staticSDOType() throws IOException
+ {
+ //test for static sdo type. The test succeeds if the IllegalArgumentException is thrown
+ //by XSDHelper.generate method in which case the string xsd must be null;
+
+ SimpleFactory.INSTANCE.register(hc);
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ DataObject quoteSDO = (DataObject)SimpleFactory.INSTANCE.createQuote();
+ List typeList = new Vector();
+ typeList.add(quoteSDO.getType());
+ String xsd = null;
+
+ try
+ {
+ xsd = xsdHelper.generate(typeList);
+ xsd = "";
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+ assertNull(xsd);
+ }
+
+ public void testXSDGeneration_DynamicSDOType() throws IOException
+ {
+ //test for dynamic SDOs that have no XSD model. Here the testcase succeeds only if the
+ //xsd is generated by XSDHelper in which case xsd must not be null
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
+ quoteType.set("uri", "http://www.example.com/dynamic");
+ quoteType.set("name", "DynamicQuote");
+
+ DataObject aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "symbol");
+ aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "String"));
+
+ aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "price");
+ aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "Decimal"));
+
+ aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "volume");
+ aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "Double"));
+
+ TypeHelper.INSTANCE.define(quoteType);
+
+ Type dynamicQuoteType =
+ TypeHelper.INSTANCE.getType("http://www.example.com/dynamic", "DynamicQuote");
+
+ Vector types = new Vector();
+ types.add(dynamicQuoteType);
+ String xsd = null;
+
+ try
+ {
+ xsd = xsdHelper.generate(types);
+ //System.out.println(xsd);
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+ assertNotNull(xsd);
+
+ }
+
+ public void testXSDGeneration_DynamicWithNestedStaticSDOType() throws IOException
+ {
+ //testing static SDO with XSD Model being contained in a Dynamic SDO not having an XSD Model.
+ //the schema must be generated with imports / includes for the XSD corresponding to the static
+ //sdo types.
+ TypeHelper typeHelper = hc.getTypeHelper();
+ XSDHelper xsdHelper = hc.getXSDHelper();
+
+ SimpleFactory.INSTANCE.register(hc);
+ DataObject quoteSDO = (DataObject)SimpleFactory.INSTANCE.createQuote();
+
+
+ DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
+ quoteType.set("uri", "http://www.example.com/dynamic");
+ quoteType.set("name", "DynamicQuote");
+
+ DataObject aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "symbol");
+ aProperty.set("type", typeHelper.getType("commonj.sdo", "String"));
+
+ aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "price");
+ aProperty.set("type", typeHelper.getType("commonj.sdo", "Decimal"));
+
+ aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "volume");
+ aProperty.set("type", typeHelper.getType("commonj.sdo", "Double"));
+
+ aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "containedQuotes");
+ aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
+ aProperty.set("containment", new Boolean(true));
+
+ aProperty = quoteType.createDataObject("property");
+ aProperty.set("name", "referredQuotes");
+ aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
+
+ typeHelper.define(quoteType);
+
+ Type dynamicQuoteType =
+ typeHelper.getType("http://www.example.com/dynamic", "DynamicQuote");
+ Vector types = new Vector();
+ types.add(dynamicQuoteType);
+ String xsd = null;
+
+ try
+ {
+ Hashtable schemaLocationMap = new Hashtable();
+ schemaLocationMap.put("http://www.example.com/simple", "http://www.example.com/simple/xsd");
+ xsd = xsdHelper.generate(types, schemaLocationMap);
+ //System.out.println(xsd);
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+ assertNotNull(xsd);
+
+ }
+
+ public void testPrefixFromNSWithHyphenNumber() throws IOException {
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ xsdHelper.define(xsdCornersURL.openStream(), xsdCornersURL.toString());
+ DataFactory df = hc.getDataFactory();
+ DataObject root = df.create("http://www.example.com/simple-1", "A");
+ root.setString("a1", "a1s");
+ root.setString("a2", "a2s");
+
+ String doc = hc.getXMLHelper().save(root, "http://www.example.com/simple-1", "a");
+ assertTrue(doc.indexOf("xmlns:s1=\"http://www.example.com/simple-1\"") != -1);
+ }
+
+ public void testShortPrefix() throws IOException {
+ XSDHelper xsdHelper = hc.getXSDHelper();
+ URL url = getClass().getResource("/prefix.xsd");
+ xsdHelper.define(url.openStream(), url.toString());
+ DataObject cmd = hc.getDataFactory().create("http://soaassureservice.soabench.ibm.com", "CreateClaim");
+ cmd.setString("requestInfo", "cost");
+ String doc = hc.getXMLHelper().save(cmd, "http://soaassureservice.soabench.ibm.com", "createClaim");
+ assertTrue(doc.indexOf("xmlns:as=\"http://soaassureservice.soabench.ibm.com\"") != -1);
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java
new file mode 100644
index 0000000000..f369b340ed
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java
@@ -0,0 +1,123 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+public class XSDQNameTestCase extends TestCase {
+ private final String xsdString =
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ "";
+
+ private final String xmlString =
+ " " +
+ " " +
+ "fbnt " +
+ "simple:stockQuote " +
+ "";
+
+ private final String TEST_NAMESPACE = "http://www.example.com/simple";
+
+ HelperContext hc;
+ TypeHelper th;
+
+ /**
+ * Based on Spec 2.1, section 9.4.1, the return value of DataObject.get() on XSD QName property
+ * should be http://www.example.com/simple#stockQuote
+ * TODO add this to the CTS
+ *
+ * @throws IOException
+ */
+ public void testLoad() throws IOException {
+ XMLDocument doc = hc.getXMLHelper().load(xmlString);
+ DataObject root = doc.getRootObject();
+ assertEquals("http://www.example.com/simple#stockQuote", root.get("policy"));
+ }
+
+ /**
+ * After serialization, the value of XSD QName property in XML should be :stockQuote
+ */
+ public void testSave() throws IOException {
+ Type quoteType = th.getType(TEST_NAMESPACE, "Quote");
+ DataObject quote = hc.getDataFactory().create(quoteType);
+
+ quote.setString("symbol", "fbnt");
+ quote.set("policy", "http://www.example.com/simple#stockQuote");
+
+ String str = hc.getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote");
+ int start = str.indexOf("");
+ int end = str.indexOf("");
+ assertTrue(start != -1 && end != -1);
+
+ String policyValue = str.substring(start + "".length(), end);
+
+ Pattern pattern = Pattern.compile(".*:stockQuote"); // prefix can be anything
+
+ Matcher matcher = pattern.matcher(policyValue);
+ assertTrue(matcher.find());
+ }
+
+ /**
+ * Test the scenario that the xsd:QName property value contains non-existent namespace
+ */
+ public void testSave2() throws IOException {
+ Type quoteType = th.getType(TEST_NAMESPACE, "Quote");
+ DataObject quote = hc.getDataFactory().create(quoteType);
+
+ quote.setString("symbol", "fbnt");
+ quote.set("policy", "http://www.example.com/simple2#stockQuote");
+
+ String str = hc.getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote");
+
+ // Make sure the non-existent namespace was serialized
+ Pattern pattern = Pattern.compile(".*xmlns:.*=\"http://www.example.com/simple2\"");
+ Matcher matcher = pattern.matcher(str);
+ assertTrue(matcher.find());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hc = SDOUtil.createHelperContext();
+ th = hc.getTypeHelper();
+
+ hc.getXSDHelper().define(xsdString);
+ }
+}
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/SchemaLocationTestCase.xml b/sandbox/kgoodson/events/impl/src/test/resources/SchemaLocationTestCase.xml
new file mode 100644
index 0000000000..e13f45a877
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/SchemaLocationTestCase.xml
@@ -0,0 +1,33 @@
+
+
+
+ some string
+
+ another string
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/SequenceChangeSummary.xsd b/sandbox/kgoodson/events/impl/src/test/resources/SequenceChangeSummary.xsd
new file mode 100644
index 0000000000..dd3c2bc2dc
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/SequenceChangeSummary.xsd
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/SubstitutionValues.xsd b/sandbox/kgoodson/events/impl/src/test/resources/SubstitutionValues.xsd
new file mode 100644
index 0000000000..e977e6e631
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/SubstitutionValues.xsd
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/TypePropertyMetadataInfo.xsd b/sandbox/kgoodson/events/impl/src/test/resources/TypePropertyMetadataInfo.xsd
new file mode 100644
index 0000000000..b6d7841ec4
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/TypePropertyMetadataInfo.xsd
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ forest.jpg
+
+
+
+
+
+
+
+
+
+ getNumber
+ setNumber
+
+
+
+
+
+
+
+
+
+ getPhonetype
+ setPhonetype
+
+
+
+
+
+
+
+
+
+
+ This is the metadata for defining the ExampleNumber type.
+
+
+
+
+
+
+
+
+
+
+
+ This is the metadata for defining the PhoneNumber type.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd
new file mode 100644
index 0000000000..c2beb7708d
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentSchemaLocation.xsd b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentSchemaLocation.xsd
new file mode 100644
index 0000000000..0561eb555b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentSchemaLocation.xsd
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentTestCase.xml b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentTestCase.xml
new file mode 100644
index 0000000000..88160e0b2f
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentTestCase.xml
@@ -0,0 +1,14 @@
+
+ some string
+
+ another string
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLStreamHelper.xsd b/sandbox/kgoodson/events/impl/src/test/resources/XMLStreamHelper.xsd
new file mode 100644
index 0000000000..492f61b1d2
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLStreamHelper.xsd
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/anytype.xsd b/sandbox/kgoodson/events/impl/src/test/resources/anytype.xsd
new file mode 100644
index 0000000000..db10376360
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/anytype.xsd
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/api_test.xsd b/sandbox/kgoodson/events/impl/src/test/resources/api_test.xsd
new file mode 100644
index 0000000000..5238c72605
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/api_test.xsd
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/bank.xsd b/sandbox/kgoodson/events/impl/src/test/resources/bank.xsd
new file mode 100644
index 0000000000..a0cb7970b0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/bank.xsd
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/company.xsd b/sandbox/kgoodson/events/impl/src/test/resources/company.xsd
new file mode 100644
index 0000000000..18e99352be
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/company.xsd
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/containmenttest.xsd b/sandbox/kgoodson/events/impl/src/test/resources/containmenttest.xsd
new file mode 100644
index 0000000000..e576bc9b41
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/containmenttest.xsd
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/customer1.xml b/sandbox/kgoodson/events/impl/src/test/resources/customer1.xml
new file mode 100644
index 0000000000..5a29e30a3c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/customer1.xml
@@ -0,0 +1,8 @@
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/customer2.xml b/sandbox/kgoodson/events/impl/src/test/resources/customer2.xml
new file mode 100644
index 0000000000..e9ebb92677
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/customer2.xml
@@ -0,0 +1,8 @@
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/datatype.xsd b/sandbox/kgoodson/events/impl/src/test/resources/datatype.xsd
new file mode 100644
index 0000000000..05f55e0502
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/datatype.xsd
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/dotNames.xsd b/sandbox/kgoodson/events/impl/src/test/resources/dotNames.xsd
new file mode 100644
index 0000000000..a788b7b4f4
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/dotNames.xsd
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/expectedExceptions.xsd b/sandbox/kgoodson/events/impl/src/test/resources/expectedExceptions.xsd
new file mode 100644
index 0000000000..79f90d311d
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/expectedExceptions.xsd
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xml b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xml
new file mode 100644
index 0000000000..000909a52e
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xml
@@ -0,0 +1,9 @@
+
+
+ 1Dummy2
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xsd b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xsd
new file mode 100644
index 0000000000..4cdfd1bcd6
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xsd
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/foo.xsd b/sandbox/kgoodson/events/impl/src/test/resources/foo.xsd
new file mode 100644
index 0000000000..f50002ec3d
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/foo.xsd
@@ -0,0 +1,232 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixed.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xml
new file mode 100644
index 0000000000..42ff3a3a5b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xml
@@ -0,0 +1,9 @@
+
+
+ fbnt
+ FlyByNightTechnology
+ some text
+ 2000.0
+ more text
+ 1000.0
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixed.xsd b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xsd
new file mode 100644
index 0000000000..deee92e9c1
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xsd
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixed2.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixed2.xml
new file mode 100644
index 0000000000..d95d179478
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/mixed2.xml
@@ -0,0 +1,12 @@
+
+
+ fbnt
+ FlyByNightTechnology
+ some text
+ 2000.0
+ more text
+ 1000.0
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummary.xml
new file mode 100644
index 0000000000..49dbb89f38
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummary.xml
@@ -0,0 +1,11 @@
+
+
+
+ fbnt
+ FlyByNightTechnology
+ 1000.0
+
+ 2000.02000.99
+
+
+FBNTFlyByNightTechnology999.01500.02500.01000.03000.04000.0
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummaryUndone.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummaryUndone.xml
new file mode 100644
index 0000000000..d8097ace8b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummaryUndone.xml
@@ -0,0 +1,2 @@
+
+fbntFlyByNightTechnology1000.01500.02000.02000.992500.0
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixedopen.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixedopen.xml
new file mode 100644
index 0000000000..21a62ef2d0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/mixedopen.xml
@@ -0,0 +1,13 @@
+
+
+ fbnt
+ FlyByNightTechnology
+ some text
+ 2000.0
+ more text
+ 1000.0
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/names.xsd b/sandbox/kgoodson/events/impl/src/test/resources/names.xsd
new file mode 100644
index 0000000000..9096b2d62f
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/names.xsd
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open.xml b/sandbox/kgoodson/events/impl/src/test/resources/open.xml
new file mode 100644
index 0000000000..d4a5b92e0c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/open.xml
@@ -0,0 +1,8 @@
+
+
+ s1
+
+ FlyByNightTechnology
+
+ 1000.0
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open.xsd b/sandbox/kgoodson/events/impl/src/test/resources/open.xsd
new file mode 100644
index 0000000000..803c0a9cee
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/open.xsd
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open1any.xsd b/sandbox/kgoodson/events/impl/src/test/resources/open1any.xsd
new file mode 100644
index 0000000000..00efaef5e0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/open1any.xsd
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open2.xml b/sandbox/kgoodson/events/impl/src/test/resources/open2.xml
new file mode 100644
index 0000000000..ab992ccf74
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/open2.xml
@@ -0,0 +1,9 @@
+
+
+ s1
+
+ 1000.0
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummary.xml
new file mode 100644
index 0000000000..4ef2dc5948
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummary.xml
@@ -0,0 +1,24 @@
+
+
+ FBNT
+
+ 1500.0
+
+
+ 2500.0
+
+
+ 3000.0
+
+
+ 4000.0
+
+
+
+ fbnt
+
+ 2000.02000.99
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummaryUndone.xml b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummaryUndone.xml
new file mode 100644
index 0000000000..9883a3824a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummaryUndone.xml
@@ -0,0 +1,17 @@
+
+
+ fbnt
+
+ 1500.0
+
+
+ 2000.0
+
+ 2000.99
+
+
+
+ 2500.0
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/openContentProperty.xml b/sandbox/kgoodson/events/impl/src/test/resources/openContentProperty.xml
new file mode 100644
index 0000000000..03608365c0
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/openContentProperty.xml
@@ -0,0 +1,12 @@
+
+
+ s1
+
+ FlyByNightTechnology
+
+ 1000.0
+ 1100.0
+
+ mutual-1
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/po.xsd b/sandbox/kgoodson/events/impl/src/test/resources/po.xsd
new file mode 100644
index 0000000000..5c53ac1905
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/po.xsd
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/prefix.xsd b/sandbox/kgoodson/events/impl/src/test/resources/prefix.xsd
new file mode 100644
index 0000000000..af3d3283f5
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/prefix.xsd
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/quote.xml b/sandbox/kgoodson/events/impl/src/test/resources/quote.xml
new file mode 100644
index 0000000000..d7b5969e23
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/quote.xml
@@ -0,0 +1,14 @@
+
+
+ fbnt
+ FlyByNightTechnology
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+
+ 2000.0
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/quoteInSOAP.xml b/sandbox/kgoodson/events/impl/src/test/resources/quoteInSOAP.xml
new file mode 100644
index 0000000000..4ee083c90c
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/quoteInSOAP.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+ fbnt
+ FlyByNightTechnology
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+
+ 2000.0
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/sdoModel.xsd b/sandbox/kgoodson/events/impl/src/test/resources/sdoModel.xsd
new file mode 100644
index 0000000000..645b7b700a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/sdoModel.xsd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/sdoannotations.xsd b/sandbox/kgoodson/events/impl/src/test/resources/sdoannotations.xsd
new file mode 100644
index 0000000000..acdde2896a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/sdoannotations.xsd
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/sdotypes.xsd b/sandbox/kgoodson/events/impl/src/test/resources/sdotypes.xsd
new file mode 100644
index 0000000000..09c05bb671
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/sdotypes.xsd
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/shallowquote.xml b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote.xml
new file mode 100644
index 0000000000..a56f2fe2b7
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote.xml
@@ -0,0 +1,11 @@
+
+
+ fbnt
+ FlyByNightTechnology
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/shallowquote1.xml b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote1.xml
new file mode 100644
index 0000000000..5931826628
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote1.xml
@@ -0,0 +1,11 @@
+
+
+ fbnt
+ FlyByNightTechnology
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simple.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simple.xsd
new file mode 100644
index 0000000000..661259e57a
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/simple.xsd
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simple2.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simple2.xsd
new file mode 100644
index 0000000000..4be4bac95b
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/simple2.xsd
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simple3.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simple3.xsd
new file mode 100644
index 0000000000..6ff14a85d2
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/simple3.xsd
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xml
new file mode 100644
index 0000000000..d8ecf8f398
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xml
@@ -0,0 +1,28 @@
+
+
+ FBNT
+ FlyByNightTechnology
+ 999.0
+ 1000.0
+
+ 1500.0
+
+
+ 2500.0
+
+
+ 3000.0
+
+
+ 4000.0
+
+
+
+ fbnt
+ 1000.0
+
+ 2000.02000.99
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xsd
new file mode 100644
index 0000000000..1df0f69196
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xsd
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummaryUndone.xml b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummaryUndone.xml
new file mode 100644
index 0000000000..e2bbc56d2d
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummaryUndone.xml
@@ -0,0 +1,19 @@
+
+
+ fbnt
+ FlyByNightTechnology
+ 1000.0
+
+ 1500.0
+
+
+ 2000.0
+
+ 2000.99
+
+
+
+ 2500.0
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simplechangesummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/simplechangesummary.xml
new file mode 100644
index 0000000000..134e2f7de5
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/simplechangesummary.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ fbnt
+ FlyByNightTechnology
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+ 1000.0
+
+ 2000.0
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues1.xml b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues1.xml
new file mode 100644
index 0000000000..e891cb1073
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues1.xml
@@ -0,0 +1,5 @@
+
+
+ gm
+ ngh
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues2.xml b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues2.xml
new file mode 100644
index 0000000000..97033de147
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues2.xml
@@ -0,0 +1,5 @@
+
+
+ gh
+ ngh
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/xpath.xml b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xml
new file mode 100644
index 0000000000..3b3e2ffbb4
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xml
@@ -0,0 +1,51 @@
+
+
+
+ Folder00000000000
+ marries inflamed apprehended beseeming bustle
+
+
+
+ Brian
+ rw
+
+
+ Fuhwei
+ r
+
+
+
+
+ Hasan
+
+
+ Frank
+
+
+
+
+
+ Folder00000000011
+ Mumbling Jumblin Pink Panther goofs it up
+
+
+
+ Imad
+ x
+
+
+ Robbie
+ rwx
+
+
+
+
+ Yang
+
+
+ Art
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/xpath.xsd b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xsd
new file mode 100644
index 0000000000..0b817d425d
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xsd
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/impl/src/test/resources/xsdCorners.xsd b/sandbox/kgoodson/events/impl/src/test/resources/xsdCorners.xsd
new file mode 100644
index 0000000000..b62bfcae56
--- /dev/null
+++ b/sandbox/kgoodson/events/impl/src/test/resources/xsdCorners.xsd
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/lib/pom.xml b/sandbox/kgoodson/events/lib/pom.xml
new file mode 100644
index 0000000000..d9c7ee3aa6
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/pom.xml
@@ -0,0 +1,96 @@
+
+
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo
+ 1.0-incubating-SNAPSHOT
+
+ 4.0.0
+ tuscany-sdo-lib
+ Tuscany SDO Library
+ Tuscany SDO implementation library.
+ jar
+ kgoodson-sandbox
+
+
+
+ codehaus
+ Codehaus maven repository
+ http://repository.codehaus.org/
+
+
+
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo-api-r${specVersion}
+
+
+
+
+ stax
+ stax-api
+ 1.0.1
+ provided
+ true
+
+
+
+
+ junit
+ junit
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+ src/main/resources/META-INF/MANIFEST.MF
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+ ${basedir}/src/main/java/org/apache/tuscany/sdo/api/overview.html
+ 2.0
+ 1.4
+ org.apache.tuscany.sdo.lib:org.apache.tuscany.sdo.spi
+
+
+
+ package
+ package
+
+ jar
+
+
+
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/Event.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/Event.java
new file mode 100644
index 0000000000..e38b465df4
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/Event.java
@@ -0,0 +1,61 @@
+package org.apache.tuscany.sdo.api;
+
+import commonj.sdo.Property;
+
+public interface Event {
+
+ Object getNotifier();
+
+ int SET = 1;
+ int UNSET = 2;
+ int ADD = 3;
+ int REMOVE = 4;
+ int ADD_MANY = 5;
+ int REMOVE_MANY = 6;
+ int MOVE = 7;
+
+ int getEventType();
+
+
+ int NO_FEATURE_ID = -1;
+
+
+ Property getProperty();
+ Object getOldValue();
+ Object getNewValue();
+ boolean wasSet();
+ boolean isTouch();
+
+
+ int NO_INDEX = -1;
+ int getPosition();
+
+
+ boolean getOldBooleanValue();
+ boolean getNewBooleanValue();
+
+ byte getOldByteValue();
+ byte getNewByteValue();
+
+ char getOldCharValue();
+ char getNewCharValue();
+
+ double getOldDoubleValue();
+ double getNewDoubleValue();
+
+ float getOldFloatValue();
+ float getNewFloatValue();
+
+ int getOldIntValue();
+ int getNewIntValue();
+
+ long getOldLongValue();
+ long getNewLongValue();
+
+ short getOldShortValue();
+ short getNewShortValue();
+
+ String getOldStringValue();
+ String getNewStringValue();
+ }
+
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/EventListener.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/EventListener.java
new file mode 100644
index 0000000000..8bfdde46ba
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/EventListener.java
@@ -0,0 +1,8 @@
+package org.apache.tuscany.sdo.api;
+
+
+public interface EventListener {
+
+ public void eventNotification(Event e);
+
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java
new file mode 100644
index 0000000000..838770dc18
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java
@@ -0,0 +1,413 @@
+/**
+ *
+ * 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.api;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * This interface provides helper functions which are not included in the SDO specification itself.
+ * Use of the functions in this interface is recommended, instead of resorting to low-level
+ * implementation-specific APIs.
+ */
+public interface SDOHelper
+{
+ /**
+ * Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use
+ * of a new TypeHelper instance to provide scope for type definitions.
+ * @return the new HelperContext
+ * @see #createHelperContext(boolean)
+ */
+ public HelperContext createHelperContext();
+
+ /**
+ * Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use
+ * of a new TypeHelper instance to provide scope for type definitions.
+ * @param options Map of default XMLOptions
+ * @return the new HelperContext
+ * @see #createHelperContext(boolean)
+ */
+ public HelperContext createHelperContext(boolean extensibleNamespaces, Map options);
+
+ /**
+ * Create a HelperContext to provide access to a consistent set of Helpers which make use of a new
+ * TypeHelper instance to provide scope for type definitions.
+ * @param extensibleNamespaces true if the contents of a namespaces should be incrementally modifiable over time
+ * @return the new HelperContext
+ */
+ public HelperContext createHelperContext(boolean extensibleNamespaces);
+
+ /**
+ * create a non-extensible HelperContext with default load/save options
+ * @param options default load/save options from XMLOptions
+ * @return the new HelperContext
+ */
+ public HelperContext createHelperContext(Map options);
+
+ /**
+ * Creates an instance of a data type from the specified string.
+ * @param dataType a Type, for which isDataType() returns true, to instantiate.
+ * @param literal the string value of the dataType.
+ * @return an instance of the dataType.
+ * @see #convertToString(Type, Object)
+ */
+ public Object createFromString(Type dataType, String literal);
+
+ /**
+ * Converts an instance of a data type to a string literal representation.
+ * @param dataType the Type, for which isDataType() returns true, of the value to convert.
+ * @param value a value of the dataType.
+ * @return the string literal representation of the value.
+ * @see #createFromString(Type, String)
+ */
+ public String convertToString(Type dataType, Object value);
+
+ /**
+ * Create a DataObject wrapper for an instance of the specified dataType.
+ * This method is typically used to create a root object that can be passed to the XMLHelper.save()
+ * method when the root element to be serialized is an XMLSchema simpleType.
+ * @param dataType a Type for which isDataType() returns true.
+ * @param value the instance value.
+ * @return a DataObject wrapper for the specified value.
+ */
+ public DataObject createDataTypeWrapper(Type dataType, Object value);
+
+ /**
+ * Get the SDO built-in type corresponding to the specified XSD type in the XML Schema
+ * namespace ("http://www.w3.org/2001/XMLSchema").
+ * @param xsdType a type name in the XML Schema namespace.
+ * @return the SDO built-in Type corresponding to the specified XSD type.
+ */
+ public Type getXSDSDOType(String xsdType);
+
+ /**
+ * Gets the Sequence corresponding to the specified substitutable Property of the specified DataObject.
+ * @param dataObject the data object.
+ * @param head a substitution group head property.
+ * @return the Sequence corresponding to the specified substitutable Property of the specified DataObject or
+ * null if the specified Property isn't a substitution head.
+ */
+ public Sequence getSubstitutionValues(DataObject dataObject, Property head);
+
+ /**
+ * Get the SDO built-in type corresponding to the specified Java instanceClass.
+ * @param javaClass the Java instanceClass of the type.
+ * @return the SDO built-in Type corresponding to the specified instanceClass.
+ */
+ public Type getJavaSDOType(Class javaClass);
+
+ /**
+ * Return whether at least one value is required for a valid instance of the specified property.
+ * @param the property in question.
+ * @return true if the property is required.
+ */
+ public boolean isRequired(Property property);
+
+ /**
+ * Return the upper bound of the specified property or -1 if unbounded.
+ * @param the property in question.
+ * @return the upper bound.
+ */
+ public int getUpperBound(Property property);
+
+ /**
+ * Returns whether the Property is many-valued given the specified context.
+ * @param property The Property in question
+ * @param context The context to check whether the specified Property is many-valued
+ * @return true if the Property is many-valued given the specified context.
+ */
+ public boolean isMany(Property property, DataObject context);
+
+ /**
+ * Create an empty data graph.
+ * @return the new data graph instance.
+ */
+ public DataGraph createDataGraph();
+
+ /**
+ * Set the root object of a data graph.
+ * @param dataGraph the data graph in which to set the root object.
+ * @param rootObject the root object.
+ */
+ public void setRootObject(DataGraph dataGraph, DataObject rootObject);
+
+ /**
+ * Load a serialized data graph from the specified insputStream.
+ *
+ * @param inputStream the inputStream of the data graph.
+ * @param options loader control options, or null.
+ * @param hc the HelperContext in which to register deserialized Types and to find Types when
+ * creating DataObject instances, or null for default HelperContext.
+ * @return the de-serialized data graph.
+ * @throws IOException
+ */
+ public DataGraph loadDataGraph(InputStream inputStream, Map options, HelperContext hc) throws IOException;
+
+ /**
+ * Serialize the specified data graph to the specified outputStream.
+ * @param dataGraph the data graph to save.
+ * @param outputStream the outputStream for the data graph.
+ * @param options serializer control options, or null.
+ * @throws IOException
+ */
+ public void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options) throws IOException;
+
+ /**
+ * Registers the specified {@link Type type}(s) to be serialized along with
+ * the {@link DataObject data object}(s) in the graph. For example, the list of types returned from
+ * {@link TypeHelper#define} can be registered with this method, allowing deserialization of
+ * instances of a dynamically defined model.
+ * @param dataGraph the DataGraph in which to register the specified type(s).
+ * @param types a list containing the type(s) to be registered (TBD or null to automatically register all
+ * types used by the objects in the DataGraph).
+ */
+ public void registerDataGraphTypes(DataGraph dataGraph, List/*Type*/types);
+
+ /**
+ * Create a new cross scope CopyHelper.
+ * @param hc the HelperContext containing the Types to use to create the copy objects.
+ * @return the new CopyHelper.
+ */
+ public CopyHelper createCrossScopeCopyHelper(HelperContext targetScope);
+
+
+ /**
+ * Create a new XMLStreamHelper, with visibility to types in the specified HelperContext scope.
+ * @param hc the HelperContext to use for locating types.
+ * @return the new XMLStreamHelper.
+ */
+ public XMLStreamHelper createXMLStreamHelper(HelperContext hc);
+
+ /**
+ * Create a new ObjectInputStream in the specifice HelperContext scope.
+ * @param inputStream the inputStream with which to create the ObjectInputStream.
+ * @param helperContext the HelperContext scope.
+ * @return the new ObjectInputStream.
+ */
+ public ObjectInputStream createObjectInputStream(InputStream inputStream, HelperContext helperContext) throws IOException;
+
+ /**
+ * Create a new ObjectOutputStream in the specifice HelperContext scope.
+ * @param outputStream the outputStream with which to create the ObjectOutputStream.
+ * @param helperContext the HelperContext scope.
+ * @return the new ObjectOutputStream.
+ */
+ public ObjectOutputStream createObjectOutputStream(OutputStream outputStream, HelperContext helperContext) throws IOException;
+
+ /**
+ * Gets all of the types associated with a uri.
+ * @param hc the HelperContext to use for locating types.
+ * @param uri the URI of the Types
+ * @return a List containing instances of Type, null if uri is not found.
+ */
+ public List getTypes(HelperContext hc, String uri);
+
+ /**
+ * Gets the open content subset of the specified DataObject's instance properties.
+ * @param dataObject the DataObject instance
+ * @return a List containing any open content properties of the DataObject
+ */
+ public List getOpenContentProperties(DataObject dataObject);
+
+ /**
+ * Return true if the specified type is a special DocumentRoot Type.
+ * @param type the Type in question
+ * @return true if type is a DocumentRoot
+ */
+ public boolean isDocumentRoot(Type type);
+
+ /**
+ * Return an XPath from the containment root to the specified DataObject.
+ * @param dataObject a DataObject
+ * @return the XPath from the containment root.
+ */
+ public String getXPath(DataObject dataObject);
+
+ /**
+ * Gets a MetaDataBuilder which can be used to programatically create SDO Types and Properties.
+ * @return a MetaDataBuilder instance
+ */
+ public MetaDataBuilder getMetaDataBuilder();
+
+ /**
+ * This interface provides methods which can be used to programatically create SDO Types and Properties.
+ * It provides a lower level and more efficient API then the DataObject-based one of TypeHelper.define().
+ */
+ public interface MetaDataBuilder
+ {
+
+ /**
+ * Create a Type in the specified TypeHelper scope.
+ * @return the new Type.
+ */
+ public Type createType(HelperContext hc, String uri, String name, boolean isDataType);
+
+ /**
+ * Add a baseType to the specified type.
+ */
+ public void addBaseType(Type type, Type baseType);
+
+ /**
+ * Add an aliasName to the specified type.
+ */
+ public void addAliasName(Type type, String aliasName);
+
+ /**
+ * Set the isOpen value of the specified type.
+ */
+ public void setOpen(Type type, boolean isOpen);
+
+ /**
+ * Set the isSequenced value of the specified type.
+ */
+ public void setSequenced(Type type, boolean isSequenced);
+
+ /**
+ * Set the isAbstract value of the specified type.
+ */
+ public void setAbstract(Type type, boolean isAbstract);
+
+ /**
+ * Set the isAbstract value of the specified type.
+ */
+ public void setJavaClassName(Type type, String javaClassName);
+
+ /**
+ * Create a new property in the specified containingType.
+ */
+ public Property createProperty(Type containingType, String name, Type propertyType);
+
+ /**
+ * Set a SDO property to become an XSD element or attribute
+ */
+ public void setPropertyXMLKind(Property property, boolean isXmlElement);
+
+ /**
+ * Create a new open content property in the specified TypeHelper scope.
+ */
+ public Property createOpenContentProperty(HelperContext hc, String uri, String name, Type type);
+
+ /**
+ * Add an aliasName to the specified property.
+ */
+ public void addAliasName(Property property, String aliasName);
+
+ /**
+ * Set the isMany value of the specified property.
+ */
+ public void setMany(Property property, boolean isMany);
+
+ /**
+ * Set the isContainment value of the specified property.
+ */
+ public void setContainment(Property property, boolean isContainment);
+
+ /**
+ * Set the default value of the specified property.
+ */
+ public void setDefault(Property property, String defaultValue);
+
+ /**
+ * Set the isReadOnly value of the specified property.
+ */
+ public void setReadOnly(Property property, boolean isReadOnly);
+
+ /**
+ * Set the opposite value of the specified property.
+ */
+ public void setOpposite(Property property, Property opposite);
+
+ /**
+ * Add an instance property to the specified type.
+ */
+ public void addTypeInstanceProperty(Type definedType, Property instanceProperty, Object value);
+
+ /**
+ * Add anf instance property to the specified property.
+ */
+ public void addPropertyInstanceProperty(Property definedProperty, Property instanceProperty, Object value);
+ }
+
+ /**
+ * This interface contains options that can be passed to the XMLHelper load() and save() methods.
+ */
+ public interface XMLOptions
+ {
+ /**
+ * Line Break String such as "\n", "\r\n", "\r" and "", absence/null is the default (line.separator System Property)
+ */
+ final String XML_SAVE_LINE_BREAK = "LineBreak";
+
+ /**
+ * Indent String such as "\t", "", etc. absence/null is the default (" ")
+ */
+ final String XML_SAVE_INDENT = "indent";
+
+ /**
+ * Margin String such as " ", "\t\t", etc. Absence/null/"" is the default (no margin)
+ */
+ final String XML_SAVE_MARGIN = "margin";
+
+ /**
+ * Attribute formatting that exceeds the specified width as Integer will cause a line break so that formatting will continue indented on the next line
+ */
+ final String XML_SAVE_LINE_WIDTH = "LINE_WIDTH";
+
+ /**
+ * Boolean to save a doctype declaration
+ */
+ final String XML_SAVE_DOCTYPE = "SAVE_DOCTYPE";
+
+ /**
+ * Boolean to process the schemaLocation/noNamespaceSchemaLocation attributes occurring in the instance document to {@link XSDHelper#define convert XSD(s) to Types}
+ */
+ final String XML_LOAD_SCHEMA = "ProcessSchemaLocations";
+
+ /**
+ * To tolerate malformed elements and attributes (default unless set by System property XML.load.form.lax). 0 not to.
+ */
+ final String XML_LOAD_LAX_FORM = "load malform";
+
+ /**
+ * Allows you to record unknown features during deserialization/loading.
+ * The default is Boolean.FALSE unless set to Boolean.TRUE explicitly.
+ */
+ final String XML_LOAD_UNKNOWN_PROPERTIES = "load unknown properties";
+ }
+
+ public void addChangeListener(DataObject quote, EventListener listener);
+
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java
new file mode 100644
index 0000000000..17ce7ce28c
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java
@@ -0,0 +1,412 @@
+/**
+ *
+ * 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.api;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sdo.spi.HelperProviderBase;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * This class provides convenient static utility functions for calling the default SDOHelper.
+ */
+public final class SDOUtil
+{
+ protected static SDOHelper defaultSDOHelper = ((HelperProviderBase)HelperProvider.INSTANCE).sdoHelper();
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createDataTypeWrapper(Type, Object)}.
+ */
+ public static DataObject createDataTypeWrapper(Type dataType, Object value)
+ {
+ return defaultSDOHelper.createDataTypeWrapper(dataType, value);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createFromString(Type, String)}.
+ */
+ public static Object createFromString(Type dataType, String literal)
+ {
+ return defaultSDOHelper.createFromString(dataType, literal);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#convertToString(Type, Object)}.
+ */
+ public static String convertToString(Type dataType, Object value)
+ {
+ return defaultSDOHelper.convertToString(dataType, value);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getXSDSDOType(String)}.
+ */
+ public static Type getXSDSDOType(String xsdType)
+ {
+ return defaultSDOHelper.getXSDSDOType(xsdType);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getSubstitutionValues(DataObject, Property)}.
+ */
+ public static Sequence getSubstitutionValues(DataObject dataObject, Property head)
+ {
+ return defaultSDOHelper.getSubstitutionValues(dataObject, head);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getJavaSDOType(Class)}.
+ */
+ public static Type getJavaSDOType(Class javaClass)
+ {
+ return defaultSDOHelper.getJavaSDOType(javaClass);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#isRequired(Property)}.
+ */
+ public static boolean isRequired(Property property)
+ {
+ return defaultSDOHelper.isRequired(property);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getUpperBound(Property)}.
+ */
+ public static int getUpperBound(Property property)
+ {
+ return defaultSDOHelper.getUpperBound(property);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#isMany(Property, DataObject)}.
+ */
+ public static boolean isMany(Property property, DataObject context)
+ {
+ return defaultSDOHelper.isMany(property, context);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createDataGraph}.
+ */
+ public static DataGraph createDataGraph()
+ {
+ return defaultSDOHelper.createDataGraph();
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#setRootObject(DataGraph, DataObject)}.
+ */
+ public static void setRootObject(DataGraph dataGraph, DataObject rootObject)
+ {
+ defaultSDOHelper.setRootObject(dataGraph, rootObject);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#loadDataGraph(InputStream, Map, TypeHelper)}.
+ */
+ public static DataGraph loadDataGraph(InputStream inputStream, Map options) throws IOException
+ {
+ return defaultSDOHelper.loadDataGraph(inputStream, options, (HelperContext)null);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#loadDataGraph(InputStream, Map, HelperContext)}.
+ */
+ public static DataGraph loadDataGraph(InputStream inputStream, Map options, HelperContext hc) throws IOException
+ {
+ return defaultSDOHelper.loadDataGraph(inputStream, options, hc);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#saveDataGraph(DataGraph, OutputStream, Map)}.
+ */
+ public static void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options) throws IOException
+ {
+ defaultSDOHelper.saveDataGraph(dataGraph, outputStream, options);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#registerDataGraphTypes(DataGraph, List)}.
+ */
+ public static void registerDataGraphTypes(DataGraph dataGraph, List/*Type*/ types)
+ {
+ defaultSDOHelper.registerDataGraphTypes(dataGraph, types);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext(boolean,Map)}.
+ */
+ public static HelperContext createHelperContext(boolean extensibleNamespaces,Map options){
+ return defaultSDOHelper.createHelperContext(extensibleNamespaces, options);
+ }
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext(boolean)}.
+ */
+ public static HelperContext createHelperContext(boolean extensibleNamespaces)
+ {
+ return defaultSDOHelper.createHelperContext(extensibleNamespaces);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext}.
+ */
+ public static HelperContext createHelperContext(Map options)
+ {
+ return defaultSDOHelper.createHelperContext(options);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext}.
+ */
+ public static HelperContext createHelperContext()
+ {
+ return defaultSDOHelper.createHelperContext();
+ }
+
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createCrossScopeCopyHelper(HelperContext)}.
+ */
+ public static CopyHelper createCrossScopeCopyHelper(HelperContext hc)
+ {
+ return defaultSDOHelper.createCrossScopeCopyHelper(hc);
+ }
+
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createXMLStreamHelper(HelperContext)}.
+ */
+ public static XMLStreamHelper createXMLStreamHelper(HelperContext hc)
+ {
+ return defaultSDOHelper.createXMLStreamHelper(hc);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createObjectInputStream(InputStream, HelperContext)}.
+ */
+ public static ObjectInputStream createObjectInputStream(InputStream inputStream, HelperContext helperContext) throws IOException
+ {
+ return defaultSDOHelper.createObjectInputStream(inputStream, helperContext);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createObjectOutputStream(OutputStream, HelperContext)}.
+ */
+ public static ObjectOutputStream createObjectOutputStream(OutputStream outputStream, HelperContext helperContext) throws IOException
+ {
+ return defaultSDOHelper.createObjectOutputStream(outputStream, helperContext);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getTypes(HelperContext, String)}.
+ */
+ public static List getTypes(HelperContext hc, String uri) {
+
+ return defaultSDOHelper.getTypes(hc, uri);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getOpenContentProperties(DataObject)}.
+ */
+ public static List getOpenContentProperties(DataObject dataObject)
+ {
+ return defaultSDOHelper.getOpenContentProperties(dataObject);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#isDocumentRoot(Type)}.
+ */
+ public static boolean isDocumentRoot(Type type)
+ {
+ return defaultSDOHelper.isDocumentRoot(type);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getXPath(DataObject)}.
+ */
+ public static String getXPath(DataObject dataObject)
+ {
+ return defaultSDOHelper.getXPath(dataObject);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#createType(HelperContext, String, String, boolean)}.
+ */
+ public static Type createType(HelperContext hc, String uri, String name, boolean isDataType)
+ {
+ return defaultSDOHelper.getMetaDataBuilder().createType(hc, uri, name, isDataType);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addBaseType(Type, Type)}.
+ */
+ public static void addBaseType(Type type, Type baseType)
+ {
+ defaultSDOHelper.getMetaDataBuilder().addBaseType(type, baseType);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addAliasName(Type, String)}.
+ */
+ public static void addAliasName(Type type, String aliasName)
+ {
+ defaultSDOHelper.getMetaDataBuilder().addAliasName(type, aliasName);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setOpen(Type, boolean)}.
+ */
+ public static void setOpen(Type type, boolean isOpen)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setOpen(type, isOpen);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setSequenced(Type, boolean)}.
+ */
+ public static void setSequenced(Type type, boolean isSequenced)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setSequenced(type, isSequenced);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setAbstract(Type, boolean)}.
+ */
+ public static void setAbstract(Type type, boolean isAbstract)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setAbstract(type, isAbstract);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setJavaClassName(Type, String)}.
+ */
+ public static void setJavaClassName(Type type, String javaClassName)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setJavaClassName(type, javaClassName);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#createProperty(Type, String, Type)}.
+ */
+ public static Property createProperty(Type containingType, String name, Type propertyType)
+ {
+ return defaultSDOHelper.getMetaDataBuilder().createProperty(containingType, name, propertyType);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setPropertyXMLKind(Property, boolean)}.
+ */
+ public static void setPropertyXMLKind(Property property, boolean isXmlElement) {
+ defaultSDOHelper.getMetaDataBuilder().setPropertyXMLKind(property, isXmlElement);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#createOpenContentProperty(TypeHelper, String, String, Type)}.
+ */
+ public static Property createOpenContentProperty(HelperContext hc, String uri, String name, Type type)
+ {
+ return defaultSDOHelper.getMetaDataBuilder().createOpenContentProperty(hc, uri, name, type);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addAliasName(Property, String)}.
+ */
+ public static void addAliasName(Property property, String aliasName)
+ {
+ defaultSDOHelper.getMetaDataBuilder().addAliasName(property, aliasName);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setMany(Property, boolean)}.
+ */
+ public static void setMany(Property property, boolean isMany)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setMany(property, isMany);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setContainment(Property, boolean)}.
+ */
+ public static void setContainment(Property property, boolean isContainment)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setContainment(property, isContainment);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setDefault(Property, String)}.
+ */
+ public static void setDefault(Property property, String defaultValue)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setDefault(property, defaultValue);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setReadOnly(Property, boolean)}.
+ */
+ public static void setReadOnly(Property property, boolean isReadOnly)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setReadOnly(property, isReadOnly);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setOpposite(Property, Property)}.
+ */
+ public static void setOpposite(Property property, Property opposite)
+ {
+ defaultSDOHelper.getMetaDataBuilder().setOpposite(property, opposite);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addTypeInstanceProperty(Type, Property, Object)}.
+ */
+ public static void addTypeInstanceProperty(Type definedType, Property property, Object value)
+ {
+ defaultSDOHelper.getMetaDataBuilder().addTypeInstanceProperty(definedType, property, value);
+ }
+
+ /**
+ * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addPropertyInstanceProperty(Property, Property, Object)}.
+ */
+ public static void addPropertyInstanceProperty(Property definedProperty, Property property, Object value)
+ {
+ defaultSDOHelper.getMetaDataBuilder().addPropertyInstanceProperty(definedProperty, property, value);
+ }
+
+ public static void addChangeListener(DataObject quote, EventListener l) {
+ defaultSDOHelper.addChangeListener(quote, l);
+ }
+
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java
new file mode 100644
index 0000000000..094f05a703
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java
@@ -0,0 +1,125 @@
+/**
+ *
+ * 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.api;
+
+import java.util.Map;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+/**
+ * Helper interface for reading and writing SDO DataObjects from XML streams
+ * (StAX).
+ *
+ * @version $Rev: 503913 $ $Date: 2007-02-05 17:53:34 -0500 (Mon, 05 Feb 2007) $
+ */
+public interface XMLStreamHelper {
+ /**
+ * Creates and returns an XMLDocument from an XML input stream. The reader
+ * must be positioned on a START_DOCUMENT event.
+ *
+ * @param reader the stream to read
+ * @return an XMLDocument created from the stream
+ * @throws XMLStreamException if there was a problem reading the stream
+ * @throws IllegalStateException if the reader is not positioned on a
+ * START_DOCUMENT event
+ */
+ XMLDocument load(XMLStreamReader reader) throws XMLStreamException, IllegalStateException;
+
+ /**
+ * Save a XMLDocument to an XML stream.
+ *
+ * @param document the document to be written
+ * @param writer the stream to write to
+ * @throws XMLStreamException if there was a problem writing to the stream
+ */
+ void save(XMLDocument document, XMLStreamWriter writer) throws XMLStreamException;
+
+ void save(XMLDocument document, XMLStreamWriter writer, Map options) throws XMLStreamException;
+
+ /**
+ * Creates and returns a XMLStreamReader that can be used to read an
+ * XMLDocument as a XML event stream. The reader will be positioned on a
+ * START_DOCUMENT event.
+ *
+ * @param document the XMLDocument to be read
+ * @return an XMLStreamReader that can be used to read the document
+ */
+ XMLStreamReader createXMLStreamReader(XMLDocument document) throws XMLStreamException;
+
+ /**
+ * Create a DataObject from an element in a XML stream. The reader must be
+ * positioned on a START_ELEMENT event.
+ *
+ * @param reader the stream to read
+ * @return a DataObject created from the element in the stream
+ * @throws XMLStreamException if there was a problem reading the stream
+ * @throws IllegalStateException if the reader is not positioned on a
+ * START_ELEMENT event
+ */
+ DataObject loadObject(XMLStreamReader reader) throws XMLStreamException, IllegalStateException;
+
+ /**
+ * Default Type to load DataObject if the element is unqualified/local
+ * without xsi:type or the qualified/global element or xsi:type fail to
+ * resolve. Can be null.
+ */
+ String OPTION_DEFAULT_ROOT_TYPE = "default root type";
+
+ /**
+ * Create a DataObject from an element in a XML stream. The reader must be
+ * positioned on a START_ELEMENT event.
+ *
+ * @param reader the stream to read
+ * @param options {@link OPTION_DEFAULT_ROOT_TYPE}; can be null or empty
+ * @return a DataObject created from the element in the stream
+ * @throws XMLStreamException if there was a problem reading the stream
+ * @throws IllegalStateException if the reader is not positioned on a
+ * START_ELEMENT event
+ */
+ DataObject loadObject(XMLStreamReader reader, Map options) throws XMLStreamException, IllegalStateException;
+
+ /**
+ * Save a DataObject to an XML stream.
+ *
+ * @param sdo the DataObject to be written
+ * @param writer the stream to write to
+ * @throws XMLStreamException if there was a problem writing to the stream
+ */
+ void saveObject(DataObject sdo, XMLStreamWriter writer) throws XMLStreamException;
+
+ void saveObject(DataObject sdo, XMLStreamWriter writer, Map options) throws XMLStreamException;
+
+ /**
+ * Creates and returns a XMLStreamReader that can be used to read a
+ * DataObject as a XML event stream. The reader will be positioned on a
+ * START_ELEMENT event.
+ *
+ * @param sdo the DataObject to be read
+ * @return an XMLStreamReader that can be used to read the DataObject
+ */
+ XMLStreamReader createXMLStreamReader(DataObject sdo);
+
+ HelperContext getHelperContext();
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/overview.html b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/overview.html
new file mode 100644
index 0000000000..c6bd255b8f
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/overview.html
@@ -0,0 +1,38 @@
+
+
+
+ Tuscany API extensions to Service Data Objects (SDO)
+
+
+
Tuscany API extensions to Service Data Objects (SDO)
+
Overview
+
+The "org.apache.tuscany.sdo.api" package represents Tuscany API for SDO Java
+above and beyond what is offered by the SDO API itself. The contents of this
+project provide a means to achieve operations that are not currently addressed
+by the SDO API.
+
+
+The SDOUtil class simply provides a set of static convenince methods for
+exercising the methods of a default instance of the SDOHelper interface.
+
+
+
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java
new file mode 100644
index 0000000000..44987f9d7b
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java
@@ -0,0 +1,49 @@
+/**
+ *
+ * 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.lib;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+
+import commonj.sdo.helper.HelperContext;
+
+/**
+ * This subclass of ObjectInputStream provides a place to store the scope in which
+ * it was created.
+ */
+public class SDOObjectInputStream extends ObjectInputStream {
+
+ private HelperContext helperContext;
+
+ public SDOObjectInputStream(InputStream in, HelperContext helperContext) throws IOException{
+ super(in);
+ this.helperContext = helperContext;
+ }
+
+ public HelperContext getHelperContext() {
+ return helperContext;
+ }
+
+ public void setHelperContext(HelperContext helperContext) {
+ this.helperContext = helperContext;
+ }
+
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java
new file mode 100644
index 0000000000..1610e1c6de
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java
@@ -0,0 +1,49 @@
+/**
+ *
+ * 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.lib;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+import commonj.sdo.helper.HelperContext;
+
+/**
+ * This subclass of ObjectOutputStream provides a place to store the scope in which
+ * it was created.
+ */
+public class SDOObjectOutputStream extends ObjectOutputStream {
+
+ private HelperContext helperContext;
+
+ public SDOObjectOutputStream(OutputStream os, HelperContext helperContext) throws IOException{
+ super(os);
+ this.helperContext = helperContext;
+ }
+
+ public HelperContext getHelperContext() {
+ return helperContext;
+ }
+
+ public void setHelperContext(HelperContext helperContext) {
+ this.helperContext = helperContext;
+ }
+
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java
new file mode 100644
index 0000000000..163feb4522
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java
@@ -0,0 +1,245 @@
+/**
+ *
+ * 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.spi;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.ObjectStreamException;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.apache.tuscany.sdo.api.SDOHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+import org.apache.tuscany.sdo.lib.SDOObjectInputStream;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.DataHelper;
+import commonj.sdo.helper.EqualityHelper;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import commonj.sdo.impl.HelperProvider;
+import commonj.sdo.impl.ExternalizableDelegator.Resolvable;
+
+
+/**
+ * Create and manage all the default helpers
+ */
+public abstract class HelperProviderBase extends HelperProvider
+{
+ protected CopyHelper copyHelper;
+
+ protected DataFactory dataFactory;
+
+ protected DataHelper dataHelper;
+
+ protected EqualityHelper equalityHelper;
+
+ protected TypeHelper typeHelper;
+
+ protected XMLHelper xmlHelper;
+
+ protected XSDHelper xsdHelper;
+
+ protected SDOHelper sdoHelper; // Tuscany extension APIs
+
+ protected XMLStreamHelper xmlStreamHelper;
+ /**
+ * Subclasses must implement this method to initialize the above Helper instance variables
+ */
+ protected abstract HelperContext createDefaultHelpers();
+
+ public HelperProviderBase()
+ {
+ defaultContext = createDefaultHelpers();
+ }
+
+ public SDOHelper sdoHelper()
+ {
+ return sdoHelper;
+ }
+
+ public CopyHelper copyHelper()
+ {
+ return copyHelper;
+ }
+
+ public DataFactory dataFactory()
+ {
+ return dataFactory;
+ }
+
+ public DataHelper dataHelper()
+ {
+ return dataHelper;
+ }
+
+ public EqualityHelper equalityHelper()
+ {
+ return equalityHelper;
+ }
+
+ public TypeHelper typeHelper()
+ {
+ return typeHelper;
+ }
+
+ public XMLHelper xmlHelper()
+ {
+ return xmlHelper;
+ }
+
+ public XMLStreamHelper xmlStreamHelper()
+ {
+ return xmlStreamHelper;
+ }
+ public XSDHelper xsdHelper()
+ {
+ return xsdHelper;
+ }
+
+ public Resolvable resolvable()
+ {
+ return new ResolvableImpl();
+ }
+
+ public Resolvable resolvable(Object target)
+ {
+ return new ResolvableImpl(target);
+ }
+
+ protected class ResolvableImpl implements Resolvable
+ {
+ protected Object target;
+
+ public ResolvableImpl(Object target) { this.target = target; }
+
+ public ResolvableImpl() { this.target = null; }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ if (target instanceof DataObject)
+ {
+ writeDataObject((DataObject)target, out);
+ }
+ else
+ {
+ throw new NotSerializableException(); // should never happen
+ }
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ target = readDataObject(in);
+ }
+
+ public Object readResolve() throws ObjectStreamException
+ {
+ return target;
+ }
+
+ protected void writeDataObject(DataObject dataObject, ObjectOutput objectOutput) throws IOException
+ {
+ DataGraph dataGraph = dataObject.getDataGraph();
+ if (dataGraph != null)
+ {
+ objectOutput.writeByte(0);
+ objectOutput.writeUTF(SDOUtil.getXPath(dataObject));
+ objectOutput.writeObject(dataGraph);
+ }
+ else if (dataObject.getContainer() != null)
+ {
+ objectOutput.writeByte(0);
+ objectOutput.writeUTF(SDOUtil.getXPath(dataObject));
+ objectOutput.writeObject(dataObject.getRootObject());
+ }
+ else
+ {
+ // Root object
+ objectOutput.writeByte(1);
+
+ ByteArrayOutputStream compressedByteArrayOutputStream = new ByteArrayOutputStream();
+ GZIPOutputStream gzipOutputStream = new GZIPOutputStream(compressedByteArrayOutputStream);
+ XMLHelper xmlHelperLocal = xmlHelper;
+ if(objectOutput instanceof SDOObjectInputStream)
+ {
+ xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper();
+ }
+ xmlHelperLocal.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream);
+ gzipOutputStream.close(); // Flush the contents
+
+ byte[] byteArray = compressedByteArrayOutputStream.toByteArray();
+ objectOutput.writeInt(byteArray.length);
+ objectOutput.write(byteArray);
+ }
+ }
+
+ protected DataObject readDataObject(ObjectInput objectInput) throws IOException, ClassNotFoundException
+ {
+ boolean isRoot = objectInput.readByte() == 1;
+ if (isRoot)
+ {
+ // Root object: [rootXML] = length + XML contents
+ int length = objectInput.readInt();
+ byte[] compressedBytes = new byte [length];
+
+ int index = 0;
+ int bytesRead;
+ while (index < length) {
+ if ((bytesRead = objectInput.read(compressedBytes, index, length-index)) == -1) {
+ break;
+ }
+ index += bytesRead;
+ }
+
+ GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedBytes));
+ XMLHelper xmlHelperLocal = xmlHelper;
+ if (objectInput instanceof SDOObjectInputStream)
+ {
+ xmlHelperLocal = ((SDOObjectInputStream)objectInput).getHelperContext().getXMLHelper();
+ }
+ XMLDocument doc = xmlHelperLocal.load(gzipInputStream);
+ gzipInputStream.close();
+
+ return doc.getRootObject();
+ }
+ else
+ {
+ // Non root object: [path] [root]
+ String xpath = objectInput.readUTF();
+ Object object = objectInput.readObject();
+
+ DataObject root = object instanceof DataGraph ? ((DataGraph)object).getRootObject() : (DataObject)object;
+ return xpath.equals("") ? root : root.getDataObject(xpath);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java
new file mode 100644
index 0000000000..43c379256c
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java
@@ -0,0 +1,176 @@
+/**
+ *
+ * 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.spi;
+
+/**
+ * Base class for an implementation of the SDOHelper and SDOHelper.MetaDataBuilder interfaces.
+ */
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sdo.api.SDOHelper;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.lib.SDOObjectInputStream;
+import org.apache.tuscany.sdo.lib.SDOObjectOutputStream;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.helper.HelperContext;
+
+public abstract class SDOHelperBase implements SDOHelper, SDOHelper.MetaDataBuilder
+{
+ public HelperContext createHelperContext()
+ {
+ return createHelperContext(false);
+ }
+
+ public ObjectInputStream createObjectInputStream(InputStream inputStream, HelperContext helperContext) throws IOException
+ {
+ return new SDOObjectInputStream(inputStream, helperContext);
+ }
+
+ public ObjectOutputStream createObjectOutputStream(OutputStream outputStream, HelperContext helperContext) throws IOException
+ {
+ return new SDOObjectOutputStream(outputStream, helperContext);
+ }
+
+ public String getXPath(DataObject dataObject)
+ {
+ StringBuffer path = getXPath(dataObject, new StringBuffer(), dataObject);
+ return path.toString();
+ }
+
+ protected 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();
+ if (SDOUtil.isMany(property, dataObject))
+ {
+ List list = container.getList(property);
+ int pos = list.indexOf(dataObject);
+ path.insert(0, property.getName() + "." + pos + (first ? "" : "/"));
+ }
+ else
+ {
+ path.insert(0, property.getName() + (first ? "" : "/"));
+ }
+
+ return getXPath(container, path, root);
+ }
+
+ public MetaDataBuilder getMetaDataBuilder()
+ {
+ return this;
+ }
+
+ //Java instance class to SDO mappings (section 8.1 of the SDO spec)
+ protected static Map javaToSdoMappings = new HashMap();
+ static {
+ javaToSdoMappings.put(boolean.class, "Boolean");
+ javaToSdoMappings.put(byte.class, "Byte");
+ javaToSdoMappings.put(char.class, "Character");
+ javaToSdoMappings.put(Date.class, "Date");
+ javaToSdoMappings.put(BigDecimal.class, "Decimal");
+ javaToSdoMappings.put(double.class, "Double");
+ javaToSdoMappings.put(float.class, "Float");
+ javaToSdoMappings.put(int.class, "Int");
+ javaToSdoMappings.put(BigInteger.class, "Integer");
+ javaToSdoMappings.put(long.class, "Long");
+ javaToSdoMappings.put(Object.class, "Object");
+ javaToSdoMappings.put(short.class, "Short");
+ javaToSdoMappings.put(String.class, "String");
+ javaToSdoMappings.put(Boolean.class, "BooleanObject");
+ javaToSdoMappings.put(Byte.class, "ByteObject");
+ javaToSdoMappings.put(Character.class, "CharacterObject");
+ javaToSdoMappings.put(Double.class, "DoubleObject");
+ javaToSdoMappings.put(Float.class, "FloatObject");
+ javaToSdoMappings.put(Integer.class, "IntObject");
+ javaToSdoMappings.put(Long.class, "LongObject");
+ javaToSdoMappings.put(Short.class, "ShortObject");
+ }
+
+ //XSD to SDO mappings (section 9.4 of the SDO spec)
+ protected static Map xsdToSdoMappings = new HashMap();
+ static {
+ xsdToSdoMappings.put("anySimpleType", "Object");
+ xsdToSdoMappings.put("anyType", "DataObject");
+ xsdToSdoMappings.put("anyURI", "URI");
+ xsdToSdoMappings.put("base64Binary", "Bytes");
+ xsdToSdoMappings.put("boolean", "Boolean");
+ xsdToSdoMappings.put("byte", "Byte");
+ xsdToSdoMappings.put("date", "YearMonthDay");
+ xsdToSdoMappings.put("dateTime", "DateTime");
+ xsdToSdoMappings.put("decimal", "Decimal");
+ xsdToSdoMappings.put("double", "Double");
+ xsdToSdoMappings.put("duration", "Duration");
+ xsdToSdoMappings.put("ENTITIES", "Strings");
+ xsdToSdoMappings.put("ENTITY", "String");
+ xsdToSdoMappings.put("float", "Float");
+ xsdToSdoMappings.put("gDay", "Day");
+ xsdToSdoMappings.put("gMonth", "Month");
+ xsdToSdoMappings.put("gMonthDay", "MonthDay");
+ xsdToSdoMappings.put("gYear", "Year");
+ xsdToSdoMappings.put("gYearMonth", "YearMonth");
+ xsdToSdoMappings.put("hexBinary", "Bytes");
+ xsdToSdoMappings.put("ID","String");
+ xsdToSdoMappings.put("IDREF","String");
+ xsdToSdoMappings.put("IDREFS","Strings");
+ xsdToSdoMappings.put("int","Int");
+ xsdToSdoMappings.put("integer","Integer");
+ xsdToSdoMappings.put("language","String");
+ xsdToSdoMappings.put("long","Long");
+ xsdToSdoMappings.put("Name","String");
+ xsdToSdoMappings.put("NCName","String");
+ xsdToSdoMappings.put("negativeInteger","Integer");
+ xsdToSdoMappings.put("NMTOKEN","String");
+ xsdToSdoMappings.put("NMTOKENS","Strings");
+ xsdToSdoMappings.put("nonNegativeInteger","Integer");
+ xsdToSdoMappings.put("nonPositiveInteger","Integer");
+ xsdToSdoMappings.put("normalizedString","String");
+ xsdToSdoMappings.put("NOTATION","String");
+ xsdToSdoMappings.put("positiveInteger","Integer");
+ xsdToSdoMappings.put("QName","URI");
+ xsdToSdoMappings.put("short","Short");
+ xsdToSdoMappings.put("string","String");
+ xsdToSdoMappings.put("time","Time");
+ xsdToSdoMappings.put("token","String");
+ xsdToSdoMappings.put("unsignedByte","Short");
+ xsdToSdoMappings.put("unsignedInt","Long");
+ xsdToSdoMappings.put("unsignedLong","Integer");
+ xsdToSdoMappings.put("unsignedShort","Int");
+ }
+
+}
diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/DISCLAIMER b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/DISCLAIMER
new file mode 100644
index 0000000000..a65af91c5a
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/DISCLAIMER
@@ -0,0 +1,7 @@
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
\ No newline at end of file
diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/LICENSE.txt b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..e55ca67ba9
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,207 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+
+
+
diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/MANIFEST.MF b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fc4233db53
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Extension-Name: tuscany-sdo-lib
+Specification-Title: Tuscany SDO Implementation Library
+Specification-Vendor: Apache Software Foundation
+Implementation-Vendor: Apache Software Foundation
+Implementation-Vendor-Id: org.apache
+Implementation-Title: tuscany-sdo-lib
+Implementation-Version: incubating-M3
+Bundle-ManifestVersion: 2
+Bundle-Name: Tuscany SDO Implementation Library
+Bundle-SymbolicName: org.apache.tuscany.sdo.lib
+Bundle-Version: 1.0.0
+Bundle-Vendor: Apache Software Foundation
+Require-Bundle: org.apache.tuscany.sdo.spec;visibility:=reexport
+Export-Package: org.apache.tuscany.sdo.api,
+ org.apache.tuscany.sdo.rtlib
diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/NOTICE b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..cb303cf8b5
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,14 @@
+Apache Tuscany
+Copyright (c) 2005 - 2007 The Apache Software Foundation
+
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Please see the LICENSE file present in the META-INF directory of this archive.
+
diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/README.txt b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/README.txt
new file mode 100644
index 0000000000..43759129b7
--- /dev/null
+++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/README.txt
@@ -0,0 +1,23 @@
+Apache Tuscany 1.0-incubating build (July 2007)
+===============================================
+
+http://incubator.apache.org/tuscany/
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sandbox/kgoodson/events/play/pom.xml b/sandbox/kgoodson/events/play/pom.xml
new file mode 100644
index 0000000000..b98621178d
--- /dev/null
+++ b/sandbox/kgoodson/events/play/pom.xml
@@ -0,0 +1,33 @@
+
+ 4.0.0
+ com.example
+ play
+ jar
+ kgoodson_sandbox
+ play
+ http://maven.apache.org
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo-lib
+ kgoodson-sandbox
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo-impl
+ kgoodson-sandbox
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo-api-r2.1
+ 1.0-incubating-SNAPSHOT
+
+
+
diff --git a/sandbox/kgoodson/events/play/src/main/java/com/example/ComExampleObserver.java b/sandbox/kgoodson/events/play/src/main/java/com/example/ComExampleObserver.java
new file mode 100644
index 0000000000..909713dfc4
--- /dev/null
+++ b/sandbox/kgoodson/events/play/src/main/java/com/example/ComExampleObserver.java
@@ -0,0 +1,13 @@
+package com.example;
+
+import org.apache.tuscany.sdo.api.Event;
+import org.apache.tuscany.sdo.api.ListenerBase;
+
+public class ComExampleObserver extends ListenerBase {
+
+ public void eventNotification(Event e) {
+ System.out.println("Hi I changed");
+
+ }
+
+}
diff --git a/sandbox/kgoodson/events/play/src/test/java/com/example/TestChanges.java b/sandbox/kgoodson/events/play/src/test/java/com/example/TestChanges.java
new file mode 100644
index 0000000000..09aec7f046
--- /dev/null
+++ b/sandbox/kgoodson/events/play/src/test/java/com/example/TestChanges.java
@@ -0,0 +1,41 @@
+package com.example;
+
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import junit.framework.TestCase;
+
+
+import com.example.ComExampleObserver;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+
+public class TestChanges extends TestCase {
+
+ HelperContext scope;
+ private final String TEST_MODEL = "/simple.xsd";
+
+
+ public void setUp() throws Exception {
+ scope = SDOUtil.createHelperContext();
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ scope.getXSDHelper().define(inputStream, url.toString());
+ inputStream.close();
+
+ }
+
+ public void tearDown() throws Exception {
+ }
+
+ public void testChange1()
+ {
+ DataObject quote = scope.getDataFactory().create("http://www.example.com/simple", "Quote");
+ SDOUtil.addChangeListener(quote, new ComExampleObserver());
+
+ quote.setString("symbol","foo");
+ }
+}
diff --git a/sandbox/kgoodson/events/play/src/test/resources/simple.xsd b/sandbox/kgoodson/events/play/src/test/resources/simple.xsd
new file mode 100644
index 0000000000..3beb0ca496
--- /dev/null
+++ b/sandbox/kgoodson/events/play/src/test/resources/simple.xsd
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--
cgit v1.2.3