diff options
Diffstat (limited to 'branches/sdo-1.1.1-incubating/impl/src/test')
139 files changed, 0 insertions, 21890 deletions
diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java deleted file mode 100644 index 938c4b25d2..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * - * 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.helper.HelperContext; - - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <!-- end-user-doc --> - * @generated - */ -public interface ExpectedExceptionFactory -{ - - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - ExpectedExceptionFactory INSTANCE = com.example.ExpectedException.impl.ExpectedExceptionFactoryImpl.init(); - - /** - * Returns a new object of class '<em>Type</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Type</em>'. - * @generated - */ - ExpectedExceptionType createExpectedExceptionType(); - - /** - * Returns a new object of class '<em>Sequence Read Only Type</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Sequence Read Only Type</em>'. - * @generated - */ - SequenceReadOnlyType createSequenceReadOnlyType(); - - /** - * Registers the types supported by this Factory within the supplied scope.argument - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param scope an instance of HelperContext used to manage the scoping of types. - * @generated - */ - public void register(HelperContext scope); - -} //ExpectedExceptionFactory diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java deleted file mode 100644 index 80159443dc..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java +++ /dev/null @@ -1,786 +0,0 @@ -/** - * - * 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 java.io.Serializable; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import java.util.List; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Type</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getListVal <em>List Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal <em>Read Only Val</em>}</li> - * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal <em>Read Only List Val</em>}</li> - * </ul> - * </p> - * - * @extends Serializable - * @generated - */ -public interface ExpectedExceptionType extends Serializable -{ - /** - * Returns the value of the '<em><b>String Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>String Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>String Val</em>' attribute. - * @see #isSetStringVal() - * @see #unsetStringVal() - * @see #setStringVal(String) - * @generated - */ - String getStringVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>String Val</em>' attribute. - * @see #isSetStringVal() - * @see #unsetStringVal() - * @see #getStringVal() - * @generated - */ - void setStringVal(String value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetStringVal() - * @see #getStringVal() - * @see #setStringVal(String) - * @generated - */ - void unsetStringVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>String Val</em>' attribute is set. - * @see #unsetStringVal() - * @see #getStringVal() - * @see #setStringVal(String) - * @generated - */ - boolean isSetStringVal(); - - /** - * Returns the value of the '<em><b>Boolean Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Boolean Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Boolean Val</em>' attribute. - * @see #isSetBooleanVal() - * @see #unsetBooleanVal() - * @see #setBooleanVal(boolean) - * @generated - */ - boolean isBooleanVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Boolean Val</em>' attribute. - * @see #isSetBooleanVal() - * @see #unsetBooleanVal() - * @see #isBooleanVal() - * @generated - */ - void setBooleanVal(boolean value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetBooleanVal() - * @see #isBooleanVal() - * @see #setBooleanVal(boolean) - * @generated - */ - void unsetBooleanVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Boolean Val</em>' attribute is set. - * @see #unsetBooleanVal() - * @see #isBooleanVal() - * @see #setBooleanVal(boolean) - * @generated - */ - boolean isSetBooleanVal(); - - /** - * Returns the value of the '<em><b>Byte Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Byte Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Byte Val</em>' attribute. - * @see #isSetByteVal() - * @see #unsetByteVal() - * @see #setByteVal(byte) - * @generated - */ - byte getByteVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Byte Val</em>' attribute. - * @see #isSetByteVal() - * @see #unsetByteVal() - * @see #getByteVal() - * @generated - */ - void setByteVal(byte value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetByteVal() - * @see #getByteVal() - * @see #setByteVal(byte) - * @generated - */ - void unsetByteVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Byte Val</em>' attribute is set. - * @see #unsetByteVal() - * @see #getByteVal() - * @see #setByteVal(byte) - * @generated - */ - boolean isSetByteVal(); - - /** - * Returns the value of the '<em><b>Decimal Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Decimal Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Decimal Val</em>' attribute. - * @see #isSetDecimalVal() - * @see #unsetDecimalVal() - * @see #setDecimalVal(BigDecimal) - * @generated - */ - BigDecimal getDecimalVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Decimal Val</em>' attribute. - * @see #isSetDecimalVal() - * @see #unsetDecimalVal() - * @see #getDecimalVal() - * @generated - */ - void setDecimalVal(BigDecimal value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetDecimalVal() - * @see #getDecimalVal() - * @see #setDecimalVal(BigDecimal) - * @generated - */ - void unsetDecimalVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Decimal Val</em>' attribute is set. - * @see #unsetDecimalVal() - * @see #getDecimalVal() - * @see #setDecimalVal(BigDecimal) - * @generated - */ - boolean isSetDecimalVal(); - - /** - * Returns the value of the '<em><b>Int Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Int Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Int Val</em>' attribute. - * @see #isSetIntVal() - * @see #unsetIntVal() - * @see #setIntVal(int) - * @generated - */ - int getIntVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Int Val</em>' attribute. - * @see #isSetIntVal() - * @see #unsetIntVal() - * @see #getIntVal() - * @generated - */ - void setIntVal(int value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetIntVal() - * @see #getIntVal() - * @see #setIntVal(int) - * @generated - */ - void unsetIntVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Int Val</em>' attribute is set. - * @see #unsetIntVal() - * @see #getIntVal() - * @see #setIntVal(int) - * @generated - */ - boolean isSetIntVal(); - - /** - * Returns the value of the '<em><b>Float Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Float Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Float Val</em>' attribute. - * @see #isSetFloatVal() - * @see #unsetFloatVal() - * @see #setFloatVal(float) - * @generated - */ - float getFloatVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Float Val</em>' attribute. - * @see #isSetFloatVal() - * @see #unsetFloatVal() - * @see #getFloatVal() - * @generated - */ - void setFloatVal(float value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetFloatVal() - * @see #getFloatVal() - * @see #setFloatVal(float) - * @generated - */ - void unsetFloatVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Float Val</em>' attribute is set. - * @see #unsetFloatVal() - * @see #getFloatVal() - * @see #setFloatVal(float) - * @generated - */ - boolean isSetFloatVal(); - - /** - * Returns the value of the '<em><b>Double Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Double Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Double Val</em>' attribute. - * @see #isSetDoubleVal() - * @see #unsetDoubleVal() - * @see #setDoubleVal(double) - * @generated - */ - double getDoubleVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Double Val</em>' attribute. - * @see #isSetDoubleVal() - * @see #unsetDoubleVal() - * @see #getDoubleVal() - * @generated - */ - void setDoubleVal(double value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetDoubleVal() - * @see #getDoubleVal() - * @see #setDoubleVal(double) - * @generated - */ - void unsetDoubleVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Double Val</em>' attribute is set. - * @see #unsetDoubleVal() - * @see #getDoubleVal() - * @see #setDoubleVal(double) - * @generated - */ - boolean isSetDoubleVal(); - - /** - * Returns the value of the '<em><b>Date Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Date Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Date Val</em>' attribute. - * @see #isSetDateVal() - * @see #unsetDateVal() - * @see #setDateVal(String) - * @generated - */ - String getDateVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Date Val</em>' attribute. - * @see #isSetDateVal() - * @see #unsetDateVal() - * @see #getDateVal() - * @generated - */ - void setDateVal(String value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetDateVal() - * @see #getDateVal() - * @see #setDateVal(String) - * @generated - */ - void unsetDateVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Date Val</em>' attribute is set. - * @see #unsetDateVal() - * @see #getDateVal() - * @see #setDateVal(String) - * @generated - */ - boolean isSetDateVal(); - - /** - * Returns the value of the '<em><b>Short Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Short Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Short Val</em>' attribute. - * @see #isSetShortVal() - * @see #unsetShortVal() - * @see #setShortVal(short) - * @generated - */ - short getShortVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Short Val</em>' attribute. - * @see #isSetShortVal() - * @see #unsetShortVal() - * @see #getShortVal() - * @generated - */ - void setShortVal(short value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetShortVal() - * @see #getShortVal() - * @see #setShortVal(short) - * @generated - */ - void unsetShortVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Short Val</em>' attribute is set. - * @see #unsetShortVal() - * @see #getShortVal() - * @see #setShortVal(short) - * @generated - */ - boolean isSetShortVal(); - - /** - * Returns the value of the '<em><b>Long Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Long Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Long Val</em>' attribute. - * @see #isSetLongVal() - * @see #unsetLongVal() - * @see #setLongVal(long) - * @generated - */ - long getLongVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Long Val</em>' attribute. - * @see #isSetLongVal() - * @see #unsetLongVal() - * @see #getLongVal() - * @generated - */ - void setLongVal(long value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetLongVal() - * @see #getLongVal() - * @see #setLongVal(long) - * @generated - */ - void unsetLongVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Long Val</em>' attribute is set. - * @see #unsetLongVal() - * @see #getLongVal() - * @see #setLongVal(long) - * @generated - */ - boolean isSetLongVal(); - - /** - * Returns the value of the '<em><b>List Val</b></em>' attribute list. - * The list contents are of type {@link java.lang.String}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>List Val</em>' attribute list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>List Val</em>' attribute list. - * @generated - */ - List getListVal(); - - /** - * Returns the value of the '<em><b>Bytes Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Bytes Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Bytes Val</em>' attribute. - * @see #isSetBytesVal() - * @see #unsetBytesVal() - * @see #setBytesVal(byte[]) - * @generated - */ - byte[] getBytesVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Bytes Val</em>' attribute. - * @see #isSetBytesVal() - * @see #unsetBytesVal() - * @see #getBytesVal() - * @generated - */ - void setBytesVal(byte[] value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetBytesVal() - * @see #getBytesVal() - * @see #setBytesVal(byte[]) - * @generated - */ - void unsetBytesVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Bytes Val</em>' attribute is set. - * @see #unsetBytesVal() - * @see #getBytesVal() - * @see #setBytesVal(byte[]) - * @generated - */ - boolean isSetBytesVal(); - - /** - * Returns the value of the '<em><b>Integer Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Integer Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Integer Val</em>' attribute. - * @see #isSetIntegerVal() - * @see #unsetIntegerVal() - * @see #setIntegerVal(BigInteger) - * @generated - */ - BigInteger getIntegerVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Integer Val</em>' attribute. - * @see #isSetIntegerVal() - * @see #unsetIntegerVal() - * @see #getIntegerVal() - * @generated - */ - void setIntegerVal(BigInteger value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetIntegerVal() - * @see #getIntegerVal() - * @see #setIntegerVal(BigInteger) - * @generated - */ - void unsetIntegerVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Integer Val</em>' attribute is set. - * @see #unsetIntegerVal() - * @see #getIntegerVal() - * @see #setIntegerVal(BigInteger) - * @generated - */ - boolean isSetIntegerVal(); - - /** - * Returns the value of the '<em><b>Char Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Char Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Char Val</em>' attribute. - * @see #isSetCharVal() - * @see #unsetCharVal() - * @see #setCharVal(String) - * @generated - */ - String getCharVal(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Char Val</em>' attribute. - * @see #isSetCharVal() - * @see #unsetCharVal() - * @see #getCharVal() - * @generated - */ - void setCharVal(String value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetCharVal() - * @see #getCharVal() - * @see #setCharVal(String) - * @generated - */ - void unsetCharVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Char Val</em>' attribute is set. - * @see #unsetCharVal() - * @see #getCharVal() - * @see #setCharVal(String) - * @generated - */ - boolean isSetCharVal(); - - /** - * Returns the value of the '<em><b>Read Only Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Read Only Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Read Only Val</em>' attribute. - * @see #isSetReadOnlyVal() - * @generated - */ - String getReadOnlyVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal <em>Read Only Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Read Only Val</em>' attribute is set. - * @see #getReadOnlyVal() - * @generated - */ - boolean isSetReadOnlyVal(); - - /** - * Returns the value of the '<em><b>Read Only List Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Read Only List Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Read Only List Val</em>' attribute. - * @see #isSetReadOnlyListVal() - * @generated - */ - String getReadOnlyListVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal <em>Read Only List Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Read Only List Val</em>' attribute is set. - * @see #getReadOnlyListVal() - * @generated - */ - boolean isSetReadOnlyListVal(); - -} // ExpectedExceptionType diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java deleted file mode 100644 index a87511df28..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * - * 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; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Sequence Read Only Type</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getMixed <em>Mixed</em>}</li> - * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal <em>Read Only Val</em>}</li> - * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal <em>Read Only List Val</em>}</li> - * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}</li> - * </ul> - * </p> - * - * @extends Serializable - * @generated - */ -public interface SequenceReadOnlyType extends Serializable -{ - /** - * Returns the value of the '<em><b>Mixed</b></em>' attribute list. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Mixed</em>' attribute list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Mixed</em>' attribute list. - * @generated - */ - Sequence getMixed(); - - /** - * Returns the value of the '<em><b>Read Only Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Read Only Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Read Only Val</em>' attribute. - * @see #isSetReadOnlyVal() - * @generated - */ - String getReadOnlyVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal <em>Read Only Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Read Only Val</em>' attribute is set. - * @see #getReadOnlyVal() - * @generated - */ - boolean isSetReadOnlyVal(); - - /** - * Returns the value of the '<em><b>Read Only List Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Read Only List Val</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Read Only List Val</em>' attribute. - * @see #isSetReadOnlyListVal() - * @generated - */ - String getReadOnlyListVal(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal <em>Read Only List Val</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Read Only List Val</em>' attribute is set. - * @see #getReadOnlyListVal() - * @generated - */ - boolean isSetReadOnlyListVal(); - - /** - * Returns the value of the '<em><b>Unique Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Unique Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Unique Name</em>' attribute. - * @see #isSetUniqueName() - * @see #unsetUniqueName() - * @see #setUniqueName(String) - * @generated - */ - String getUniqueName(); - - /** - * Sets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Unique Name</em>' attribute. - * @see #isSetUniqueName() - * @see #unsetUniqueName() - * @see #getUniqueName() - * @generated - */ - void setUniqueName(String value); - - /** - * Unsets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetUniqueName() - * @see #getUniqueName() - * @see #setUniqueName(String) - * @generated - */ - void unsetUniqueName(); - - /** - * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Unique Name</em>' attribute is set. - * @see #unsetUniqueName() - * @see #getUniqueName() - * @see #setUniqueName(String) - * @generated - */ - boolean isSetUniqueName(); - -} // SequenceReadOnlyType diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java deleted file mode 100644 index 68280749c4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java +++ /dev/null @@ -1,579 +0,0 @@ -/** - * - * 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; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * Generator information: - * patternVersion=1.2; -prefix ExpectedException - * <!-- end-user-doc --> - * @generated - */ -public class ExpectedExceptionFactoryImpl extends FactoryBase implements ExpectedExceptionFactory -{ - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String NAMESPACE_URI = "http://example.com/ExpectedException"; - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String NAMESPACE_PREFIX = "expect"; - - /** - * The version of the generator pattern used to generate this class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String PATTERN_VERSION = "1.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. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @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. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void register(HelperContext scope) { - if(scope == null) { - throw new IllegalArgumentException("Scope can not be null"); - } - TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); - th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public DataObject create(int typeNumber) - { - switch (typeNumber) - { - case EXPECTED_EXCEPTION_TYPE: return (DataObject)createExpectedExceptionType(); - case SEQUENCE_READ_ONLY_TYPE: return (DataObject)createSequenceReadOnlyType(); - default: - return super.create(typeNumber); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @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"); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @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"); - } - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ExpectedExceptionType createExpectedExceptionType() - { - ExpectedExceptionTypeImpl expectedExceptionType = new ExpectedExceptionTypeImpl(); - return expectedExceptionType; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @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" - }); - - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String createcharFromString(String initialValue) - { - return (String)((ModelFactoryImpl)ModelFactory.INSTANCE).createStringFromString(initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertcharToString(Object instanceValue) - { - return ((ModelFactoryImpl)ModelFactory.INSTANCE).convertStringToString(instanceValue); - } - -} //ExpectedExceptionFactoryImpl diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java deleted file mode 100644 index df7bdbd66e..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java +++ /dev/null @@ -1,1682 +0,0 @@ -/** - * - * 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; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Type</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getStringVal <em>String Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#isBooleanVal <em>Boolean Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getByteVal <em>Byte Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDecimalVal <em>Decimal Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntVal <em>Int Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getFloatVal <em>Float Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDoubleVal <em>Double Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDateVal <em>Date Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getShortVal <em>Short Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getLongVal <em>Long Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getListVal <em>List Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getBytesVal <em>Bytes Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntegerVal <em>Integer Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getCharVal <em>Char Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyVal <em>Read Only Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyListVal <em>Read Only List Val</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ExpectedExceptionTypeImpl extends DataObjectBase implements ExpectedExceptionType -{ - - public final static int STRING_VAL = 0; - - public final static int BOOLEAN_VAL = 1; - - public final static int BYTE_VAL = 2; - - public final static int DECIMAL_VAL = 3; - - public final static int INT_VAL = 4; - - public final static int FLOAT_VAL = 5; - - public final static int DOUBLE_VAL = 6; - - public final static int DATE_VAL = 7; - - public final static int SHORT_VAL = 8; - - public final static int LONG_VAL = 9; - - public final static int LIST_VAL = 10; - - public final static int BYTES_VAL = 11; - - public final static int INTEGER_VAL = 12; - - public final static int CHAR_VAL = 13; - - public final static int READ_ONLY_VAL = 14; - - public final static int READ_ONLY_LIST_VAL = 15; - - public final static int SDO_PROPERTY_COUNT = 16; - - public final static int EXTENDED_PROPERTY_COUNT = 0; - - - /** - * The internal feature id for the '<em><b>String Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_STRING_VAL = 0; - - /** - * The internal feature id for the '<em><b>Boolean Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_BOOLEAN_VAL = 1; - - /** - * The internal feature id for the '<em><b>Byte Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_BYTE_VAL = 2; - - /** - * The internal feature id for the '<em><b>Decimal Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_DECIMAL_VAL = 3; - - /** - * The internal feature id for the '<em><b>Int Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_INT_VAL = 4; - - /** - * The internal feature id for the '<em><b>Float Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_FLOAT_VAL = 5; - - /** - * The internal feature id for the '<em><b>Double Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_DOUBLE_VAL = 6; - - /** - * The internal feature id for the '<em><b>Date Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_DATE_VAL = 7; - - /** - * The internal feature id for the '<em><b>Short Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_SHORT_VAL = 8; - - /** - * The internal feature id for the '<em><b>Long Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_LONG_VAL = 9; - - /** - * The internal feature id for the '<em><b>List Val</b></em>' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_LIST_VAL = 10; - - /** - * The internal feature id for the '<em><b>Bytes Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_BYTES_VAL = 11; - - /** - * The internal feature id for the '<em><b>Integer Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_INTEGER_VAL = 12; - - /** - * The internal feature id for the '<em><b>Char Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_CHAR_VAL = 13; - - /** - * The internal feature id for the '<em><b>Read Only Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_READ_ONLY_VAL = 14; - - /** - * The internal feature id for the '<em><b>Read Only List Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_READ_ONLY_LIST_VAL = 15; - - /** - * The number of properties for this type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_PROPERTY_COUNT = 16; - - protected int internalConvertIndex(int internalIndex) - { - switch (internalIndex) - { - case INTERNAL_STRING_VAL: return STRING_VAL; - case INTERNAL_BOOLEAN_VAL: return BOOLEAN_VAL; - case INTERNAL_BYTE_VAL: return BYTE_VAL; - case INTERNAL_DECIMAL_VAL: return DECIMAL_VAL; - case INTERNAL_INT_VAL: return INT_VAL; - case INTERNAL_FLOAT_VAL: return FLOAT_VAL; - case INTERNAL_DOUBLE_VAL: return DOUBLE_VAL; - case INTERNAL_DATE_VAL: return DATE_VAL; - case INTERNAL_SHORT_VAL: return SHORT_VAL; - case INTERNAL_LONG_VAL: return LONG_VAL; - case INTERNAL_LIST_VAL: return LIST_VAL; - case INTERNAL_BYTES_VAL: return BYTES_VAL; - case INTERNAL_INTEGER_VAL: return INTEGER_VAL; - case INTERNAL_CHAR_VAL: return CHAR_VAL; - case INTERNAL_READ_ONLY_VAL: return READ_ONLY_VAL; - case INTERNAL_READ_ONLY_LIST_VAL: return READ_ONLY_LIST_VAL; - } - return super.internalConvertIndex(internalIndex); - } - - - /** - * The default value of the '{@link #getStringVal() <em>String Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getStringVal() - * @generated - * @ordered - */ - protected static final String STRING_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getStringVal() <em>String Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getStringVal() - * @generated - * @ordered - */ - protected String stringVal = STRING_VAL_DEFAULT_; - - /** - * This is true if the String Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean stringVal_set_ = false; - - /** - * The default value of the '{@link #isBooleanVal() <em>Boolean Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isBooleanVal() - * @generated - * @ordered - */ - protected static final boolean BOOLEAN_VAL_DEFAULT_ = false; - - /** - * The cached value of the '{@link #isBooleanVal() <em>Boolean Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isBooleanVal() - * @generated - * @ordered - */ - protected boolean booleanVal = BOOLEAN_VAL_DEFAULT_; - - /** - * This is true if the Boolean Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean booleanVal_set_ = false; - - /** - * The default value of the '{@link #getByteVal() <em>Byte Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getByteVal() - * @generated - * @ordered - */ - protected static final byte BYTE_VAL_DEFAULT_ = 0; - - /** - * The cached value of the '{@link #getByteVal() <em>Byte Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getByteVal() - * @generated - * @ordered - */ - protected byte byteVal = BYTE_VAL_DEFAULT_; - - /** - * This is true if the Byte Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean byteVal_set_ = false; - - /** - * The default value of the '{@link #getDecimalVal() <em>Decimal Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDecimalVal() - * @generated - * @ordered - */ - protected static final BigDecimal DECIMAL_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getDecimalVal() <em>Decimal Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDecimalVal() - * @generated - * @ordered - */ - protected BigDecimal decimalVal = DECIMAL_VAL_DEFAULT_; - - /** - * This is true if the Decimal Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean decimalVal_set_ = false; - - /** - * The default value of the '{@link #getIntVal() <em>Int Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getIntVal() - * @generated - * @ordered - */ - protected static final int INT_VAL_DEFAULT_ = 0; - - /** - * The cached value of the '{@link #getIntVal() <em>Int Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getIntVal() - * @generated - * @ordered - */ - protected int intVal = INT_VAL_DEFAULT_; - - /** - * This is true if the Int Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean intVal_set_ = false; - - /** - * The default value of the '{@link #getFloatVal() <em>Float Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getFloatVal() - * @generated - * @ordered - */ - protected static final float FLOAT_VAL_DEFAULT_ = 0.0F; - - /** - * The cached value of the '{@link #getFloatVal() <em>Float Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getFloatVal() - * @generated - * @ordered - */ - protected float floatVal = FLOAT_VAL_DEFAULT_; - - /** - * This is true if the Float Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean floatVal_set_ = false; - - /** - * The default value of the '{@link #getDoubleVal() <em>Double Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDoubleVal() - * @generated - * @ordered - */ - protected static final double DOUBLE_VAL_DEFAULT_ = 0.0; - - /** - * The cached value of the '{@link #getDoubleVal() <em>Double Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDoubleVal() - * @generated - * @ordered - */ - protected double doubleVal = DOUBLE_VAL_DEFAULT_; - - /** - * This is true if the Double Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean doubleVal_set_ = false; - - /** - * The default value of the '{@link #getDateVal() <em>Date Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDateVal() - * @generated - * @ordered - */ - protected static final String DATE_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getDateVal() <em>Date Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDateVal() - * @generated - * @ordered - */ - protected String dateVal = DATE_VAL_DEFAULT_; - - /** - * This is true if the Date Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean dateVal_set_ = false; - - /** - * The default value of the '{@link #getShortVal() <em>Short Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getShortVal() - * @generated - * @ordered - */ - protected static final short SHORT_VAL_DEFAULT_ = 0; - - /** - * The cached value of the '{@link #getShortVal() <em>Short Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getShortVal() - * @generated - * @ordered - */ - protected short shortVal = SHORT_VAL_DEFAULT_; - - /** - * This is true if the Short Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean shortVal_set_ = false; - - /** - * The default value of the '{@link #getLongVal() <em>Long Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLongVal() - * @generated - * @ordered - */ - protected static final long LONG_VAL_DEFAULT_ = 0L; - - /** - * The cached value of the '{@link #getLongVal() <em>Long Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLongVal() - * @generated - * @ordered - */ - protected long longVal = LONG_VAL_DEFAULT_; - - /** - * This is true if the Long Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean longVal_set_ = false; - - /** - * The cached value of the '{@link #getListVal() <em>List Val</em>}' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getListVal() - * @generated - * @ordered - */ - - protected List listVal = null; - - /** - * The default value of the '{@link #getBytesVal() <em>Bytes Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getBytesVal() - * @generated - * @ordered - */ - protected static final byte[] BYTES_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getBytesVal() <em>Bytes Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getBytesVal() - * @generated - * @ordered - */ - protected byte[] bytesVal = BYTES_VAL_DEFAULT_; - - /** - * This is true if the Bytes Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean bytesVal_set_ = false; - - /** - * The default value of the '{@link #getIntegerVal() <em>Integer Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getIntegerVal() - * @generated - * @ordered - */ - protected static final BigInteger INTEGER_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getIntegerVal() <em>Integer Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getIntegerVal() - * @generated - * @ordered - */ - protected BigInteger integerVal = INTEGER_VAL_DEFAULT_; - - /** - * This is true if the Integer Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean integerVal_set_ = false; - - /** - * The default value of the '{@link #getCharVal() <em>Char Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getCharVal() - * @generated - * @ordered - */ - protected static final String CHAR_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getCharVal() <em>Char Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getCharVal() - * @generated - * @ordered - */ - protected String charVal = CHAR_VAL_DEFAULT_; - - /** - * This is true if the Char Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean charVal_set_ = false; - - /** - * The default value of the '{@link #getReadOnlyVal() <em>Read Only Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getReadOnlyVal() - * @generated - * @ordered - */ - protected static final String READ_ONLY_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getReadOnlyVal() <em>Read Only Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getReadOnlyVal() - * @generated - * @ordered - */ - protected String readOnlyVal = READ_ONLY_VAL_DEFAULT_; - - /** - * This is true if the Read Only Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean readOnlyVal_set_ = false; - - /** - * The default value of the '{@link #getReadOnlyListVal() <em>Read Only List Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getReadOnlyListVal() - * @generated - * @ordered - */ - protected static final String READ_ONLY_LIST_VAL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getReadOnlyListVal() <em>Read Only List Val</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getReadOnlyListVal() - * @generated - * @ordered - */ - protected String readOnlyListVal = READ_ONLY_LIST_VAL_DEFAULT_; - - /** - * This is true if the Read Only List Val attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean readOnlyListVal_set_ = false; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ExpectedExceptionTypeImpl() - { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Type getStaticType() - { - return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getExpectedExceptionType(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getStringVal() - { - return stringVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setStringVal(String newStringVal) - { - String oldStringVal = stringVal; - stringVal = newStringVal; - boolean oldStringVal_set_ = stringVal_set_; - stringVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, STRING_VAL, oldStringVal, stringVal, !oldStringVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetStringVal() - { - String oldStringVal = stringVal; - boolean oldStringVal_set_ = stringVal_set_; - stringVal = STRING_VAL_DEFAULT_; - stringVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, STRING_VAL, oldStringVal, STRING_VAL_DEFAULT_, oldStringVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetStringVal() - { - return stringVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isBooleanVal() - { - return booleanVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setBooleanVal(boolean newBooleanVal) - { - boolean oldBooleanVal = booleanVal; - booleanVal = newBooleanVal; - boolean oldBooleanVal_set_ = booleanVal_set_; - booleanVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, BOOLEAN_VAL, oldBooleanVal, booleanVal, !oldBooleanVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetBooleanVal() - { - boolean oldBooleanVal = booleanVal; - boolean oldBooleanVal_set_ = booleanVal_set_; - booleanVal = BOOLEAN_VAL_DEFAULT_; - booleanVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, BOOLEAN_VAL, oldBooleanVal, BOOLEAN_VAL_DEFAULT_, oldBooleanVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetBooleanVal() - { - return booleanVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public byte getByteVal() - { - return byteVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setByteVal(byte newByteVal) - { - byte oldByteVal = byteVal; - byteVal = newByteVal; - boolean oldByteVal_set_ = byteVal_set_; - byteVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, BYTE_VAL, oldByteVal, byteVal, !oldByteVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetByteVal() - { - byte oldByteVal = byteVal; - boolean oldByteVal_set_ = byteVal_set_; - byteVal = BYTE_VAL_DEFAULT_; - byteVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, BYTE_VAL, oldByteVal, BYTE_VAL_DEFAULT_, oldByteVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetByteVal() - { - return byteVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public BigDecimal getDecimalVal() - { - return decimalVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDecimalVal(BigDecimal newDecimalVal) - { - BigDecimal oldDecimalVal = decimalVal; - decimalVal = newDecimalVal; - boolean oldDecimalVal_set_ = decimalVal_set_; - decimalVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, DECIMAL_VAL, oldDecimalVal, decimalVal, !oldDecimalVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetDecimalVal() - { - BigDecimal oldDecimalVal = decimalVal; - boolean oldDecimalVal_set_ = decimalVal_set_; - decimalVal = DECIMAL_VAL_DEFAULT_; - decimalVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, DECIMAL_VAL, oldDecimalVal, DECIMAL_VAL_DEFAULT_, oldDecimalVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetDecimalVal() - { - return decimalVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public int getIntVal() - { - return intVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setIntVal(int newIntVal) - { - int oldIntVal = intVal; - intVal = newIntVal; - boolean oldIntVal_set_ = intVal_set_; - intVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, INT_VAL, oldIntVal, intVal, !oldIntVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetIntVal() - { - int oldIntVal = intVal; - boolean oldIntVal_set_ = intVal_set_; - intVal = INT_VAL_DEFAULT_; - intVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, INT_VAL, oldIntVal, INT_VAL_DEFAULT_, oldIntVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetIntVal() - { - return intVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public float getFloatVal() - { - return floatVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setFloatVal(float newFloatVal) - { - float oldFloatVal = floatVal; - floatVal = newFloatVal; - boolean oldFloatVal_set_ = floatVal_set_; - floatVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, FLOAT_VAL, oldFloatVal, floatVal, !oldFloatVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetFloatVal() - { - float oldFloatVal = floatVal; - boolean oldFloatVal_set_ = floatVal_set_; - floatVal = FLOAT_VAL_DEFAULT_; - floatVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, FLOAT_VAL, oldFloatVal, FLOAT_VAL_DEFAULT_, oldFloatVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetFloatVal() - { - return floatVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public double getDoubleVal() - { - return doubleVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDoubleVal(double newDoubleVal) - { - double oldDoubleVal = doubleVal; - doubleVal = newDoubleVal; - boolean oldDoubleVal_set_ = doubleVal_set_; - doubleVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, DOUBLE_VAL, oldDoubleVal, doubleVal, !oldDoubleVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetDoubleVal() - { - double oldDoubleVal = doubleVal; - boolean oldDoubleVal_set_ = doubleVal_set_; - doubleVal = DOUBLE_VAL_DEFAULT_; - doubleVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, DOUBLE_VAL, oldDoubleVal, DOUBLE_VAL_DEFAULT_, oldDoubleVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetDoubleVal() - { - return doubleVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getDateVal() - { - return dateVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDateVal(String newDateVal) - { - String oldDateVal = dateVal; - dateVal = newDateVal; - boolean oldDateVal_set_ = dateVal_set_; - dateVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, DATE_VAL, oldDateVal, dateVal, !oldDateVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetDateVal() - { - String oldDateVal = dateVal; - boolean oldDateVal_set_ = dateVal_set_; - dateVal = DATE_VAL_DEFAULT_; - dateVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, DATE_VAL, oldDateVal, DATE_VAL_DEFAULT_, oldDateVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetDateVal() - { - return dateVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public short getShortVal() - { - return shortVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setShortVal(short newShortVal) - { - short oldShortVal = shortVal; - shortVal = newShortVal; - boolean oldShortVal_set_ = shortVal_set_; - shortVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, SHORT_VAL, oldShortVal, shortVal, !oldShortVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetShortVal() - { - short oldShortVal = shortVal; - boolean oldShortVal_set_ = shortVal_set_; - shortVal = SHORT_VAL_DEFAULT_; - shortVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, SHORT_VAL, oldShortVal, SHORT_VAL_DEFAULT_, oldShortVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetShortVal() - { - return shortVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public long getLongVal() - { - return longVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setLongVal(long newLongVal) - { - long oldLongVal = longVal; - longVal = newLongVal; - boolean oldLongVal_set_ = longVal_set_; - longVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, LONG_VAL, oldLongVal, longVal, !oldLongVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetLongVal() - { - long oldLongVal = longVal; - boolean oldLongVal_set_ = longVal_set_; - longVal = LONG_VAL_DEFAULT_; - longVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, LONG_VAL, oldLongVal, LONG_VAL_DEFAULT_, oldLongVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetLongVal() - { - return longVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public List getListVal() - { - if (listVal == null) - { - listVal = createPropertyList(ListKind.DATATYPE, String.class, LIST_VAL, 0); - } - return listVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public byte[] getBytesVal() - { - return bytesVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setBytesVal(byte[] newBytesVal) - { - byte[] oldBytesVal = bytesVal; - bytesVal = newBytesVal; - boolean oldBytesVal_set_ = bytesVal_set_; - bytesVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, BYTES_VAL, oldBytesVal, bytesVal, !oldBytesVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetBytesVal() - { - byte[] oldBytesVal = bytesVal; - boolean oldBytesVal_set_ = bytesVal_set_; - bytesVal = BYTES_VAL_DEFAULT_; - bytesVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, BYTES_VAL, oldBytesVal, BYTES_VAL_DEFAULT_, oldBytesVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetBytesVal() - { - return bytesVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public BigInteger getIntegerVal() - { - return integerVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setIntegerVal(BigInteger newIntegerVal) - { - BigInteger oldIntegerVal = integerVal; - integerVal = newIntegerVal; - boolean oldIntegerVal_set_ = integerVal_set_; - integerVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, INTEGER_VAL, oldIntegerVal, integerVal, !oldIntegerVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetIntegerVal() - { - BigInteger oldIntegerVal = integerVal; - boolean oldIntegerVal_set_ = integerVal_set_; - integerVal = INTEGER_VAL_DEFAULT_; - integerVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, INTEGER_VAL, oldIntegerVal, INTEGER_VAL_DEFAULT_, oldIntegerVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetIntegerVal() - { - return integerVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getCharVal() - { - return charVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCharVal(String newCharVal) - { - String oldCharVal = charVal; - charVal = newCharVal; - boolean oldCharVal_set_ = charVal_set_; - charVal_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, CHAR_VAL, oldCharVal, charVal, !oldCharVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetCharVal() - { - String oldCharVal = charVal; - boolean oldCharVal_set_ = charVal_set_; - charVal = CHAR_VAL_DEFAULT_; - charVal_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, CHAR_VAL, oldCharVal, CHAR_VAL_DEFAULT_, oldCharVal_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetCharVal() - { - return charVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getReadOnlyVal() - { - return readOnlyVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetReadOnlyVal() - { - return readOnlyVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getReadOnlyListVal() - { - return readOnlyListVal; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetReadOnlyListVal() - { - return readOnlyListVal_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object get(int propertyIndex, boolean resolve) - { - switch (propertyIndex) - { - case STRING_VAL: - return getStringVal(); - case BOOLEAN_VAL: - return isBooleanVal() ? Boolean.TRUE : Boolean.FALSE; - case BYTE_VAL: - return new Byte(getByteVal()); - case DECIMAL_VAL: - return getDecimalVal(); - case INT_VAL: - return new Integer(getIntVal()); - case FLOAT_VAL: - return new Float(getFloatVal()); - case DOUBLE_VAL: - return new Double(getDoubleVal()); - case DATE_VAL: - return getDateVal(); - case SHORT_VAL: - return new Short(getShortVal()); - case LONG_VAL: - return new Long(getLongVal()); - case LIST_VAL: - return getListVal(); - case BYTES_VAL: - return getBytesVal(); - case INTEGER_VAL: - return getIntegerVal(); - case CHAR_VAL: - return getCharVal(); - case READ_ONLY_VAL: - return getReadOnlyVal(); - case READ_ONLY_LIST_VAL: - return getReadOnlyListVal(); - } - return super.get(propertyIndex, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void set(int propertyIndex, Object newValue) - { - switch (propertyIndex) - { - case STRING_VAL: - setStringVal((String)newValue); - return; - case BOOLEAN_VAL: - setBooleanVal(((Boolean)newValue).booleanValue()); - return; - case BYTE_VAL: - setByteVal(((Byte)newValue).byteValue()); - return; - case DECIMAL_VAL: - setDecimalVal((BigDecimal)newValue); - return; - case INT_VAL: - setIntVal(((Integer)newValue).intValue()); - return; - case FLOAT_VAL: - setFloatVal(((Float)newValue).floatValue()); - return; - case DOUBLE_VAL: - setDoubleVal(((Double)newValue).doubleValue()); - return; - case DATE_VAL: - setDateVal((String)newValue); - return; - case SHORT_VAL: - setShortVal(((Short)newValue).shortValue()); - return; - case LONG_VAL: - setLongVal(((Long)newValue).longValue()); - return; - case LIST_VAL: - getListVal().clear(); - getListVal().addAll((Collection)newValue); - return; - case BYTES_VAL: - setBytesVal((byte[])newValue); - return; - case INTEGER_VAL: - setIntegerVal((BigInteger)newValue); - return; - case CHAR_VAL: - setCharVal((String)newValue); - return; - } - super.set(propertyIndex, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unset(int propertyIndex) - { - switch (propertyIndex) - { - case STRING_VAL: - unsetStringVal(); - return; - case BOOLEAN_VAL: - unsetBooleanVal(); - return; - case BYTE_VAL: - unsetByteVal(); - return; - case DECIMAL_VAL: - unsetDecimalVal(); - return; - case INT_VAL: - unsetIntVal(); - return; - case FLOAT_VAL: - unsetFloatVal(); - return; - case DOUBLE_VAL: - unsetDoubleVal(); - return; - case DATE_VAL: - unsetDateVal(); - return; - case SHORT_VAL: - unsetShortVal(); - return; - case LONG_VAL: - unsetLongVal(); - return; - case LIST_VAL: - getListVal().clear(); - return; - case BYTES_VAL: - unsetBytesVal(); - return; - case INTEGER_VAL: - unsetIntegerVal(); - return; - case CHAR_VAL: - unsetCharVal(); - return; - } - super.unset(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSet(int propertyIndex) - { - switch (propertyIndex) - { - case STRING_VAL: - return isSetStringVal(); - case BOOLEAN_VAL: - return isSetBooleanVal(); - case BYTE_VAL: - return isSetByteVal(); - case DECIMAL_VAL: - return isSetDecimalVal(); - case INT_VAL: - return isSetIntVal(); - case FLOAT_VAL: - return isSetFloatVal(); - case DOUBLE_VAL: - return isSetDoubleVal(); - case DATE_VAL: - return isSetDateVal(); - case SHORT_VAL: - return isSetShortVal(); - case LONG_VAL: - return isSetLongVal(); - case LIST_VAL: - return listVal != null && !listVal.isEmpty(); - case BYTES_VAL: - return isSetBytesVal(); - case INTEGER_VAL: - return isSetIntegerVal(); - case CHAR_VAL: - return isSetCharVal(); - case READ_ONLY_VAL: - return isSetReadOnlyVal(); - case READ_ONLY_LIST_VAL: - return isSetReadOnlyListVal(); - } - return super.isSet(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() - { - if (isProxy(this)) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (stringVal: "); - if (stringVal_set_) result.append(stringVal); else result.append("<unset>"); - result.append(", booleanVal: "); - if (booleanVal_set_) result.append(booleanVal); else result.append("<unset>"); - result.append(", byteVal: "); - if (byteVal_set_) result.append(byteVal); else result.append("<unset>"); - result.append(", decimalVal: "); - if (decimalVal_set_) result.append(decimalVal); else result.append("<unset>"); - result.append(", intVal: "); - if (intVal_set_) result.append(intVal); else result.append("<unset>"); - result.append(", floatVal: "); - if (floatVal_set_) result.append(floatVal); else result.append("<unset>"); - result.append(", doubleVal: "); - if (doubleVal_set_) result.append(doubleVal); else result.append("<unset>"); - result.append(", dateVal: "); - if (dateVal_set_) result.append(dateVal); else result.append("<unset>"); - result.append(", shortVal: "); - if (shortVal_set_) result.append(shortVal); else result.append("<unset>"); - result.append(", longVal: "); - if (longVal_set_) result.append(longVal); else result.append("<unset>"); - result.append(", listVal: "); - result.append(listVal); - result.append(", bytesVal: "); - if (bytesVal_set_) result.append(bytesVal); else result.append("<unset>"); - result.append(", integerVal: "); - if (integerVal_set_) result.append(integerVal); else result.append("<unset>"); - result.append(", charVal: "); - if (charVal_set_) result.append(charVal); else result.append("<unset>"); - result.append(", readOnlyVal: "); - if (readOnlyVal_set_) result.append(readOnlyVal); else result.append("<unset>"); - result.append(", readOnlyListVal: "); - if (readOnlyListVal_set_) result.append(readOnlyListVal); else result.append("<unset>"); - result.append(')'); - return result.toString(); - } - -} //ExpectedExceptionTypeImpl diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java deleted file mode 100644 index 048cb439db..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java +++ /dev/null @@ -1,354 +0,0 @@ -/** - * - * 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.SequenceReadOnlyType; - -import commonj.sdo.Sequence; -import commonj.sdo.Type; - -import org.apache.tuscany.sdo.impl.DataObjectBase; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Sequence Read Only Type</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getMixed <em>Mixed</em>}</li> - * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyVal <em>Read Only Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyListVal <em>Read Only List Val</em>}</li> - * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getUniqueName <em>Unique Name</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class SequenceReadOnlyTypeImpl extends DataObjectBase implements SequenceReadOnlyType -{ - - public final static int MIXED = -1; - - public final static int READ_ONLY_VAL = 0; - - public final static int READ_ONLY_LIST_VAL = 1; - - public final static int UNIQUE_NAME = 2; - - public final static int SDO_PROPERTY_COUNT = 3; - - public final static int EXTENDED_PROPERTY_COUNT = -1; - - - /** - * The internal feature id for the '<em><b>Mixed</b></em>' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_MIXED = 0; - - /** - * The internal feature id for the '<em><b>Read Only Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_READ_ONLY_VAL = 1; - - /** - * The internal feature id for the '<em><b>Read Only List Val</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_READ_ONLY_LIST_VAL = 2; - - /** - * The internal feature id for the '<em><b>Unique Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_UNIQUE_NAME = 3; - - /** - * The number of properties for this type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_PROPERTY_COUNT = 4; - - protected int internalConvertIndex(int internalIndex) - { - switch (internalIndex) - { - case INTERNAL_MIXED: return MIXED; - case INTERNAL_READ_ONLY_VAL: return READ_ONLY_VAL; - case INTERNAL_READ_ONLY_LIST_VAL: return READ_ONLY_LIST_VAL; - case INTERNAL_UNIQUE_NAME: return UNIQUE_NAME; - } - return super.internalConvertIndex(internalIndex); - } - - - /** - * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getMixed() - * @generated - * @ordered - */ - - protected Sequence mixed = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SequenceReadOnlyTypeImpl() - { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Type getStaticType() - { - return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getSequenceReadOnlyType(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Sequence getMixed() - { - if (mixed == null) - { - mixed = createSequence(INTERNAL_MIXED); - } - return mixed; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getReadOnlyVal() - { - return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_VAL); - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetReadOnlyVal() - { - return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_VAL); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getReadOnlyListVal() - { - return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL); - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetReadOnlyListVal() - { - return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getUniqueName() - { - return (String)get(getMixed(), getType(), INTERNAL_UNIQUE_NAME); - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setUniqueName(String newUniqueName) - { - set(getMixed(), getType(), INTERNAL_UNIQUE_NAME, newUniqueName); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetUniqueName() - { - unset(getMixed(), getType(), INTERNAL_UNIQUE_NAME); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetUniqueName() - { - return isSet(getMixed(), getType(), INTERNAL_UNIQUE_NAME); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) - { - switch (propertyIndex) - { - case MIXED: - return removeFromSequence(getMixed(), otherEnd, changeContext); - } - return super.inverseRemove(otherEnd, propertyIndex, changeContext); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object get(int propertyIndex, boolean resolve) - { - switch (propertyIndex) - { - case MIXED: - // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view - //if (coreType) - return getMixed(); - case READ_ONLY_VAL: - return getReadOnlyVal(); - case READ_ONLY_LIST_VAL: - return getReadOnlyListVal(); - case UNIQUE_NAME: - return getUniqueName(); - } - return super.get(propertyIndex, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void set(int propertyIndex, Object newValue) - { - switch (propertyIndex) - { - case MIXED: - setSequence(getMixed(), newValue); - return; - case UNIQUE_NAME: - setUniqueName((String)newValue); - return; - } - super.set(propertyIndex, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unset(int propertyIndex) - { - switch (propertyIndex) - { - case MIXED: - unsetSequence(getMixed()); - return; - case UNIQUE_NAME: - unsetUniqueName(); - return; - } - super.unset(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSet(int propertyIndex) - { - switch (propertyIndex) - { - case MIXED: - return mixed != null && !isSequenceEmpty(getMixed()); - case READ_ONLY_VAL: - return isSetReadOnlyVal(); - case READ_ONLY_LIST_VAL: - return isSetReadOnlyListVal(); - case UNIQUE_NAME: - return isSetUniqueName(); - } - return super.isSet(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() - { - if (isProxy(this)) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (mixed: "); - result.append(mixed); - result.append(')'); - return result.toString(); - } - -} //SequenceReadOnlyTypeImpl diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/Quote.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/Quote.java deleted file mode 100644 index 48dcf96d64..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/Quote.java +++ /dev/null @@ -1,475 +0,0 @@ -/** - * - * 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 java.io.Serializable; - -import java.math.BigDecimal; - -import java.util.List; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Quote</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link com.example.simple.Quote#getSymbol <em>Symbol</em>}</li> - * <li>{@link com.example.simple.Quote#getCompanyName <em>Company Name</em>}</li> - * <li>{@link com.example.simple.Quote#getPrice <em>Price</em>}</li> - * <li>{@link com.example.simple.Quote#getOpen1 <em>Open1</em>}</li> - * <li>{@link com.example.simple.Quote#getHigh <em>High</em>}</li> - * <li>{@link com.example.simple.Quote#getLow <em>Low</em>}</li> - * <li>{@link com.example.simple.Quote#getVolume <em>Volume</em>}</li> - * <li>{@link com.example.simple.Quote#getChange1 <em>Change1</em>}</li> - * <li>{@link com.example.simple.Quote#getQuotes <em>Quotes</em>}</li> - * </ul> - * </p> - * - * @extends Serializable - * @generated - */ -public interface Quote extends Serializable -{ - /** - * Returns the value of the '<em><b>Symbol</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Symbol</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Symbol</em>' attribute. - * @see #isSetSymbol() - * @see #unsetSymbol() - * @see #setSymbol(String) - * @generated - */ - String getSymbol(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getSymbol <em>Symbol</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Symbol</em>' attribute. - * @see #isSetSymbol() - * @see #unsetSymbol() - * @see #getSymbol() - * @generated - */ - void setSymbol(String value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getSymbol <em>Symbol</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetSymbol() - * @see #getSymbol() - * @see #setSymbol(String) - * @generated - */ - void unsetSymbol(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getSymbol <em>Symbol</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Symbol</em>' attribute is set. - * @see #unsetSymbol() - * @see #getSymbol() - * @see #setSymbol(String) - * @generated - */ - boolean isSetSymbol(); - - /** - * Returns the value of the '<em><b>Company Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Company Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Company Name</em>' attribute. - * @see #isSetCompanyName() - * @see #unsetCompanyName() - * @see #setCompanyName(String) - * @generated - */ - String getCompanyName(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getCompanyName <em>Company Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Company Name</em>' attribute. - * @see #isSetCompanyName() - * @see #unsetCompanyName() - * @see #getCompanyName() - * @generated - */ - void setCompanyName(String value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getCompanyName <em>Company Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetCompanyName() - * @see #getCompanyName() - * @see #setCompanyName(String) - * @generated - */ - void unsetCompanyName(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getCompanyName <em>Company Name</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Company Name</em>' attribute is set. - * @see #unsetCompanyName() - * @see #getCompanyName() - * @see #setCompanyName(String) - * @generated - */ - boolean isSetCompanyName(); - - /** - * Returns the value of the '<em><b>Price</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Price</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Price</em>' attribute. - * @see #isSetPrice() - * @see #unsetPrice() - * @see #setPrice(BigDecimal) - * @generated - */ - BigDecimal getPrice(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getPrice <em>Price</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Price</em>' attribute. - * @see #isSetPrice() - * @see #unsetPrice() - * @see #getPrice() - * @generated - */ - void setPrice(BigDecimal value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getPrice <em>Price</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetPrice() - * @see #getPrice() - * @see #setPrice(BigDecimal) - * @generated - */ - void unsetPrice(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getPrice <em>Price</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Price</em>' attribute is set. - * @see #unsetPrice() - * @see #getPrice() - * @see #setPrice(BigDecimal) - * @generated - */ - boolean isSetPrice(); - - /** - * Returns the value of the '<em><b>Open1</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Open1</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Open1</em>' attribute. - * @see #isSetOpen1() - * @see #unsetOpen1() - * @see #setOpen1(BigDecimal) - * @generated - */ - BigDecimal getOpen1(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getOpen1 <em>Open1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Open1</em>' attribute. - * @see #isSetOpen1() - * @see #unsetOpen1() - * @see #getOpen1() - * @generated - */ - void setOpen1(BigDecimal value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getOpen1 <em>Open1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetOpen1() - * @see #getOpen1() - * @see #setOpen1(BigDecimal) - * @generated - */ - void unsetOpen1(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getOpen1 <em>Open1</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Open1</em>' attribute is set. - * @see #unsetOpen1() - * @see #getOpen1() - * @see #setOpen1(BigDecimal) - * @generated - */ - boolean isSetOpen1(); - - /** - * Returns the value of the '<em><b>High</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>High</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>High</em>' attribute. - * @see #isSetHigh() - * @see #unsetHigh() - * @see #setHigh(BigDecimal) - * @generated - */ - BigDecimal getHigh(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getHigh <em>High</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>High</em>' attribute. - * @see #isSetHigh() - * @see #unsetHigh() - * @see #getHigh() - * @generated - */ - void setHigh(BigDecimal value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getHigh <em>High</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetHigh() - * @see #getHigh() - * @see #setHigh(BigDecimal) - * @generated - */ - void unsetHigh(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getHigh <em>High</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>High</em>' attribute is set. - * @see #unsetHigh() - * @see #getHigh() - * @see #setHigh(BigDecimal) - * @generated - */ - boolean isSetHigh(); - - /** - * Returns the value of the '<em><b>Low</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Low</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Low</em>' attribute. - * @see #isSetLow() - * @see #unsetLow() - * @see #setLow(BigDecimal) - * @generated - */ - BigDecimal getLow(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getLow <em>Low</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Low</em>' attribute. - * @see #isSetLow() - * @see #unsetLow() - * @see #getLow() - * @generated - */ - void setLow(BigDecimal value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getLow <em>Low</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetLow() - * @see #getLow() - * @see #setLow(BigDecimal) - * @generated - */ - void unsetLow(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getLow <em>Low</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Low</em>' attribute is set. - * @see #unsetLow() - * @see #getLow() - * @see #setLow(BigDecimal) - * @generated - */ - boolean isSetLow(); - - /** - * Returns the value of the '<em><b>Volume</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Volume</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Volume</em>' attribute. - * @see #isSetVolume() - * @see #unsetVolume() - * @see #setVolume(double) - * @generated - */ - double getVolume(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getVolume <em>Volume</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Volume</em>' attribute. - * @see #isSetVolume() - * @see #unsetVolume() - * @see #getVolume() - * @generated - */ - void setVolume(double value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getVolume <em>Volume</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetVolume() - * @see #getVolume() - * @see #setVolume(double) - * @generated - */ - void unsetVolume(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getVolume <em>Volume</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Volume</em>' attribute is set. - * @see #unsetVolume() - * @see #getVolume() - * @see #setVolume(double) - * @generated - */ - boolean isSetVolume(); - - /** - * Returns the value of the '<em><b>Change1</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Change1</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Change1</em>' attribute. - * @see #isSetChange1() - * @see #unsetChange1() - * @see #setChange1(double) - * @generated - */ - double getChange1(); - - /** - * Sets the value of the '{@link com.example.simple.Quote#getChange1 <em>Change1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Change1</em>' attribute. - * @see #isSetChange1() - * @see #unsetChange1() - * @see #getChange1() - * @generated - */ - void setChange1(double value); - - /** - * Unsets the value of the '{@link com.example.simple.Quote#getChange1 <em>Change1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetChange1() - * @see #getChange1() - * @see #setChange1(double) - * @generated - */ - void unsetChange1(); - - /** - * Returns whether the value of the '{@link com.example.simple.Quote#getChange1 <em>Change1</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Change1</em>' attribute is set. - * @see #unsetChange1() - * @see #getChange1() - * @see #setChange1(double) - * @generated - */ - boolean isSetChange1(); - - /** - * Returns the value of the '<em><b>Quotes</b></em>' containment reference list. - * The list contents are of type {@link com.example.simple.Quote}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Quotes</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Quotes</em>' containment reference list. - * @generated - */ - List getQuotes(); - -} // Quote diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/SimpleFactory.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/SimpleFactory.java deleted file mode 100644 index 98dc01d69a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/SimpleFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * 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; - - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <!-- end-user-doc --> - * @generated - */ -public interface SimpleFactory -{ - - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - SimpleFactory INSTANCE = com.example.simple.impl.SimpleFactoryImpl.init(); - - /** - * Returns a new object of class '<em>Quote</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Quote</em>'. - * @generated - */ - Quote createQuote(); - - /** - * Registers the types supported by this Factory within the supplied scope.argument - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param scope an instance of HelperContext used to manage the scoping of types. - * @generated - */ - public void register(HelperContext scope); - -} //SimpleFactory diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/impl/QuoteImpl.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/impl/QuoteImpl.java deleted file mode 100644 index 39af3bbdb2..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/impl/QuoteImpl.java +++ /dev/null @@ -1,1045 +0,0 @@ -/** - * - * 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; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Quote</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link com.example.simple.impl.QuoteImpl#getSymbol <em>Symbol</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getCompanyName <em>Company Name</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getPrice <em>Price</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getOpen1 <em>Open1</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getHigh <em>High</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getLow <em>Low</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getVolume <em>Volume</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getChange1 <em>Change1</em>}</li> - * <li>{@link com.example.simple.impl.QuoteImpl#getQuotes <em>Quotes</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class QuoteImpl extends DataObjectBase implements Quote -{ - - public final static int SYMBOL = 0; - - public final static int COMPANY_NAME = 1; - - public final static int PRICE = 2; - - public final static int OPEN1 = 3; - - public final static int HIGH = 4; - - public final static int LOW = 5; - - public final static int VOLUME = 6; - - public final static int CHANGE1 = 7; - - public final static int QUOTES = 8; - - public final static int SDO_PROPERTY_COUNT = 9; - - public final static int EXTENDED_PROPERTY_COUNT = 0; - - - /** - * The internal feature id for the '<em><b>Symbol</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_SYMBOL = 0; - - /** - * The internal feature id for the '<em><b>Company Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_COMPANY_NAME = 1; - - /** - * The internal feature id for the '<em><b>Price</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_PRICE = 2; - - /** - * The internal feature id for the '<em><b>Open1</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_OPEN1 = 3; - - /** - * The internal feature id for the '<em><b>High</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_HIGH = 4; - - /** - * The internal feature id for the '<em><b>Low</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_LOW = 5; - - /** - * The internal feature id for the '<em><b>Volume</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_VOLUME = 6; - - /** - * The internal feature id for the '<em><b>Change1</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_CHANGE1 = 7; - - /** - * The internal feature id for the '<em><b>Quotes</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_QUOTES = 8; - - /** - * The number of properties for this type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_PROPERTY_COUNT = 9; - - protected int internalConvertIndex(int internalIndex) - { - switch (internalIndex) - { - case INTERNAL_SYMBOL: return SYMBOL; - case INTERNAL_COMPANY_NAME: return COMPANY_NAME; - case INTERNAL_PRICE: return PRICE; - case INTERNAL_OPEN1: return OPEN1; - case INTERNAL_HIGH: return HIGH; - case INTERNAL_LOW: return LOW; - case INTERNAL_VOLUME: return VOLUME; - case INTERNAL_CHANGE1: return CHANGE1; - case INTERNAL_QUOTES: return QUOTES; - } - return super.internalConvertIndex(internalIndex); - } - - - /** - * The default value of the '{@link #getSymbol() <em>Symbol</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSymbol() - * @generated - * @ordered - */ - protected static final String SYMBOL_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getSymbol() <em>Symbol</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSymbol() - * @generated - * @ordered - */ - protected String symbol = SYMBOL_DEFAULT_; - - /** - * This is true if the Symbol attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean symbol_set_ = false; - - /** - * The default value of the '{@link #getCompanyName() <em>Company Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getCompanyName() - * @generated - * @ordered - */ - protected static final String COMPANY_NAME_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getCompanyName() <em>Company Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getCompanyName() - * @generated - * @ordered - */ - protected String companyName = COMPANY_NAME_DEFAULT_; - - /** - * This is true if the Company Name attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean companyName_set_ = false; - - /** - * The default value of the '{@link #getPrice() <em>Price</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPrice() - * @generated - * @ordered - */ - protected static final BigDecimal PRICE_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getPrice() <em>Price</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPrice() - * @generated - * @ordered - */ - protected BigDecimal price = PRICE_DEFAULT_; - - /** - * This is true if the Price attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean price_set_ = false; - - /** - * The default value of the '{@link #getOpen1() <em>Open1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getOpen1() - * @generated - * @ordered - */ - protected static final BigDecimal OPEN1_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getOpen1() <em>Open1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getOpen1() - * @generated - * @ordered - */ - protected BigDecimal open1 = OPEN1_DEFAULT_; - - /** - * This is true if the Open1 attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean open1_set_ = false; - - /** - * The default value of the '{@link #getHigh() <em>High</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getHigh() - * @generated - * @ordered - */ - protected static final BigDecimal HIGH_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getHigh() <em>High</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getHigh() - * @generated - * @ordered - */ - protected BigDecimal high = HIGH_DEFAULT_; - - /** - * This is true if the High attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean high_set_ = false; - - /** - * The default value of the '{@link #getLow() <em>Low</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLow() - * @generated - * @ordered - */ - protected static final BigDecimal LOW_DEFAULT_ = null; - - /** - * The cached value of the '{@link #getLow() <em>Low</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLow() - * @generated - * @ordered - */ - protected BigDecimal low = LOW_DEFAULT_; - - /** - * This is true if the Low attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean low_set_ = false; - - /** - * The default value of the '{@link #getVolume() <em>Volume</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVolume() - * @generated - * @ordered - */ - protected static final double VOLUME_DEFAULT_ = 0.0; - - /** - * The cached value of the '{@link #getVolume() <em>Volume</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVolume() - * @generated - * @ordered - */ - protected double volume = VOLUME_DEFAULT_; - - /** - * This is true if the Volume attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean volume_set_ = false; - - /** - * The default value of the '{@link #getChange1() <em>Change1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getChange1() - * @generated - * @ordered - */ - protected static final double CHANGE1_DEFAULT_ = 0.0; - - /** - * The cached value of the '{@link #getChange1() <em>Change1</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getChange1() - * @generated - * @ordered - */ - protected double change1 = CHANGE1_DEFAULT_; - - /** - * This is true if the Change1 attribute has been set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - protected boolean change1_set_ = false; - - /** - * The cached value of the '{@link #getQuotes() <em>Quotes</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getQuotes() - * @generated - * @ordered - */ - - protected List quotes = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public QuoteImpl() - { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Type getStaticType() - { - return ((SimpleFactoryImpl)SimpleFactory.INSTANCE).getQuote(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getSymbol() - { - return symbol; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSymbol(String newSymbol) - { - String oldSymbol = symbol; - symbol = newSymbol; - boolean oldSymbol_set_ = symbol_set_; - symbol_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, SYMBOL, oldSymbol, symbol, !oldSymbol_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetSymbol() - { - String oldSymbol = symbol; - boolean oldSymbol_set_ = symbol_set_; - symbol = SYMBOL_DEFAULT_; - symbol_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, SYMBOL, oldSymbol, SYMBOL_DEFAULT_, oldSymbol_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetSymbol() - { - return symbol_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getCompanyName() - { - return companyName; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCompanyName(String newCompanyName) - { - String oldCompanyName = companyName; - companyName = newCompanyName; - boolean oldCompanyName_set_ = companyName_set_; - companyName_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, COMPANY_NAME, oldCompanyName, companyName, !oldCompanyName_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetCompanyName() - { - String oldCompanyName = companyName; - boolean oldCompanyName_set_ = companyName_set_; - companyName = COMPANY_NAME_DEFAULT_; - companyName_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, COMPANY_NAME, oldCompanyName, COMPANY_NAME_DEFAULT_, oldCompanyName_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetCompanyName() - { - return companyName_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public BigDecimal getPrice() - { - return price; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setPrice(BigDecimal newPrice) - { - BigDecimal oldPrice = price; - price = newPrice; - boolean oldPrice_set_ = price_set_; - price_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, PRICE, oldPrice, price, !oldPrice_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetPrice() - { - BigDecimal oldPrice = price; - boolean oldPrice_set_ = price_set_; - price = PRICE_DEFAULT_; - price_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, PRICE, oldPrice, PRICE_DEFAULT_, oldPrice_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetPrice() - { - return price_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public BigDecimal getOpen1() - { - return open1; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setOpen1(BigDecimal newOpen1) - { - BigDecimal oldOpen1 = open1; - open1 = newOpen1; - boolean oldOpen1_set_ = open1_set_; - open1_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, OPEN1, oldOpen1, open1, !oldOpen1_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetOpen1() - { - BigDecimal oldOpen1 = open1; - boolean oldOpen1_set_ = open1_set_; - open1 = OPEN1_DEFAULT_; - open1_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, OPEN1, oldOpen1, OPEN1_DEFAULT_, oldOpen1_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetOpen1() - { - return open1_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public BigDecimal getHigh() - { - return high; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setHigh(BigDecimal newHigh) - { - BigDecimal oldHigh = high; - high = newHigh; - boolean oldHigh_set_ = high_set_; - high_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, HIGH, oldHigh, high, !oldHigh_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetHigh() - { - BigDecimal oldHigh = high; - boolean oldHigh_set_ = high_set_; - high = HIGH_DEFAULT_; - high_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, HIGH, oldHigh, HIGH_DEFAULT_, oldHigh_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetHigh() - { - return high_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public BigDecimal getLow() - { - return low; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setLow(BigDecimal newLow) - { - BigDecimal oldLow = low; - low = newLow; - boolean oldLow_set_ = low_set_; - low_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, LOW, oldLow, low, !oldLow_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetLow() - { - BigDecimal oldLow = low; - boolean oldLow_set_ = low_set_; - low = LOW_DEFAULT_; - low_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, LOW, oldLow, LOW_DEFAULT_, oldLow_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetLow() - { - return low_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public double getVolume() - { - return volume; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setVolume(double newVolume) - { - double oldVolume = volume; - volume = newVolume; - boolean oldVolume_set_ = volume_set_; - volume_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, VOLUME, oldVolume, volume, !oldVolume_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetVolume() - { - double oldVolume = volume; - boolean oldVolume_set_ = volume_set_; - volume = VOLUME_DEFAULT_; - volume_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, VOLUME, oldVolume, VOLUME_DEFAULT_, oldVolume_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetVolume() - { - return volume_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public double getChange1() - { - return change1; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setChange1(double newChange1) - { - double oldChange1 = change1; - change1 = newChange1; - boolean oldChange1_set_ = change1_set_; - change1_set_ = true; - if (isNotifying()) - notify(ChangeKind.SET, CHANGE1, oldChange1, change1, !oldChange1_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetChange1() - { - double oldChange1 = change1; - boolean oldChange1_set_ = change1_set_; - change1 = CHANGE1_DEFAULT_; - change1_set_ = false; - if (isNotifying()) - notify(ChangeKind.UNSET, CHANGE1, oldChange1, CHANGE1_DEFAULT_, oldChange1_set_); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetChange1() - { - return change1_set_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public List getQuotes() - { - if (quotes == null) - { - quotes = createPropertyList(ListKind.CONTAINMENT, Quote.class, QUOTES, 0); - } - return quotes; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) - { - switch (propertyIndex) - { - case QUOTES: - return removeFromList(getQuotes(), otherEnd, changeContext); - } - return super.inverseRemove(otherEnd, propertyIndex, changeContext); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object get(int propertyIndex, boolean resolve) - { - switch (propertyIndex) - { - case SYMBOL: - return getSymbol(); - case COMPANY_NAME: - return getCompanyName(); - case PRICE: - return getPrice(); - case OPEN1: - return getOpen1(); - case HIGH: - return getHigh(); - case LOW: - return getLow(); - case VOLUME: - return new Double(getVolume()); - case CHANGE1: - return new Double(getChange1()); - case QUOTES: - return getQuotes(); - } - return super.get(propertyIndex, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void set(int propertyIndex, Object newValue) - { - switch (propertyIndex) - { - case SYMBOL: - setSymbol((String)newValue); - return; - case COMPANY_NAME: - setCompanyName((String)newValue); - return; - case PRICE: - setPrice((BigDecimal)newValue); - return; - case OPEN1: - setOpen1((BigDecimal)newValue); - return; - case HIGH: - setHigh((BigDecimal)newValue); - return; - case LOW: - setLow((BigDecimal)newValue); - return; - case VOLUME: - setVolume(((Double)newValue).doubleValue()); - return; - case CHANGE1: - setChange1(((Double)newValue).doubleValue()); - return; - case QUOTES: - getQuotes().clear(); - getQuotes().addAll((Collection)newValue); - return; - } - super.set(propertyIndex, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unset(int propertyIndex) - { - switch (propertyIndex) - { - case SYMBOL: - unsetSymbol(); - return; - case COMPANY_NAME: - unsetCompanyName(); - return; - case PRICE: - unsetPrice(); - return; - case OPEN1: - unsetOpen1(); - return; - case HIGH: - unsetHigh(); - return; - case LOW: - unsetLow(); - return; - case VOLUME: - unsetVolume(); - return; - case CHANGE1: - unsetChange1(); - return; - case QUOTES: - getQuotes().clear(); - return; - } - super.unset(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSet(int propertyIndex) - { - switch (propertyIndex) - { - case SYMBOL: - return isSetSymbol(); - case COMPANY_NAME: - return isSetCompanyName(); - case PRICE: - return isSetPrice(); - case OPEN1: - return isSetOpen1(); - case HIGH: - return isSetHigh(); - case LOW: - return isSetLow(); - case VOLUME: - return isSetVolume(); - case CHANGE1: - return isSetChange1(); - case QUOTES: - return quotes != null && !quotes.isEmpty(); - } - return super.isSet(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() - { - if (isProxy(this)) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (symbol: "); - if (symbol_set_) result.append(symbol); else result.append("<unset>"); - result.append(", companyName: "); - if (companyName_set_) result.append(companyName); else result.append("<unset>"); - result.append(", price: "); - if (price_set_) result.append(price); else result.append("<unset>"); - result.append(", open1: "); - if (open1_set_) result.append(open1); else result.append("<unset>"); - result.append(", high: "); - if (high_set_) result.append(high); else result.append("<unset>"); - result.append(", low: "); - if (low_set_) result.append(low); else result.append("<unset>"); - result.append(", volume: "); - if (volume_set_) result.append(volume); else result.append("<unset>"); - result.append(", change1: "); - if (change1_set_) result.append(change1); else result.append("<unset>"); - result.append(')'); - return result.toString(); - } - -} //QuoteImpl diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java deleted file mode 100644 index 51099d70a7..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java +++ /dev/null @@ -1,330 +0,0 @@ -/** - * - * 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 commonj.sdo.helper.HelperContext; -import org.apache.tuscany.sdo.helper.TypeHelperImpl; - -import com.example.simple.*; - -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; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * Generator information: - * patternVersion=1.2; - * <!-- end-user-doc --> - * @generated - */ -public class SimpleFactoryImpl extends FactoryBase implements SimpleFactory -{ - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String NAMESPACE_URI = "http://www.example.com/simple"; - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String NAMESPACE_PREFIX = "simple"; - - /** - * The version of the generator pattern used to generate this class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String PATTERN_VERSION = "1.2"; - - public static final int QUOTE = 1; - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SimpleFactoryImpl() - { - super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.example.simple"); - } - - /** - * Registers the Factory instance so that it is available within the supplied scope. - * @argument scope a HelperContext instance that will make the types supported by this Factory available. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void register(HelperContext scope) { - if(scope == null) { - throw new IllegalArgumentException("Scope can not be null"); - } - TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); - th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public DataObject create(int typeNumber) - { - switch (typeNumber) - { - case QUOTE: return (DataObject)createQuote(); - default: - return super.create(typeNumber); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Quote createQuote() - { - QuoteImpl quote = new QuoteImpl(); - return quote; - } - - // Following creates and initializes SDO metadata for the supported types. - protected Type quoteType = null; - - public Type getQuote() - { - return quoteType; - } - - - private static boolean isInited = false; - - public static SimpleFactoryImpl init() - { - if (isInited) return (SimpleFactoryImpl)FactoryBase.getStaticFactory(SimpleFactoryImpl.NAMESPACE_URI); - SimpleFactoryImpl theSimpleFactoryImpl = new SimpleFactoryImpl(); - isInited = true; - - // Initialize dependencies - SDOUtil.registerStaticTypes(SDOFactory.class); - SDOUtil.registerStaticTypes(ModelFactory.class); - SDOUtil.registerStaticTypes(InternalFactory.class); - - // Create package meta-data objects - theSimpleFactoryImpl.createMetaData(); - - // Initialize created meta-data - theSimpleFactoryImpl.initializeMetaData(); - - // Mark meta-data to indicate it can't be changed - //theSimpleFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? - - return theSimpleFactoryImpl; - } - - private boolean isCreated = false; - - public void createMetaData() - { - if (isCreated) return; - isCreated = true; - - // Create types and their properties - quoteType = createType(false, QUOTE); - createProperty(true, quoteType,QuoteImpl.INTERNAL_SYMBOL); - createProperty(true, quoteType,QuoteImpl.INTERNAL_COMPANY_NAME); - createProperty(true, quoteType,QuoteImpl.INTERNAL_PRICE); - createProperty(true, quoteType,QuoteImpl.INTERNAL_OPEN1); - createProperty(true, quoteType,QuoteImpl.INTERNAL_HIGH); - createProperty(true, quoteType,QuoteImpl.INTERNAL_LOW); - createProperty(true, quoteType,QuoteImpl.INTERNAL_VOLUME); - createProperty(true, quoteType,QuoteImpl.INTERNAL_CHANGE1); - createProperty(false, quoteType,QuoteImpl.INTERNAL_QUOTES); - } - - 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(quoteType, Quote.class, "Quote", false); - property = getLocalProperty(quoteType, 0); - initializeProperty(property, theModelPackageImpl.getString(), "symbol", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 1); - initializeProperty(property, theModelPackageImpl.getString(), "companyName", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 2); - initializeProperty(property, theModelPackageImpl.getDecimal(), "price", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 3); - initializeProperty(property, theModelPackageImpl.getDecimal(), "open1", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 4); - initializeProperty(property, theModelPackageImpl.getDecimal(), "high", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 5); - initializeProperty(property, theModelPackageImpl.getDecimal(), "low", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 6); - initializeProperty(property, theModelPackageImpl.getDouble(), "volume", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 7); - initializeProperty(property, theModelPackageImpl.getDouble(), "change1", null, 1, 1, Quote.class, false, true, false); - - property = getLocalProperty(quoteType, 8); - initializeProperty(property, this.getQuote(), "quotes", null, 0, -1, Quote.class, false, false, false, true , null); - - createXSDMetaData(theModelPackageImpl); - } - - protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl) - { - super.initXSD(); - - Property property = null; - - - property = createGlobalProperty - ("stockQuote", - this.getQuote(), - new String[] - { - "kind", "element", - "name", "stockQuote", - "namespace", "##targetNamespace" - }); - - addXSDMapping - (quoteType, - new String[] - { - "name", "Quote", - "kind", "elementOnly" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_SYMBOL), - new String[] - { - "kind", "element", - "name", "symbol" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_COMPANY_NAME), - new String[] - { - "kind", "element", - "name", "companyName" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_PRICE), - new String[] - { - "kind", "element", - "name", "price" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_OPEN1), - new String[] - { - "kind", "element", - "name", "open1" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_HIGH), - new String[] - { - "kind", "element", - "name", "high" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_LOW), - new String[] - { - "kind", "element", - "name", "low" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_VOLUME), - new String[] - { - "kind", "element", - "name", "volume" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_CHANGE1), - new String[] - { - "kind", "element", - "name", "change1" - }); - - addXSDMapping - (getProperty(quoteType, QuoteImpl.INTERNAL_QUOTES), - new String[] - { - "kind", "element", - "name", "quotes" - }); - - } - -} //SimpleFactoryImpl diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java deleted file mode 100644 index c8ee9a96c8..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.example.test.Containment; - -import commonj.sdo.helper.HelperContext; - - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <!-- end-user-doc --> - * @generated - */ -public interface ContainmentFactory -{ - - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - ContainmentFactory INSTANCE = com.example.test.Containment.impl.ContainmentFactoryImpl.init(); - - /** - * Returns a new object of class '<em>Test</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Test</em>'. - * @generated - */ - ContainmentTest createContainmentTest(); - - /** - * Registers the types supported by this Factory within the supplied scope.argument - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param scope an instance of HelperContext used to manage the scoping of types. - * @generated - */ - public void register(HelperContext scope); - -} //ContainmentFactory diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/ContainmentTest.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/ContainmentTest.java deleted file mode 100644 index 64734b8862..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/ContainmentTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.example.test.Containment; - -import commonj.sdo.Sequence; - -import java.io.Serializable; - -import java.util.List; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Test</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link com.example.test.Containment.ContainmentTest#getMixed <em>Mixed</em>}</li> - * <li>{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}</li> - * <li>{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}</li> - * <li>{@link com.example.test.Containment.ContainmentTest#getContainMany <em>Contain Many</em>}</li> - * </ul> - * </p> - * - * @extends Serializable - * @generated - */ -public interface ContainmentTest extends Serializable -{ - /** - * Returns the value of the '<em><b>Mixed</b></em>' attribute list. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Mixed</em>' attribute list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Mixed</em>' attribute list. - * @generated - */ - Sequence getMixed(); - - /** - * Returns the value of the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Name</em>' attribute. - * @see #isSetName() - * @see #unsetName() - * @see #setName(String) - * @generated - */ - String getName(); - - /** - * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Name</em>' attribute. - * @see #isSetName() - * @see #unsetName() - * @see #getName() - * @generated - */ - void setName(String value); - - /** - * Unsets the value of the '{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetName() - * @see #getName() - * @see #setName(String) - * @generated - */ - void unsetName(); - - /** - * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getName <em>Name</em>}' attribute is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Name</em>' attribute is set. - * @see #unsetName() - * @see #getName() - * @see #setName(String) - * @generated - */ - boolean isSetName(); - - /** - * Returns the value of the '<em><b>Contain</b></em>' containment reference. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Contain</em>' containment reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Contain</em>' containment reference. - * @see #isSetContain() - * @see #unsetContain() - * @see #setContain(ContainmentTest) - * @generated - */ - ContainmentTest getContain(); - - /** - * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Contain</em>' containment reference. - * @see #isSetContain() - * @see #unsetContain() - * @see #getContain() - * @generated - */ - void setContain(ContainmentTest value); - - /** - * Unsets the value of the '{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isSetContain() - * @see #getContain() - * @see #setContain(ContainmentTest) - * @generated - */ - void unsetContain(); - - /** - * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getContain <em>Contain</em>}' containment reference is set. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return whether the value of the '<em>Contain</em>' containment reference is set. - * @see #unsetContain() - * @see #getContain() - * @see #setContain(ContainmentTest) - * @generated - */ - boolean isSetContain(); - - /** - * Returns the value of the '<em><b>Contain Many</b></em>' containment reference list. - * The list contents are of type {@link com.example.test.Containment.ContainmentTest}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Contain Many</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Contain Many</em>' containment reference list. - * @generated - */ - List getContainMany(); - -} // ContainmentTest diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java deleted file mode 100644 index 9f51d02590..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java +++ /dev/null @@ -1,270 +0,0 @@ -/** - * - * 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; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * Generator information: - * patternVersion=1.2; -prefix Containment - * <!-- end-user-doc --> - * @generated - */ -public class ContainmentFactoryImpl extends FactoryBase implements ContainmentFactory -{ - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String NAMESPACE_URI = "http://www.example.com/ContainmentTest"; - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String NAMESPACE_PREFIX = "contain"; - - /** - * The version of the generator pattern used to generate this class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String PATTERN_VERSION = "1.2"; - - public static final int CONTAINMENT_TEST = 1; - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ContainmentFactoryImpl() - { - super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.example.test.Containment"); - } - - /** - * Registers the Factory instance so that it is available within the supplied scope. - * @argument scope a HelperContext instance that will make the types supported by this Factory available. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void register(HelperContext scope) { - if(scope == null) { - throw new IllegalArgumentException("Scope can not be null"); - } - TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); - th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public DataObject create(int typeNumber) - { - switch (typeNumber) - { - case CONTAINMENT_TEST: return (DataObject)createContainmentTest(); - default: - return super.create(typeNumber); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ContainmentTest createContainmentTest() - { - ContainmentTestImpl containmentTest = new ContainmentTestImpl(); - return containmentTest; - } - - // Following creates and initializes SDO metadata for the supported types. - protected Type containmentTestType = null; - - public Type getContainmentTest() - { - return containmentTestType; - } - - - private static boolean isInited = false; - - public static ContainmentFactoryImpl init() - { - if (isInited) return (ContainmentFactoryImpl)FactoryBase.getStaticFactory(ContainmentFactoryImpl.NAMESPACE_URI); - ContainmentFactoryImpl theContainmentFactoryImpl = new ContainmentFactoryImpl(); - isInited = true; - - // Initialize 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/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java deleted file mode 100644 index 14d4678d2d..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java +++ /dev/null @@ -1,409 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.example.test.Containment.impl; - -import com.example.test.Containment.ContainmentFactory; -import com.example.test.Containment.ContainmentTest; - -import commonj.sdo.Sequence; -import commonj.sdo.Type; - -import java.util.Collection; -import java.util.List; - -import org.apache.tuscany.sdo.impl.DataObjectBase; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Test</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getMixed <em>Mixed</em>}</li> - * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getName <em>Name</em>}</li> - * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getContain <em>Contain</em>}</li> - * <li>{@link com.example.test.Containment.impl.ContainmentTestImpl#getContainMany <em>Contain Many</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ContainmentTestImpl extends DataObjectBase implements ContainmentTest -{ - - public final static int MIXED = -1; - - public final static int NAME = 0; - - public final static int CONTAIN = 1; - - public final static int CONTAIN_MANY = 2; - - public final static int SDO_PROPERTY_COUNT = 3; - - public final static int EXTENDED_PROPERTY_COUNT = -1; - - - /** - * The internal feature id for the '<em><b>Mixed</b></em>' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_MIXED = 0; - - /** - * The internal feature id for the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_NAME = 1; - - /** - * The internal feature id for the '<em><b>Contain</b></em>' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_CONTAIN = 2; - - /** - * The internal feature id for the '<em><b>Contain Many</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_CONTAIN_MANY = 3; - - /** - * The number of properties for this type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public final static int INTERNAL_PROPERTY_COUNT = 4; - - protected int internalConvertIndex(int internalIndex) - { - switch (internalIndex) - { - case INTERNAL_MIXED: return MIXED; - case INTERNAL_NAME: return NAME; - case INTERNAL_CONTAIN: return CONTAIN; - case INTERNAL_CONTAIN_MANY: return CONTAIN_MANY; - } - return super.internalConvertIndex(internalIndex); - } - - - /** - * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getMixed() - * @generated - * @ordered - */ - - protected Sequence mixed = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ContainmentTestImpl() - { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Type getStaticType() - { - return ((ContainmentFactoryImpl)ContainmentFactory.INSTANCE).getContainmentTest(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Sequence getMixed() - { - if (mixed == null) - { - mixed = createSequence(INTERNAL_MIXED); - } - return mixed; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getName() - { - return (String)get(getMixed(), getType(), INTERNAL_NAME); - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setName(String newName) - { - set(getMixed(), getType(), INTERNAL_NAME, newName); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetName() - { - unset(getMixed(), getType(), INTERNAL_NAME); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetName() - { - return isSet(getMixed(), getType(), INTERNAL_NAME); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ContainmentTest getContain() - { - return (ContainmentTest)get(getMixed(), getType(), INTERNAL_CONTAIN); - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ChangeContext basicSetContain(ContainmentTest newContain, ChangeContext changeContext) - { - return basicAdd(getMixed(), getType(), INTERNAL_CONTAIN, newContain, changeContext); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setContain(ContainmentTest newContain) - { - set(getMixed(), getType(), INTERNAL_CONTAIN, newContain); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ChangeContext basicUnsetContain(ChangeContext changeContext) - { - // TODO: implement this method to unset the contained 'Contain' containment reference - // -> this method is automatically invoked to keep the containment relationship in synch - // -> do not modify other features - // -> return changeContext, after adding any generated Notification to it (if it is null, a NotificationChain object must be created first) - // Ensure that you remove @generated or mark it @generated NOT - throw new UnsupportedOperationException(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unsetContain() - { - unset(getMixed(), getType(), INTERNAL_CONTAIN); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSetContain() - { - return isSet(getMixed(), getType(), INTERNAL_CONTAIN); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public List getContainMany() - { - return getList(getMixed(), getType(), INTERNAL_CONTAIN_MANY); - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) - { - switch (propertyIndex) - { - case MIXED: - return removeFromSequence(getMixed(), otherEnd, changeContext); - case CONTAIN: - return basicUnsetContain(changeContext); - case CONTAIN_MANY: - return removeFromList(getContainMany(), otherEnd, changeContext); - } - return super.inverseRemove(otherEnd, propertyIndex, changeContext); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object get(int propertyIndex, boolean resolve) - { - switch (propertyIndex) - { - case MIXED: - // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view - //if (coreType) - return getMixed(); - case NAME: - return getName(); - case CONTAIN: - return getContain(); - case CONTAIN_MANY: - return getContainMany(); - } - return super.get(propertyIndex, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void set(int propertyIndex, Object newValue) - { - switch (propertyIndex) - { - case MIXED: - setSequence(getMixed(), newValue); - return; - case NAME: - setName((String)newValue); - return; - case CONTAIN: - setContain((ContainmentTest)newValue); - return; - case CONTAIN_MANY: - getContainMany().clear(); - getContainMany().addAll((Collection)newValue); - return; - } - super.set(propertyIndex, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void unset(int propertyIndex) - { - switch (propertyIndex) - { - case MIXED: - unsetSequence(getMixed()); - return; - case NAME: - unsetName(); - return; - case CONTAIN: - unsetContain(); - return; - case CONTAIN_MANY: - getContainMany().clear(); - return; - } - super.unset(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isSet(int propertyIndex) - { - switch (propertyIndex) - { - case MIXED: - return mixed != null && !isSequenceEmpty(getMixed()); - case NAME: - return isSetName(); - case CONTAIN: - return isSetContain(); - case CONTAIN_MANY: - return !getContainMany().isEmpty(); - } - return super.isSet(propertyIndex); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() - { - if (isProxy(this)) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (mixed: "); - result.append(mixed); - result.append(')'); - return result.toString(); - } - -} //ContainmentTestImpl diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java deleted file mode 100644 index 7d91456137..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java deleted file mode 100644 index d67b53fb7c..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java deleted file mode 100644 index 4a51310cd0..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java deleted file mode 100644 index e9151b9d46..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java deleted file mode 100644 index 218a725226..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java deleted file mode 100644 index 56bf6af9b4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java deleted file mode 100644 index 6cc0529c5f..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java deleted file mode 100644 index 3e3e87e47b..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java deleted file mode 100644 index ec848de4fa..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java deleted file mode 100644 index 1bdef4b1ef..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java +++ /dev/null @@ -1,87 +0,0 @@ - -/** - * - * 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(BoundsTestCase.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); - suite.addTestSuite(NotificationTestCase.class); - suite.addTestSuite(ImplSpecificTestCase.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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java deleted file mode 100644 index 4d085eae28..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java deleted file mode 100644 index 7f176fe033..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * - * 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.api.SDOUtil; -import org.apache.tuscany.sdo.api.SDOHelper; - -import junit.framework.TestCase; - -import commonj.sdo.*; -import commonj.sdo.helper.*; - -public class BoundsTestCase extends TestCase { - private final String TEST_MODEL = "/bounds.xsd"; - private final String TEST_NAMESPACE = "http://www.example.com/bounds"; - - private TypeHelper typeHelper; - private XSDHelper xsdHelper; - private DataFactory dataFactory; - - public void testBounds() { - Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price"); - assertTrue(priceProperty.isOpenContent()); - assertEquals(SDOHelper.UNSPECIFIED, SDOUtil.getUpperBound(priceProperty)); - assertEquals(0, SDOUtil.getLowerBound(priceProperty)); - - Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote"); - DataObject quote = dataFactory.create(quoteType); - assertEquals(2, SDOUtil.getUpperBound(quote.getInstanceProperty("symbol"))); - assertEquals(0, SDOUtil.getLowerBound(quote.getInstanceProperty("symbol"))); - - //XSD default value of maxOccurs and minOccurs is 1, unbounded returns -1 for maxOccurs - Type quoteType2 = typeHelper.getType(TEST_NAMESPACE, "OpenQuote2"); - DataObject quote2 = dataFactory.create(quoteType2); - assertEquals(SDOHelper.UNBOUNDED, SDOUtil.getUpperBound(quote2.getInstanceProperty("symbol"))); - assertEquals(1, SDOUtil.getLowerBound(quote2.getInstanceProperty("symbol"))); - - //XSD default value of maxOccurs and minOccurs is 1 - Type quoteType3 = typeHelper.getType(TEST_NAMESPACE, "OpenQuote3"); - DataObject quote3 = dataFactory.create(quoteType3); - assertEquals(1, SDOUtil.getUpperBound(quote3.getInstanceProperty("symbol"))); - assertEquals(1, SDOUtil.getLowerBound(quote3.getInstanceProperty("symbol"))); - } - - protected void setUp() throws Exception { - super.setUp(); - - HelperContext hc = SDOUtil.createHelperContext(); - typeHelper = hc.getTypeHelper(); - dataFactory = hc.getDataFactory(); - xsdHelper = hc.getXSDHelper(); - - // Populate the meta data for the test (Stock Quote) model - URL url = getClass().getResource(TEST_MODEL); - InputStream inputStream = url.openStream(); - xsdHelper.define(inputStream, url.toString()); - inputStream.close(); - } -}
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java deleted file mode 100644 index b9b9c0f2ea..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java +++ /dev/null @@ -1,216 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java deleted file mode 100644 index ace509d1b4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java deleted file mode 100644 index e956720117..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java deleted file mode 100644 index 843ab9b982..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java +++ /dev/null @@ -1,866 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java deleted file mode 100644 index f602555fa6..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java deleted file mode 100644 index 4a8ed34477..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java +++ /dev/null @@ -1,474 +0,0 @@ -/** - * - * 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 <indent; i++) System.out.print(" "); - } - */ - - protected void constructSourceTree(DataFactory df) - { - // Create Instances - bankSDO = df.create(TEST_NAMESPACE, BANK_TYPE ); - branchSDO1 = df.create(TEST_NAMESPACE, BRANCH_TYPE ); - branchSDO2 = df.create(TEST_NAMESPACE, BRANCH_TYPE ); - serviceSDO1 = df.create(TEST_NAMESPACE, SERVICE_TYPE ); - serviceSDO2 = df.create(TEST_NAMESPACE, SERVICE_TYPE ); - serviceSDO3 = df.create(TEST_NAMESPACE, SERVICE_TYPE ); - customerSDO1 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE ); - customerSDO2 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE ); - customerSDO3 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE ); - customerSDO4 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE ); - - // Populate the Bank Instance - bankSDO.set("name", "Fourth National"); - Vector v = new Vector(); - v.add(branchSDO1); - v.add(branchSDO2); - bankSDO.set("Branch",v); - v.removeAllElements(); - v.add(serviceSDO1); - v.add(serviceSDO2); - v.add(serviceSDO3); - bankSDO.set("Service",v); - v.removeAllElements(); - v.add(customerSDO1); - v.add(customerSDO2); - v.add(customerSDO3); - v.add(customerSDO4); - bankSDO.set("Customer",v); - v.removeAllElements(); - - // Populate Branch Instances - // Branch 1 - branchSDO1.set("ID", "BR100"); - DataObject addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE ); - addr.set("Street", "1302 Money Street"); - addr.set("City", "Apex"); - addr.set("State", "NC"); - addr.set("Zip", "27502"); - branchSDO1.set("Address", addr); - v.add("If you are north, head south"); - v.add("If you are south, head north"); - branchSDO1.set("Directions", v); - v.removeAllElements(); - DataObject account1 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE ); - account1.set("ID", "0000 1200 0001"); - account1.set("Service", serviceSDO1 ); - account1.setBigDecimal("Balance", new BigDecimal("3124.12")); - v.add(account1); - DataObject account2 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE ); - account2.set("ID", "0000 8899 0001"); - account2.set("Service", serviceSDO1 ); - account2.setBigDecimal("Balance", new BigDecimal("20.00")); - v.add(account2); - DataObject account3 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE ); - account3.set("ID", "0000 3110 0020"); - account3.set("Service", serviceSDO3 ); - account3.setBigDecimal("Balance", new BigDecimal("5000.00")); - v.add(account3); - branchSDO1.set("Account", v); - v.removeAllElements(); - // Branch 2 - branchSDO2.set("ID", "BR200"); - addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE ); - addr.set("Street", "1207 Cash Court"); - addr.set("City", "Raleigh"); - addr.set("State", "NC"); - addr.set("Zip", "27701"); - branchSDO2.set("Address", addr); - v.add("If you are east, head west"); - v.add("If you are west, head east"); - branchSDO2.set("Directions", v); - v.removeAllElements(); - DataObject account4 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE ); - account4.set("ID", "0000 0011 0001"); - account4.set("Service", serviceSDO1 ); - account4.setBigDecimal("Balance", new BigDecimal("99.12")); - v.add(account4); - DataObject account5 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE ); - account5.set("ID", "0000 9911 0001"); - account5.set("Service", serviceSDO2 ); - account5.setBigDecimal("Balance", new BigDecimal("820.00")); - v.add(account5); - DataObject account6 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE ); - account6.set("ID", "0000 0001 0020"); - account6.set("Service", serviceSDO3 ); - account6.setBigDecimal("Balance", new BigDecimal("9000.00")); - v.add(account6); - branchSDO2.set("Account", v); - v.removeAllElements(); - - // Populate Service Instances - serviceSDO1.set("ID", "SRV01"); - serviceSDO1.set("Name", "Checking"); - serviceSDO1.setBigDecimal("Fee", new BigDecimal("0.00")); - serviceSDO2.set("ID", "SRV02"); - serviceSDO2.set("Name", "Savings"); - serviceSDO2.setBigDecimal("Fee", new BigDecimal("0.00")); - serviceSDO3.set("ID", "SRV03"); - serviceSDO3.set("Name", "Loan"); - serviceSDO3.setBigDecimal("Fee", new BigDecimal("0.00")); - - // Populate Customer Instances - // Customer 1 - customerSDO1.set("ID", "CUST01"); - customerSDO1.set("First", "James"); - customerSDO1.set("Last", "Madison"); - addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE ); - addr.set("Street", "1234 Easy Street"); - addr.set("City", "New York"); - addr.set("State", "NY"); - addr.set("Zip", "27511"); - customerSDO1.set("Address", addr); - customerSDO1.set("HomeBranch", branchSDO1); - v.add(account1); - customerSDO1.set("Account", v); - v.removeAllElements(); - v.add(customerSDO2); - v.add(customerSDO3); - customerSDO1.set("Related", v); - v.removeAllElements(); - // Customer 2 - customerSDO2.set("ID", "CUST02"); - customerSDO2.set("First", "George"); - customerSDO2.set("Last", "Washington"); - addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE ); - addr.set("Street", "1776 Potomac Avenue"); - addr.set("City", "Washington"); - addr.set("State", "DC"); - addr.set("Zip", "50555"); - customerSDO2.set("Address", addr); - customerSDO2.set("HomeBranch", branchSDO1); - v.add(account2); - v.add(account3); - customerSDO2.set("Account", v); - v.removeAllElements(); - // Customer 3 - customerSDO3.set("ID", "CUST03"); - customerSDO3.set("First", "Thomas"); - customerSDO3.set("Last", "Jefferson"); - addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE ); - addr.set("Street", "1492 Columbus Avenue"); - addr.set("City", "Charlottesville"); - addr.set("State", "VA"); - addr.set("Zip", "20121"); - customerSDO3.set("Address", addr); - customerSDO3.set("HomeBranch", branchSDO2); - v.add(account4); - customerSDO3.set("Account", v); - v.removeAllElements(); - // Customer 4 - customerSDO4.set("ID", "CUST04"); - customerSDO4.set("First", "Benjamin"); - customerSDO4.set("Last", "Franklin"); - addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE ); - addr.set("Street", "99 Light Street"); - addr.set("City", "Philadelphia"); - addr.set("State", "PA"); - addr.set("Zip", "19251"); - customerSDO4.set("Address", addr); - customerSDO4.set("HomeBranch", branchSDO2); - v.add(account5); - v.add(account6); - customerSDO4.set("Account", v); - v.removeAllElements(); - - } - - private void populateScopeWithDynamicTypes(TypeHelper scope) - { - Type stringType = scope.getType("commonj.sdo", "String"); - DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo", "Type"); - customerType.set("uri", TEST_NAMESPACE); - customerType.set("name", DYNAMIC_TYPE ); - DataObject custNumProperty = customerType.createDataObject("property"); - custNumProperty.set("name", "custNum"); - custNumProperty.set("type", stringType); - DataObject firstNameProperty = customerType.createDataObject("property"); - firstNameProperty.set("name", "firstName"); - firstNameProperty.set("type", stringType); - DataObject lastNameProperty = customerType.createDataObject("property"); - lastNameProperty.set("name", "lastName"); - lastNameProperty.set("type", stringType); - scope.define(customerType); - } - - /* - private void dumpObject(DataObject sdo, String node ) - { - try - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SDOUtil.createXMLHelper(scopeA).save(sdo, TEST_NAMESPACE, - node, baos); - System.out.println(baos.toString()); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - */ -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataGraphTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataGraphTestCase.java deleted file mode 100644 index 5fcc567908..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataGraphTestCase.java +++ /dev/null @@ -1,270 +0,0 @@ -/** - * - * 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.DataGraph; -import commonj.sdo.DataObject; -import commonj.sdo.Type; -import commonj.sdo.helper.XSDHelper; - -/** - * Tests methods of DataGraph except for change summary which is tested elsewhere. - */ -public class DataGraphTestCase extends TestCase { - private final String SIMPLE_MODEL = "/simple.xsd"; - private final String ANYTYPE_MODEL = "/anytype.xsd"; - - /** - * createRootObject(type) test with good parms. - */ - public void testCreateRootObjectType() throws IOException { - // Create an empty data graph and add a root object, an instance of type Quote - - DataGraph dataGraph = SDOUtil.createDataGraph(); - Type quoteType = dataGraph.getType("http://www.example.com/simple", "Quote"); - DataObject quote = dataGraph.createRootObject(quoteType); - - assertNotNull(quote); - } - - /** - * createRootObject(type) test with bad parm. - */ - public void testCreateRootObjectTypeBad() throws IOException { - // Create an empty data graph and pass bad parms to createRootObject - - DataGraph dataGraph = SDOUtil.createDataGraph(); - boolean success = false; - try { - dataGraph.createRootObject(null); - } catch(NullPointerException npe) { - fail("createRootObject with null type threw NullPointerException"); - } catch(Exception e) { - success = true; - } - if (!success) { - fail("createRootObject with null type parameter did not throw an exception"); - } - } - - /** - * createRootObject(type) test with good parms but too often to ensure - * that IllegalStateException is thrown - */ - public void testCreateRootObjectTypeIllegalState() throws IOException { - // Create an empty data graph and add a root object, then add another root object - - DataGraph dataGraph = SDOUtil.createDataGraph(); - DataObject quote = dataGraph.createRootObject("http://www.example.com/anytype", "Person"); - - assertNotNull(quote); - - Type quoteType = dataGraph.getType("http://www.example.com/simple", "Quote"); - assertNotNull(quoteType); - boolean success = false; - try { - dataGraph.createRootObject(quoteType); - } catch(IllegalStateException ise) { - success = true; - } catch(Exception e) { - fail("createRootObject called when a root was already created and an exception other than IllegalStateException was thrown: "+e.getMessage()); - } - if (!success) { - fail("createRootObject called when a root was already created but no IllegalStateException was thrown"); - } - } - - /** - * createRootObject(type) test with good parms but too often to ensure - * that IllegalStateException is thrown - */ - public void testCreateRootObjectUriTypenameIllegalState() throws IOException { - // Create an empty data graph and add a root object, then add another root object - - DataGraph dataGraph = SDOUtil.createDataGraph(); - DataObject quote = dataGraph.createRootObject("http://www.example.com/anytype", "Person"); - - assertNotNull(quote); - - boolean success = false; - try { - dataGraph.createRootObject("http://www.example.com/simple", "Quote"); - } catch(IllegalStateException ise) { - success = true; - } catch(Exception e) { - fail("createRootObject called when a root was already created and an exception other than IllegalStateException was thrown: "+e.getMessage()); - } - if (!success) { - fail("createRootObject called when a root was already created but no IllegalStateException was thrown"); - } - } - - /** - * createRootObject(uri_string, typeName_string) test with good parms. - */ - public void testCreateRootObjectUriTypename() 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"); - - assertNotNull(quote); - } - - /** - * createRootObject(uri_string, typeName_string) test with bad parms. - */ - public void testCreateRootObjectUriTypenameBad1() throws IOException { - // Create an empty data graph and pass bad parms to createRootObject - - DataGraph dataGraph = SDOUtil.createDataGraph(); - boolean success = false; - try { - dataGraph.createRootObject("http://www.example.com/mangled", "Quote"); - } catch(NullPointerException npe) { - fail("createRootObject with mangled URI threw NullPointerException"); - } catch(Exception e) { - success = true; - } - if (!success) { - fail("createRootObject with mangled URI did not throw an exception"); - } - } - - /** - * createRootObject(uri_string, typeName_string) test with bad parms. - */ - public void testCreateRootObjectUriTypenameBad2() throws IOException { - // Create an empty data graph and pass bad parms to createRootObject - - DataGraph dataGraph = SDOUtil.createDataGraph(); - boolean success = false; - try { - dataGraph.createRootObject("http://www.example.com/simple", "Mangled"); - } catch(NullPointerException npe) { - fail("createRootObject with mangled type name threw NullPointerException"); - } catch(Exception e) { - success = true; - } - if (!success) { - fail("createRootObject with mangled type name did not throw an exception"); - } - } - - /** - * getType(uri_string, typeName_string) test with good parms. - */ - public void testGetType() throws IOException { - // Create an empty data graph and get a type, a Quote type - - DataGraph dataGraph = SDOUtil.createDataGraph(); - Type quoteType = dataGraph.getType("http://www.example.com/simple", "Quote"); - - assertNotNull(quoteType); - } - - /** - * getType(uri_string, typeName_string) test with bad URI parm. - */ - public void testGetTypeBad1() throws IOException { - // Create an empty data graph and pass bad parms to getType - - DataGraph dataGraph = SDOUtil.createDataGraph(); - Type quoteType = null; - try { - quoteType = dataGraph.getType("http://www.example.com/mangled", "Quote"); - } catch(Exception e) { - fail("getType with mangled URI threw an exception: "+e.getMessage()); - } - assertNull(quoteType); - } - - /** - * getType(uri_string, typeName_string) test with bad type name parm. - */ - public void testGetTypeBad2() throws IOException { - // Create an empty data graph and pass bad parms to getType - - DataGraph dataGraph = SDOUtil.createDataGraph(); - Type quoteType = null; - try { - quoteType = dataGraph.getType("http://www.example.com/simple", "Mangled"); - } catch(Exception e) { - fail("getType with mangled type name threw an exception: "+e.getMessage()); - } - assertNull(quoteType); - } - - /** - * getType(uri_string, typeName_string) test with null URI parm. - */ - public void testGetTypeBad3() throws IOException { - // Create an empty data graph and pass bad parms to getType - - DataGraph dataGraph = SDOUtil.createDataGraph(); - Type quoteType = null; - try { - quoteType = dataGraph.getType(null, "Quote"); - } catch(Exception e) { - fail("getType with null URI threw an exception: "+e.getMessage()); - } - assertNull(quoteType); - } - - /** - * getType(uri_string, typeName_string) test with null type name parm. - */ - public void testGetTypeBad4() throws IOException { - // Create an empty data graph and pass bad parms to getType - - DataGraph dataGraph = SDOUtil.createDataGraph(); - Type quoteType = null; - try { - quoteType = dataGraph.getType("http://www.example.com/simple", null); - } catch(Exception e) { - fail("getType with null type name threw an exception: "+e.getMessage()); - } - assertNull(quoteType); - } - - protected void setUp() throws Exception { - super.setUp(); - - // Populate the meta data for the Quote type - URL url = getClass().getResource(SIMPLE_MODEL); - InputStream inputStream = url.openStream(); - XSDHelper.INSTANCE.define(inputStream, url.toString()); - inputStream.close(); - - // Populate the meta data for the Person type - URL url2 = getClass().getResource(ANYTYPE_MODEL); - InputStream inputStream2 = url2.openStream(); - XSDHelper.INSTANCE.define(inputStream2, url2.toString()); - inputStream2.close(); - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java deleted file mode 100644 index a4312a9154..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * - * 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.List; - -import org.apache.tuscany.sdo.api.SDOUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; -import junit.framework.TestCase; - -public class DataObjectGetListTestCase extends TestCase { - private HelperContext hc; - private DataObject companyDataObject; - - private final String TEST_NAMESPACE = "http://www.example.com/getList"; - - private String xsdString = - "<xsd:schema " + - "xmlns:getList=\"http://www.example.com/getList\" " + - "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + - "targetNamespace=\"http://www.example.com/getList\">" + - - "<xsd:element name=\"company\" type=\"getList:Company\"/>" + - "<xsd:element name=\"employee\" type=\"xsd:string\"/>" + - - "<xsd:complexType name=\"Company\">" + - "<xsd:sequence>" + - "<xsd:element name=\"openCompany\" type=\"getList:OpenCompany\"/>" + - "<xsd:element name=\"closeCompany\" type=\"getList:CloseCompany\"/>" + - "</xsd:sequence>" + - "</xsd:complexType>" + - - "<xsd:complexType name=\"OpenCompany\">" + - "<xsd:sequence>" + - "<xsd:element name=\"company\" type=\"xsd:string\"/>" + - "<xsd:element name=\"employees\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>" + - "<xsd:any maxOccurs=\"unbounded\" namespace=\"##any\"/>" + - "</xsd:sequence>" + - "</xsd:complexType>" + - - "<xsd:complexType name=\"CloseCompany\">" + - "<xsd:sequence>" + - "<xsd:element name=\"company\" type=\"xsd:string\"/>" + - "<xsd:element name=\"employees\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>" + - "</xsd:sequence>" + - "</xsd:complexType>" + - - "</xsd:schema>"; - - /** - * Test DataObject.getList() on open type - */ - public void testUnknownPropertyOnOpenType() throws IOException { - String companyName = companyDataObject.getString("openCompany/company"); - assertEquals(companyName, "OpenCompany"); - List unknownProperty = companyDataObject.getList("openCompany/unknownProperty"); - assertNotNull(unknownProperty); - assertTrue(unknownProperty instanceof List); - - List unknownProperty2 = companyDataObject.getList("openCompany/unknownProperty"); - assertNotNull(unknownProperty2); - assertTrue(unknownProperty2 instanceof List); - - // unknownProperty and unknownProperty2 are in fact the same value for the same property - - unknownProperty.add("employee1"); - assertTrue(unknownProperty.size() == 1); - - unknownProperty2.add("employee2"); - assertTrue(unknownProperty2.size() == 2); - - unknownProperty.remove(0); - assertTrue(unknownProperty.size() == 1); - - assertEquals(unknownProperty.get(0), "employee2"); - } - - /** - * Test DataObject.getList() on non-open type - */ - public void testUnknownPropertyOnClosedType() throws IOException { - String companyName = companyDataObject.getString("closeCompany/company"); - assertEquals(companyName, "CloseCompany"); - List unknownProperty = companyDataObject.getList("closeCompany/unknownProperty"); - assertNotNull(unknownProperty); - assertTrue(unknownProperty instanceof List); - - try { - unknownProperty.add("employee1"); - fail("An exception should have been thrown."); - } - catch (Exception e) { - } - } - - protected void setUp() throws Exception { - super.setUp(); - - hc = SDOUtil.createHelperContext(); - hc.getXSDHelper().define(xsdString); - - companyDataObject = hc.getDataFactory().create(TEST_NAMESPACE, "Company"); - DataObject openCompany = companyDataObject.createDataObject("openCompany"); - openCompany.setString("company", "OpenCompany"); - DataObject closeCompany = companyDataObject.createDataObject("closeCompany"); - closeCompany.setString("company", "CloseCompany"); - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java deleted file mode 100644 index a49b165386..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * - * 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 junit.framework.TestCase; - -import commonj.sdo.Type; -import commonj.sdo.helper.TypeHelper; -import commonj.sdo.helper.XSDHelper; - - -public class DataTypeBaseTypeTestCase extends TestCase { - private final String TEST_MODEL = "/datatype.xsd"; - private final String TEST_NAMESPACE = "http://www.example.com/datatype"; - - public void testSimpleSDOType() throws IOException - { - Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOType"); - List baseTypes = type.getBaseTypes(); - assertTrue(baseTypes.size() == 1); - } - - public void testSimpleSDOTypeInstanceClass() throws IOException - { - Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeInstanceClass"); - List baseTypes = type.getBaseTypes(); - assertTrue(baseTypes.size() == 0); - } - - public void testSimpleSDOTypeExtendedInstanceClass() throws IOException - { - Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeExtendedInstanceClass"); - List baseTypes = type.getBaseTypes(); - assertTrue(baseTypes.size() == 1); - } - - public void setUp() throws Exception - { - URL url = getClass().getResource(TEST_MODEL); - InputStream inputStream = url.openStream(); - XSDHelper.INSTANCE.define(inputStream, url.toString()); - inputStream.close(); - } - -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java deleted file mode 100644 index 86808f3b56..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java +++ /dev/null @@ -1,380 +0,0 @@ -/** - * - * 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.lang.reflect.Method; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -import junit.framework.TestCase; - -import commonj.sdo.helper.DataHelper; - -// DateConversionTestCase insures that the DataHelper conversions accurately -// retain the information in the specified fields (e.g. month, day or year). -// It also provides coverage for the DataHelper API. -// Note that toDate is called each time Test.initialize() is called. - -public class DateConversionTestCase extends TestCase -{ - private static Calendar test_calendar; - private static Date test_date; - private static DataHelper data_helper; - - private static final TestType TO_DATE_TIME = new TestType("toDateTime", new int [] {Calendar.YEAR, Calendar.MONTH, - Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND}); - private static final TestType TO_DURATION = new TestType("toDuration", new int [] {Calendar.YEAR, Calendar.MONTH, - Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND}); - private static final TestType TO_TIME = new TestType("toTime", new int [] {Calendar.HOUR_OF_DAY, Calendar.MINUTE, - Calendar.SECOND, Calendar.MILLISECOND}); - private static final TestType TO_DAY = new TestType("toDay", new int[] {Calendar.DAY_OF_MONTH}); - private static final TestType TO_MONTH = new TestType("toMonth", new int[] {Calendar.MONTH}); - private static final TestType TO_MONTH_DAY = new TestType("toMonthDay", new int[] {Calendar.MONTH, Calendar.DAY_OF_MONTH}); - private static final TestType TO_YEAR = new TestType("toYear", new int[] {Calendar.YEAR}); - private static final TestType TO_YEAR_MONTH= new TestType("toYearMonth", new int[] {Calendar.YEAR, Calendar.MONTH}); - private static final TestType TO_YEAR_MONTH_DAY = new TestType("toYearMonthDay", new int[] {Calendar.YEAR, - Calendar.MONTH, Calendar.DAY_OF_MONTH}); - - public DateConversionTestCase() throws Exception - { - data_helper = DataHelper.INSTANCE; - test_calendar = new GregorianCalendar(); - test_calendar.setTime(new Date(System.currentTimeMillis())); - test_date = test_calendar.getTime(); - } - - //Test for TUSCANY-1514 - public void testNullStringToDate() throws Exception { - Date result = data_helper.toDate(null); - assertEquals(null, result); - } - - private static class TestType - { - private static final Class[] DATE_CLASS_ARRAY = {Date.class}; - private static final Class[] CALENDAR_CLASS_ARRAY = {Calendar.class}; - - Method date_method; - Method calendar_method; - int [] compare_fields; - - public TestType (String method_name, int [] compare_fields) - { - try - { - this.date_method = DataHelper.class.getMethod(method_name, DATE_CLASS_ARRAY); - } - catch (NoSuchMethodException e) - { - this.date_method = null; - } - - this.compare_fields = compare_fields; - try - { - this.calendar_method = DataHelper.class.getMethod(method_name, CALENDAR_CLASS_ARRAY); - } - catch (NoSuchMethodException e) - { - this.calendar_method = null; - } - - } - - public Method getDateMethod() - { - return this.date_method; - } - - public Method getCalendarMethod() - { - return this.calendar_method; - } - } - - private static class Test - { - String from_type; - Date from_date; - Calendar from_calendar; - Class expected_exception; - - public Test () - { - this.from_date = null; - this.from_calendar = null; - expected_exception = null; - } - - public void initialize (TestType from_type) - { - this.from_type = from_type.getDateMethod().getName(); - - try - { - String date_string = (String) from_type.getDateMethod().invoke(data_helper, new Object[] {test_date}); - - this.from_date = data_helper.toDate(date_string); - date_string = (String) from_type.getCalendarMethod().invoke(data_helper, new Object[] {test_calendar}); - this.from_calendar = data_helper.toCalendar(date_string); - } - catch (Exception e) - { - this.from_date = null; - this.from_calendar = null; - } - - } - - // This method is needed because there is not a toDate(Date) method in DataHelper. - - public void initializeToDate() - { - this.from_calendar = test_calendar; - this.from_date = test_date; - this.from_type = "toDate"; - } - - public void attemptConversion (TestType to_type) throws Exception - { - executeConversion(to_type.getDateMethod(), new Object[] {this.from_date}, to_type.compare_fields); - executeConversion(to_type.getCalendarMethod(), new Object[] {this.from_calendar}, to_type.compare_fields); - } - - private void executeConversion (Method conversion, Object[] parm, int [] compare_fields) throws Exception - { - String result; - - try - { - result = (String) conversion.invoke(data_helper, parm); - } - catch (Exception e) - { - System.err.println("An unexpected exception was thrown while calling " + conversion.getName() + - " after initializing with " + this.from_type + "."); - throw e; - } - - assertTrue("The expected value did not result when calling " + conversion.getName() + - " after initializing with " + this.from_type + ".", compareFields(parm[0], result, compare_fields)); - } - - private boolean compareFields(Object compare_to, String output, int [] compare_fields) - { - Calendar result = data_helper.toCalendar(output); - Calendar expected; - - if (compare_to instanceof Calendar) - expected = (GregorianCalendar) test_calendar; - else - { - expected = new GregorianCalendar(); - expected.setTime((Date) test_date); - } - - for (int i = 0; i < compare_fields.length; i++) - { - if (expected.get(compare_fields[i]) != result.get(compare_fields[i])) - { - System.err.println("Failed: - expected '" + expected.get(compare_fields[i]) + "' got '" + result.get(compare_fields[i]) + "' for output: " + output); - return false; - } - } - return true; - } - - } - - public void testConversionsFromDay() throws Exception - { - Test FromDay = new Test(); - - FromDay.initialize(TO_DAY); - - FromDay.attemptConversion(TO_DAY); - } - - public void testConversionsFromDate() throws Exception - { - Test FromDate = new Test(); - - FromDate.initializeToDate(); - - FromDate.attemptConversion(TO_DATE_TIME); - FromDate.attemptConversion(TO_DURATION); - FromDate.attemptConversion(TO_TIME); - FromDate.attemptConversion(TO_DAY); - FromDate.attemptConversion(TO_MONTH); - FromDate.attemptConversion(TO_MONTH_DAY); - FromDate.attemptConversion(TO_YEAR); - FromDate.attemptConversion(TO_YEAR_MONTH); - FromDate.attemptConversion(TO_YEAR_MONTH_DAY); - } - - public void testConversionsFromDateTime() throws Exception - { - Test FromDateTime = new Test(); - - FromDateTime.initialize(TO_DATE_TIME); - - FromDateTime.attemptConversion(TO_DATE_TIME); - FromDateTime.attemptConversion(TO_DURATION); - FromDateTime.attemptConversion(TO_TIME); - FromDateTime.attemptConversion(TO_DAY); - FromDateTime.attemptConversion(TO_MONTH); - FromDateTime.attemptConversion(TO_MONTH_DAY); - FromDateTime.attemptConversion(TO_YEAR); - FromDateTime.attemptConversion(TO_YEAR_MONTH); - FromDateTime.attemptConversion(TO_YEAR_MONTH_DAY); - } - - public void testConversionsFromDuration() throws Exception - { - Test FromDuration = new Test(); - - FromDuration.initialize(TO_DURATION); - - FromDuration.attemptConversion(TO_DURATION); - FromDuration.attemptConversion(TO_DATE_TIME); - FromDuration.attemptConversion(TO_TIME); - FromDuration.attemptConversion(TO_DAY); - FromDuration.attemptConversion(TO_MONTH); - FromDuration.attemptConversion(TO_MONTH_DAY); - FromDuration.attemptConversion(TO_YEAR); - FromDuration.attemptConversion(TO_YEAR_MONTH); - FromDuration.attemptConversion(TO_YEAR_MONTH_DAY); - } - - public void testConversionsFromMonth() throws Exception - { - Test FromMonth = new Test(); - - FromMonth.initialize(TO_MONTH); - - FromMonth.attemptConversion(TO_MONTH); - } - - public void testConversionsFromMonthDay() throws Exception - { - Test FromMonthDay = new Test(); - - FromMonthDay.initialize(TO_MONTH_DAY); - FromMonthDay.attemptConversion(TO_MONTH_DAY); - FromMonthDay.attemptConversion(TO_MONTH); - FromMonthDay.attemptConversion(TO_DAY); - } - - public void testConversionsFromTime() throws Exception - { - Test FromTime = new Test(); - - FromTime.initialize(TO_TIME); - - FromTime.attemptConversion(TO_TIME); - } - - public void testConversionsFromYear() throws Exception - { - Test FromYear = new Test(); - - FromYear.initialize(TO_YEAR); - - FromYear.attemptConversion(TO_YEAR); - } - - public void testConversionsFromYearMonth() throws Exception - { - Test FromYearMonth = new Test(); - - FromYearMonth.initialize(TO_YEAR_MONTH); - - FromYearMonth.attemptConversion(TO_YEAR_MONTH); - FromYearMonth.attemptConversion(TO_MONTH); - FromYearMonth.attemptConversion(TO_YEAR); - } - - public void testConversionsFromYearMonthDay() throws Exception - { - Test FromYearMonthDay = new Test(); - - FromYearMonthDay.initialize(TO_YEAR_MONTH_DAY); - - FromYearMonthDay.attemptConversion(TO_YEAR_MONTH_DAY); - FromYearMonthDay.attemptConversion(TO_YEAR_MONTH); - FromYearMonthDay.attemptConversion(TO_MONTH_DAY); - FromYearMonthDay.attemptConversion(TO_YEAR); - FromYearMonthDay.attemptConversion(TO_MONTH); - FromYearMonthDay.attemptConversion(TO_DAY); - } - - // Ensure that strings that should be recognized by toDate do not - // result in a null Date value. - - public void testToDateFormats() throws Exception - { - String[] validStrings = - { - "2006-03-31T03:30:45.123Z", - "-2006-03-31T03:30:45.1Z", - "2006-03-31T03:30:45Z", - "2006-03-31T03:30:45.123", - "2006-03-31T03:30:45.1", - "-2006-03-31T03:30:45", - "2006-03-31T03:30:45.123 EDT", - "2006-03-31T03:30:45.1 EDT", - "2006-03-31T03:30:45 EDT", - "---05 PST", - "---04", - "--12 GMT", - "--12", - "--08-08 EST", - "--08-08", - "1976-08-08 PDT", - "1976-08-08", - "88-12 CST", - "1988-12", - "2005 CDT", - "1999", - "P2006Y 08M 10D T 12H 24M 07S", - "P2006Y 10D T 12H", - "-P2006Y 08M 10D T 07S.2", - "P08M 10D T 07H", - "-P 04M 10DT12H 24S.88", - "PT12H" - }; - - for (int i = 0; i < validStrings.length; i++) - { - assertNotNull("DataHelper.toData() should not return null for '" + validStrings[i] + "'.", - data_helper.toDate(validStrings[i])); - } - - } - - public void testDateTime(){ - // a small bolt on test case resulting from a fix for JIRA TUSCANY-1044 - String date = DataHelper.INSTANCE.toDateTime(DataHelper.INSTANCE.toCalendar("2007-02-04T00:00:00.200Z")); - assertEquals("2007-02-04T00:00:00.200Z", date); - } - -} - diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java deleted file mode 100644 index f6afd5c458..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * - * 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 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 DefineOpenContentPropertyTestCase extends TestCase { - private final String TEST_MODEL = "/open.xsd"; - private final String TEST_NAMESPACE = "http://www.example.com/open"; - private final String TEST_DATA = "/openContentProperty.xml"; - - private TypeHelper typeHelper; - private XSDHelper xsdHelper; - private XMLHelper xmlHelper; - private DataFactory dataFactory; - - public void testDefineOpenContentProperty() throws IOException { - Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote"); - DataObject quote = dataFactory.create(quoteType); - - Property symbolProperty = quoteType.getProperty("symbol"); - assertFalse(symbolProperty.isOpenContent()); - - quote.setString(symbolProperty, "s1"); - - Property companyProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "company"); - assertTrue(companyProperty.isOpenContent()); - - DataObject company = quote.createDataObject(companyProperty); - company.setString("name", "FlyByNightTechnology"); - - Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price"); - assertTrue(priceProperty.isOpenContent()); - - quote.getList(priceProperty).add(new BigDecimal("1000.0")); - - // Define a new SDO open content property with simple type - DataObject p = dataFactory.create("commonj.sdo", "Property"); - p.set("type", typeHelper.getType("commonj.sdo", "Decimal")); - p.set("name", "highPrice"); - Property highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p); - assertTrue(highPrice.isOpenContent()); - - quote.setBigDecimal(highPrice, new BigDecimal("1100.0")); - - // Define a new SDO open content property with complex type - DataObject mutualFundQuotePropertyDef = dataFactory.create("commonj.sdo", "Property"); - mutualFundQuotePropertyDef.set("type", quoteType); - mutualFundQuotePropertyDef.set("name", "mutualFundQuote"); - mutualFundQuotePropertyDef.setBoolean("containment", true); - Property mutualFundQuoteProperty = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, mutualFundQuotePropertyDef); - assertTrue(mutualFundQuoteProperty.isOpenContent()); - - DataObject mutualFundQuote = quote.createDataObject(mutualFundQuoteProperty); - mutualFundQuote.setString("symbol", "mutual-1"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save(quote, TEST_NAMESPACE, "openStockQuote", baos); - - assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); - - // validate existing property condition - Property duplicateProp = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p); - assertTrue(highPrice.equals(duplicateProp)); - - // validate error condition, where new property exists with different type - boolean errorCondition = false; - try - { - p = dataFactory.create("commonj.sdo", "Property"); - p.set("type", typeHelper.getType("commonj.sdo", "String")); - p.set("name", "highPrice"); - highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p); - } - catch( IllegalArgumentException ex ) - { - errorCondition = true; - } - assertTrue(errorCondition); - } - - protected void setUp() throws Exception { - super.setUp(); - - HelperContext hc = SDOUtil.createHelperContext(); - typeHelper = hc.getTypeHelper(); - dataFactory = hc.getDataFactory(); - xsdHelper = hc.getXSDHelper(); - xmlHelper = hc.getXMLHelper(); - - // Populate the meta data for the test (Stock Quote) model - URL url = getClass().getResource(TEST_MODEL); - InputStream inputStream = url.openStream(); - xsdHelper.define(inputStream, url.toString()); - inputStream.close(); - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java deleted file mode 100644 index 5b3e814f69..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java +++ /dev/null @@ -1,704 +0,0 @@ -/** - * - * 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.math.BigDecimal; -import java.util.ArrayList; -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.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; - -public class DefineTypeTestCase extends TestCase -{ - private static final String CUSTOMER1_XML = "/customer1.xml"; - private static final String CUSTOMER2_XML = "/customer2.xml"; - private static final String OPEN_XML = "/open2.xml"; - private static final String MIXED_XML = "/mixed2.xml"; - private static final String MIXEDOPEN_XML = "/mixedopen.xml"; - - HelperContext hc; - - protected void setUp() throws Exception { - super.setUp(); - hc = SDOUtil.createHelperContext(); - } - - public void testDefineTypeRoundTrip() throws Exception { - TypeHelper types = hc.getTypeHelper(); - DataFactory factory = hc.getDataFactory(); - XMLHelper xmlHelper = hc.getXMLHelper(); - - Type intType = types.getType("commonj.sdo", "Int"); - Type stringType = types.getType("commonj.sdo", "String"); - - Property xmlElementProp = hc.getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false); - - // 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 as an XSD attribute - DataObject custNumProperty = customerType.createDataObject("property"); - custNumProperty.set("name", "custNum"); - custNumProperty.set("type", intType); - custNumProperty.setBoolean(xmlElementProp, false); - - // create a first name property as an XSD attribute - DataObject firstNameProperty = - customerType.createDataObject("property"); - firstNameProperty.set("name", "firstName"); - firstNameProperty.set("type", stringType); - firstNameProperty.setBoolean(xmlElementProp, false); - - // create a last name property as an XSD attribute - DataObject lastNameProperty = customerType.createDataObject("property"); - lastNameProperty.set("name", "lastName"); - lastNameProperty.set("type", stringType); - lastNameProperty.setBoolean(xmlElementProp, false); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save(customerType, "commonj.sdo", "type", baos); - - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - XMLDocument xdoc = xmlHelper.load(bais); - - customerType = xdoc.getRootObject(); - - // now define the Customer type so that customers can be made - types.define(customerType); - - DataObject customer1 = factory.create("http://example.com/customer", - "Customer"); - - customer1.setInt("custNum", 1); - customer1.set("firstName", "John"); - customer1.set("lastName", "Adams"); - DataObject customer2 = factory.create("http://example.com/customer", - "Customer"); - customer2.setInt("custNum", 2); - customer2.set("firstName", "Jeremy"); - customer2.set("lastName", "Pavick"); - - assertNotNull(customer1); - Type type = customer1.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertEquals(type.getProperty("custNum").getType(), intType); - assertEquals(type.getProperty("firstName").getType(), stringType); - assertEquals(type.getProperty("lastName").getType(), stringType); - - assertNotNull(customer2); - type = customer2.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertEquals(type.getProperty("custNum").getType(), intType); - assertEquals(type.getProperty("firstName").getType(), stringType); - assertEquals(type.getProperty("lastName").getType(), stringType); - - baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer1, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER1_XML))); - - baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer2, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER2_XML))); - } - - public void testDefineType() throws Exception - { - TypeHelper types = hc.getTypeHelper(); - DataFactory factory = hc.getDataFactory(); - XMLHelper xmlHelper = hc.getXMLHelper(); - - Type intType = types.getType("commonj.sdo", "Int"); - Type stringType = types.getType("commonj.sdo", "String"); - - Property xmlElementProp = hc.getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false); - - // 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); - custNumProperty.setBoolean(xmlElementProp, false); - - // create a first name property - DataObject firstNameProperty = - customerType.createDataObject("property"); - firstNameProperty.set("name", "firstName"); - firstNameProperty.set("type", stringType); - firstNameProperty.setBoolean(xmlElementProp, false); - - // create a last name property - DataObject lastNameProperty = customerType.createDataObject("property"); - lastNameProperty.set("name", "lastName"); - lastNameProperty.set("type", stringType); - lastNameProperty.setBoolean(xmlElementProp, false); - - // now define the Customer type so that customers can be made - types.define(customerType); - - DataObject customer1 = factory.create("http://example.com/customer", - "Customer"); - - customer1.setInt("custNum", 0); - assertTrue(customer1.isSet("custNum")); - - customer1.setInt("custNum", 1); - customer1.set("firstName", "John"); - customer1.set("lastName", "Adams"); - DataObject customer2 = factory.create("http://example.com/customer", - "Customer"); - customer2.setInt("custNum", 2); - customer2.set("firstName", "Jeremy"); - customer2.set("lastName", "Pavick"); - - assertNotNull(customer1); - Type type = customer1.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertEquals(type.getProperty("custNum").getType(), intType); - assertEquals(type.getProperty("firstName").getType(), stringType); - assertEquals(type.getProperty("lastName").getType(), stringType); - - assertNotNull(customer2); - assertNotNull(types.getOpenContentProperty("http://example.com/customer", "customer")); - - type = customer2.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertEquals(type.getProperty("custNum").getType(), intType); - assertEquals(type.getProperty("firstName").getType(), stringType); - assertEquals(type.getProperty("lastName").getType(), stringType); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer1, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER1_XML))); - - baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer2, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER2_XML))); - } - - public void testDefineDataType() throws Exception - { - TypeHelper types = hc.getTypeHelper(); - DataFactory factory = hc.getDataFactory(); - XMLHelper xmlHelper = hc.getXMLHelper(); - XSDHelper xsdHelper = hc.getXSDHelper(); - - Property xmlElementProp = hc.getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false); - Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false); - - // create a data types - DataObject intType = factory.create("commonj.sdo", "Type"); - intType.set("uri", "http://example.com/customer"); - intType.set("name", "MyIntType"); - intType.setBoolean("dataType", true); - intType.set(javaClassProperty, "int"); - - DataObject stringType = factory.create("commonj.sdo", "Type"); - stringType.set("uri", "http://example.com/customer"); - stringType.set("name", "MyStringType"); - stringType.setBoolean("dataType", true); - stringType.set(javaClassProperty, "java.lang.String"); - - // 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); - custNumProperty.setBoolean(xmlElementProp, false); - - // create a first name property - DataObject firstNameProperty = - customerType.createDataObject("property"); - firstNameProperty.set("name", "firstName"); - firstNameProperty.set("type", stringType); - firstNameProperty.setBoolean(xmlElementProp, false); - - // create a last name property - DataObject lastNameProperty = customerType.createDataObject("property"); - lastNameProperty.set("name", "lastName"); - lastNameProperty.set("type", stringType); - lastNameProperty.setBoolean(xmlElementProp, false); - - // now define the Customer type so that customers can be made - types.define(customerType); - - DataObject customer1 = factory.create("http://example.com/customer", - "Customer"); - - customer1.setInt("custNum", 1); - customer1.set("firstName", "John"); - customer1.set("lastName", "Adams"); - DataObject customer2 = factory.create("http://example.com/customer", - "Customer"); - customer2.setInt("custNum", 2); - customer2.set("firstName", "Jeremy"); - customer2.set("lastName", "Pavick"); - - assertNotNull(customer1); - Type type = customer1.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - - type = type.getProperty("custNum").getType(); - assertEquals(type.getURI(), "http://example.com/customer"); - assertEquals(type.getName(), "MyIntType"); - assertTrue(type.isDataType()); - - assertNotNull(customer2); - assertNotNull(types.getOpenContentProperty("http://example.com/customer", "customer")); - - type = customer2.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer1, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER1_XML))); - - baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer2, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER2_XML))); - } - - public void testFastDefineType() throws Exception - { - TypeHelper types = hc.getTypeHelper(); - DataFactory factory = hc.getDataFactory(); - XMLHelper xmlHelper = hc.getXMLHelper(); - - Type intType = types.getType("commonj.sdo", "Int"); - Type stringType = types.getType("commonj.sdo", "String"); - - // create a new Type for Customers - Type customerType = SDOUtil.createType(hc, "http://example.com/customer", "Customer", false); - - // create a customer number property - Property custNumProperty = SDOUtil.createProperty(customerType, "custNum", intType); - SDOUtil.setPropertyXMLKind(custNumProperty, false); - - // create a first name property - Property firstNameProperty = SDOUtil.createProperty(customerType, "firstName", stringType); - SDOUtil.setPropertyXMLKind(firstNameProperty, false); - - // create a last name property - Property lastNameProperty = SDOUtil.createProperty(customerType, "lastName", stringType); - SDOUtil.setPropertyXMLKind(lastNameProperty, false); - - DataObject customer1 = factory.create("http://example.com/customer", - "Customer"); - customer1.setInt("custNum", 1); - customer1.set("firstName", "John"); - customer1.set("lastName", "Adams"); - DataObject customer2 = factory.create("http://example.com/customer", - "Customer"); - customer2.setInt("custNum", 2); - customer2.set("firstName", "Jeremy"); - customer2.set("lastName", "Pavick"); - - assertNotNull(customer1); - Type type = customer1.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertEquals(type.getProperty("custNum").getType(), intType); - assertEquals(type.getProperty("firstName").getType(), stringType); - assertEquals(type.getProperty("lastName").getType(), stringType); - - assertNotNull(customer2); - type = customer2.getType(); - assertNotNull(type.getProperty("custNum")); - assertNotNull(type.getProperty("firstName")); - assertNotNull(type.getProperty("lastName")); - assertEquals(type.getProperty("custNum").getType(), intType); - assertEquals(type.getProperty("firstName").getType(), stringType); - assertEquals(type.getProperty("lastName").getType(), stringType); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer1, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER1_XML))); - - baos = new ByteArrayOutputStream(); - xmlHelper.save( - customer2, - "http://example.com/customer", - "Customer", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(CUSTOMER2_XML))); - } - - public void testDefineSequencedType() throws Exception - { - - TypeHelper types = hc.getTypeHelper(); - DataFactory factory = hc.getDataFactory(); - XMLHelper xmlHelper = hc.getXMLHelper(); - - Type stringType = types.getType("commonj.sdo", "String"); - Type decimalType = types.getType("commonj.sdo", "Decimal"); - - // Define a new mixed type - MixedQuote - DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); - mixedQuoteType.set("uri", "http://www.example.com/mixed"); - mixedQuoteType.set("name", "MixedQuote"); - mixedQuoteType.set("sequenced", Boolean.TRUE); - - DataObject symbolProperty = mixedQuoteType.createDataObject("property"); - symbolProperty.set("name", "symbol"); - symbolProperty.set("type", stringType); - - DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); - companyNameProperty.set("name", "companyName"); - companyNameProperty.set("type", stringType); - - DataObject priceProperty = mixedQuoteType.createDataObject("property"); - priceProperty.set("name", "price"); - priceProperty.set("type", decimalType); - - DataObject quotesProperty = mixedQuoteType.createDataObject("property"); - quotesProperty.set("name", "quotes"); - quotesProperty.set("type", mixedQuoteType); - quotesProperty.set("many", Boolean.TRUE); - quotesProperty.set("containment", Boolean.TRUE); - - types.define(mixedQuoteType); - - DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote"); - - assertTrue(quote.getType().isSequenced()); - - Sequence sequence = quote.getSequence(); - - sequence.addText("\n "); - - quote.setString("symbol", "fbnt"); - - sequence.addText("\n "); - - quote.setString("companyName", "FlyByNightTechnology"); - - sequence.addText("\n some text\n "); - - DataObject child = quote.createDataObject("quotes"); - child.setBigDecimal("price", new BigDecimal("2000.0")); - - sequence.addText("\n more text\n "); - - // quote.setBigDecimal("price", new BigDecimal("1000.0")); - sequence.add("price", new BigDecimal("1000.0")); - - sequence.addText("\n"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos); - assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXED_XML))); - } - - public void testDefineSequencedOpenType() throws Exception - { - TypeHelper types = hc.getTypeHelper(); - DataFactory factory = hc.getDataFactory(); - XMLHelper xmlHelper = hc.getXMLHelper(); - - Type stringType = types.getType("commonj.sdo", "String"); - Type decimalType = types.getType("commonj.sdo", "Decimal"); - - // Define a new mixed type - MixedQuote - DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); - mixedQuoteType.set("uri", "http://www.example.com/mixed"); - mixedQuoteType.set("name", "MixedOpenQuote"); - mixedQuoteType.set("sequenced", Boolean.TRUE); - mixedQuoteType.set("open", Boolean.TRUE); - -// DataObject symbolProperty = mixedQuoteType.createDataObject("property"); -// symbolProperty.set("name", "symbol"); -// symbolProperty.set("type", stringType); - - DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); - companyNameProperty.set("name", "companyName"); - companyNameProperty.set("type", stringType); - - DataObject priceProperty = mixedQuoteType.createDataObject("property"); - priceProperty.set("name", "price"); - priceProperty.set("type", decimalType); - - DataObject quotesProperty = mixedQuoteType.createDataObject("property"); - quotesProperty.set("name", "quotes"); - quotesProperty.set("type", mixedQuoteType); - quotesProperty.set("many", Boolean.TRUE); - quotesProperty.set("containment", Boolean.TRUE); - - types.define(mixedQuoteType); - - // Define a global type - DataObject globalType = factory.create("commonj.sdo", "Type"); - globalType.set("uri", "http://www.example.com/open"); - // Don't set the type's name - null is used for types containing global properties. - - DataObject symbolProperty = globalType.createDataObject("property"); - symbolProperty.set("name", "symbol"); - symbolProperty.set("type", stringType); - symbolProperty.set("containment", Boolean.TRUE); - - types.define(globalType); - - DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote"); - - assertTrue(quote.getType().isSequenced()); - - Sequence sequence = quote.getSequence(); - - sequence.addText("\n "); - - Type definedGlobalType = types.getType("http://www.example.com/open", "DocumentRoot"); - - Property definedSymbolProperty = definedGlobalType.getProperty("symbol"); - quote.setString(definedSymbolProperty, "fbnt"); - - sequence.addText("\n "); - - quote.setString("companyName", "FlyByNightTechnology"); - - sequence.addText("\n some text\n "); - - DataObject child = quote.createDataObject("quotes"); - child.setBigDecimal("price", new BigDecimal("2000.0")); - - sequence.addText("\n more text\n "); - - // quote.setBigDecimal("price", new BigDecimal("1000.0")); - sequence.add("price", new BigDecimal("1000.0")); - - sequence.addText("\n"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos); - assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXEDOPEN_XML))); - } - - - public void testDefineOpenType() throws Exception - { - TypeHelper types = hc.getTypeHelper(); - DataFactory factory = hc.getDataFactory(); - XMLHelper xmlHelper = hc.getXMLHelper(); - - Type stringType = types.getType("commonj.sdo", "String"); - Type decimalType = types.getType("commonj.sdo", "Decimal"); - - Property xmlElementProp = hc.getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false); - - // Define a new open type - OpenQuote - DataObject openQuoteType = factory.create("commonj.sdo", "Type"); - openQuoteType.set("uri", "http://www.example.com/open"); - openQuoteType.set("name", "OpenQuote"); - openQuoteType.set("open", Boolean.TRUE); - openQuoteType.setBoolean("open", true); - - types.define(openQuoteType); - - // Define new type - CompanyType - DataObject companyType = factory.create("commonj.sdo", "Type"); - companyType.set("uri", "http://www.example.com/open"); - companyType.set("name", "CompanyType"); - - // Create CompanyType property - "name" as an XSD attribute - DataObject nameProperty = companyType.createDataObject("property"); - nameProperty.set("name", "name"); - nameProperty.set("type", stringType); - nameProperty.set("containment", Boolean.TRUE); - nameProperty.setBoolean(xmlElementProp, false); - - types.define(companyType); - - // Define open content property - company - DataObject symbolProperty = factory.create("commonj.sdo", "Property"); - symbolProperty.set("name", "symbol"); - symbolProperty.set("type", stringType); - types.defineOpenContentProperty("http://www.example.com/open", symbolProperty); - - // Define open content property - company - DataObject companyProperty = factory.create("commonj.sdo", "Property"); - companyProperty.set("name", "company"); - companyProperty.set("type", companyType); - companyProperty.set("containment", Boolean.TRUE); - types.defineOpenContentProperty("http://www.example.com/open", companyProperty); - - // Define open content property - price - DataObject priceProperty = factory.create("commonj.sdo", "Property"); - priceProperty.set("name", "price"); - priceProperty.set("type", decimalType); - types.defineOpenContentProperty("http://www.example.com/open", priceProperty); - - // Create DataObject instances - DataObject openQuote = factory.create("http://www.example.com/open", "OpenQuote"); - assertTrue(openQuote.getType().isOpen()); - - Property definedSymbolProperty = types.getOpenContentProperty("http://www.example.com/open", "symbol"); - openQuote.set(definedSymbolProperty, "s1"); - - Property definedCompanyProperty = types.getOpenContentProperty("http://www.example.com/open", "company"); - DataObject company = openQuote.createDataObject(definedCompanyProperty); - company.setString("name", "FlyByNightTechnology"); - - Property definedPriceProperty = types.getOpenContentProperty("http://www.example.com/open", "price"); - openQuote.setBigDecimal(definedPriceProperty, new BigDecimal("1000.0")); - - assertEquals(definedPriceProperty.getType(), decimalType); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - xmlHelper.save( - openQuote, - "http://www.example.com/open", - "openStockQuote", baos); - assertTrue( - TestUtil.equalXmlFiles( - new ByteArrayInputStream(baos.toByteArray()), - getClass().getResource(OPEN_XML))); - } - -/** - * Type T1 has property t1p of type T2, type T2 has property t2p of type T1. - * Ensure that the typehelper can handle this circularity - */ -public void testInterdependentTypes() - { - DataObject t1 = DataFactory.INSTANCE.create("commonj.sdo", "Type"); - DataObject t1p = DataFactory.INSTANCE.create("commonj.sdo", "Property"); - DataObject t2 = DataFactory.INSTANCE.create("commonj.sdo", "Type"); - DataObject t2p = DataFactory.INSTANCE.create("commonj.sdo", "Property"); - - t1.set("name", "T1"); - t1.set("uri", "foo"); - t2.set("name", "T2"); - t2.set("uri", "foo"); - - t1.getList("property").add(t1p); - t2.getList("property").add(t2p); - t1p.set("name", "t1p"); - t1p.set("type", t2); - t2p.set("name", "t2p"); - t2p.set("type", t1); - - List ts = new ArrayList(); - ts.add(t1); - ts.add(t2); - List types = hc.getTypeHelper().define(ts); - - Type first = (Type)types.get(0); - Type second = (Type)types.get(1); - - Type firstsPropsType = ((Property)first.getProperties().get(0)).getType(); - Type secondPropsType = ((Property)second.getProperties().get(0)).getType(); - - assertNotNull(first); - assertNotNull(second); - assertEquals(first, secondPropsType); - assertEquals(second, firstsPropsType); - - } - -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java deleted file mode 100644 index 65a838bb52..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * - * 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.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.net.URL; -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.tuscany.sdo.util.SDOUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; -import commonj.sdo.helper.XMLDocument; -import commonj.sdo.helper.XMLHelper; - - -public class DeserializationNoSchemaTestCase extends TestCase -{ - HelperContext hc; - - TypeHelper th; - - private final String xmlStr = - "<?xml version=\"1.0\" encoding=\"ASCII\"?> " + - "<simple:stockQuote xmlns:simple=\"www.example.com/simple\"> " + - "<symbol>fbnt</symbol> " + - "<companyName>FlyByNightTechnology</companyName> " + - "<price>1000.0</price> " + - "<open1>1000.0</open1> " + - "<high>1000.0</high> " + - "<low>1000.0</low> " + - "<volume>1000.0</volume> " + - "<change1>1000.0</change1> " + - "<quotes> " + - "<price>2000.0</price> " + - "</quotes> " + - "</simple:stockQuote>"; - - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java deleted file mode 100644 index 476f34c328..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java deleted file mode 100644 index 9c4f487b6a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * - * 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 java.util.regex.MatchResult; -//import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import junit.framework.TestCase; - -import org.apache.tuscany.sdo.api.SDOUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.Type; -import commonj.sdo.helper.HelperContext; - -public class DupElementTestCase extends TestCase { - HelperContext hc; - - private final String TEST_MODEL = "/dupelement.xsd"; - private final String TEST_URI = "http://www.example.com/dupelement"; - - protected void setUp() throws Exception { - super.setUp(); - - URL url = getClass().getResource(TEST_MODEL); - InputStream inputStream = url.openStream(); - - hc = SDOUtil.createHelperContext(); - - hc.getXSDHelper().define(inputStream, url.toString()); - - inputStream.close(); - } - - - public void test() { - Type quoteType = hc.getTypeHelper().getType(TEST_URI, "Quote"); - - DataObject quote = hc.getDataFactory().create(quoteType); - quote.set("symbol", "ACME"); - quote.set("companyName", "ACME Corp."); - - DataObject quote2 = hc.getDataFactory().create(quoteType); - - List quotes = quote.getList("quotes"); - quotes.add(quote2); - - try { - quote.set("quotes.0/symbol", "ACME-CHILD"); - quote.set("quotes.0/companyName", "ACME subsidiary corp."); - quote.setInt("quotes.0/companyNameInInt", 99); - quote.setInt("quotes.0/symbolInInt", 55); - } - catch (Exception e) { - fail("Set value on the wrong properties with the same name"); - } - assert(quote.get("quotes.0/companyName") instanceof String); - assert(quote.get("quotes.0/symbol") instanceof String); - assert(quote.get("quotes.0/companyNameInInt") instanceof Integer); - assert(quote.get("quotes.0/symbolInInt") instanceof Integer); - - String doc = hc.getXMLHelper().save(quote, "http://www.example.com/dupelement", "stockQuote"); - //System.out.println(doc); - assertTrue( - Pattern.matches("[\\s\\S]*<companyName>[\\s]*ACME Corp.[\\s]*</companyName>[\\s\\S]*", - doc)); - assertTrue( - Pattern.matches("[\\s\\S]*<companyName>[\\s]*99[\\s]*</companyName>[\\s\\S]*", - doc)); - assertTrue( - Pattern.matches("[\\s\\S]*symbol[\\s]*=[\\s]*\"55\"[\\s\\S]*", - doc)); - assertTrue( - Pattern.matches("[\\s\\S]*<symbol>[\\s]*ACME-CHILD[\\s]*</symbol>[\\s\\S]*", - doc)); - - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java deleted file mode 100644 index 4c347867e0..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * - * 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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<xsd:schema\n" - + " targetNamespace=\"http://www.example.com/dynamicTypesFromSchemaSimple\"\n" - + " xmlns:dtfs=\"http://www.example.com/dynamicTypesFromSchemaSimple\"\n" - + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" + " \n" - + " <xsd:complexType name=\"TestType0\" mixed=\"true\">\n" + " <xsd:sequence>\n" - + " <xsd:element name=\"aString\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>\n" - + " <xsd:element name=\"aBoolean\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:boolean\"/>\n" - + " <xsd:element name=\"aFloat\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:float\"/>\n" - + " </xsd:sequence>\n" + " </xsd:complexType>\n" + " \n" - + " <xsd:element name=\"testElement0\" type=\"dtfs:TestType0\"/>\n" + " \n" + "</xsd:schema>\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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" - + "<dtfs:testElement0 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" - + " xmlns:dtfs=\"http://www.example.com/dynamicTypesFromSchemaSimple\">\n" - + " <aString>This is a repeated string.</aString>\n" + " <aString>This is a repeated string.</aString>\n" - + " <aBoolean>true</aBoolean>\n" + " <aBoolean>false</aBoolean>\n" + " <aBoolean>true</aBoolean>\n" - + " <aBoolean>1</aBoolean>\n" + " <aBoolean>0</aBoolean>\n" + " <aFloat>0</aFloat>\n" - + " <aFloat>12.5</aFloat>\n" + " <aFloat>0</aFloat>\n" + "</dtfs:testElement0>\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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java deleted file mode 100644 index af4bb4d928..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java +++ /dev/null @@ -1,1878 +0,0 @@ -/** - * - * 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<T>(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<T>(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<T>(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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java deleted file mode 100644 index e630a8f903..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * - * 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( -"<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+ - "<element name=\"root\">"+ - "<complexType>"+ - "<sequence>"+ - "<element name=\"unqualifiedElement\" type=\"string\"/>"+ - "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+ - "</sequence>"+ - "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+ - "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+ - "</complexType>"+ - "</element>"+ -"</schema>"); - 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( -"<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\" qualifiedAttribute=\"q\">"+ - "<p:unqualifiedElement/>"+ - "<qualifiedElement/>"+ -"</p:root>", 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("<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\"/>"); - } - - public void testQualifiedAttribute() throws IOException { - load("<p:root xmlns:p=\"testNS\" qualifiedAttribute=\"q\"/>"); - } - - public void testUnqualifiedElement() throws IOException { - load( -"<p:root xmlns:p=\"testNS\">"+ - "<p:unqualifiedElement/>"+ -"</p:root>"); - } - - public void testQualifiedElement() throws IOException { - load( -"<p:root xmlns:p=\"testNS\">"+ - "<qualifiedElement/>"+ -"</p:root>"); - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java deleted file mode 100644 index 14e81b6a32..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ImplSpecificTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ImplSpecificTestCase.java deleted file mode 100644 index d5117c3fed..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/ImplSpecificTestCase.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * - * 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; - -public class ImplSpecificTestCase extends TestCase { - - public void testThreadSafeHashmapIsAvailable() { - // this will fail if using Java 1.4.x and the backport library has been removed from the classpath. - // It is here because ChangeSummaryImpl contains the same logic for finding a threadsafe hashmap implementation - // but it will fallback to a synchronized hashmap - // if no threadsafe hashmap is available, hence no test failure will occur, but a performance hit - // will. This test is here top show a failure with java 1.4 to ensure that no-one removes the backport - // dependency introduced for TUSCANY-1006. - assertNotNull(loadConcurrentHashMapClazz()); - } - - protected void setUp() throws Exception { - super.setUp(); - - } - - private static String[] concurrentHashMapClazzNames = new String[] { - "java.util.concurrent.ConcurrentHashMap", - "edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap"}; - - private static Class loadConcurrentHashMapClazz() - { - Class mapClazz = null; - for (int i = 0; i < concurrentHashMapClazzNames.length; i++) - { - String concurrentHashMapClazzName = concurrentHashMapClazzNames[i]; - try - { - mapClazz = Class.forName(concurrentHashMapClazzName, true, Thread.currentThread().getContextClassLoader()); - } - catch (Exception ignored) {} - if (mapClazz != null) - { - break; - } - try - { - mapClazz = Class.forName(concurrentHashMapClazzName); - } - catch (Exception ignored) {} - if (mapClazz != null) - { - break; - } - } - // System.out.println("threadsafe hashmap = " + mapClazz.getName()); - return mapClazz; - } - -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java deleted file mode 100644 index 1eef4ea657..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * 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 <any> - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java deleted file mode 100644 index df69555d76..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java +++ /dev/null @@ -1,297 +0,0 @@ -/** - * - * 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 = "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " + - "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + - "xmlns:simple=\"http://www.example.com/simple\">" + - "<xsd:element name=\"company\" type=\"simple:Company\"/>" + - "<xsd:complexType name=\"Company\">" + - "<xsd:sequence>" + - "<xsd:element name=\"symbol\" type=\"xsd:string\"/>" + - "<xsd:element name=\"companyName\" type=\"xsd:string\"/>" + - "<xsd:element name=\"employees\" type=\"simple:Employee\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>" + - "</xsd:sequence>" + - "</xsd:complexType>" + - - "<xsd:complexType name=\"Employee\">" + - "<xsd:sequence>" + - "<xsd:element name=\"employeeID\" type=\"xsd:string\"/>" + - "<xsd:element name=\"employeeName\" type=\"xsd:string\"/>" + - "</xsd:sequence>" + - "</xsd:complexType>" + - "</xsd:schema>"; - - 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<Type> 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java deleted file mode 100644 index bd66949c89..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java deleted file mode 100644 index 885153b62e..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java +++ /dev/null @@ -1,243 +0,0 @@ -/** - * - * 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); - } - - //Amita - public void testEnumProperty() - { - Type type = typeHelper.getType(TEST_NAMESPACE, "ExampleRating"); - assertTrue(getInstanceProperty(type, "enumeration") != null); - List enumFacet = SDOUtil.getEnumerationFacet(type); - assertEquals(3, enumFacet.size()); - assertEquals("", enumFacet.get(0)); - assertEquals("Good", enumFacet.get(1)); - assertEquals("Bad", enumFacet.get(2)); - } - - //Amita - public void testPatternProperty() - { - Type type = typeHelper.getType(TEST_NAMESPACE, "PhoneNumber"); - assertTrue(getInstanceProperty(type, "pattern") != null); - List patternFacet = SDOUtil.getPatternFacet(type); - assertEquals(2, patternFacet.size()); - assertEquals("\\d{3}-\\d{4}", patternFacet.get(0)); - assertEquals("\\d{6}-\\d{8}", patternFacet.get(1)); - } - - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java deleted file mode 100644 index 806662a83c..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java deleted file mode 100644 index 544672a8b1..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java deleted file mode 100644 index 5d1637865b..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * - * 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 junit.framework.TestCase; - -import org.apache.tuscany.sdo.api.SDOUtil; -import org.apache.tuscany.sdo.api.Event; -import org.apache.tuscany.sdo.impl.ListenerBase; - -import commonj.sdo.DataObject; -import commonj.sdo.Type; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; - -/** - * Test DataObject Property value change notification - */ -public class NotificationTestCase extends TestCase { - - HelperContext hc; - TypeHelper th; - - private class Observer extends ListenerBase { - - private int notificationCount; - private Event lastEvent; - - public int getNotificationCount() { - return notificationCount; - } - - public Event getLastEvent() { - return lastEvent; - } - - public Observer() { - notificationCount = 0; - } - - public void eventNotification(Event e) { - - if (e.getEventType() != Event.REMOVE_LISTENER) { - notificationCount++; - lastEvent = e; - } - } - - } - - public void testTransitions() throws IOException { - final String TEST_MODEL = "/simple.xsd"; - final String TEST_NAMESPACE = "http://www.example.com/simple"; - - // 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(); - - Type quoteType = th.getType(TEST_NAMESPACE, "Quote"); - DataObject quote = hc.getDataFactory().create(quoteType); - Observer o = new Observer(); - SDOUtil.addChangeListener(quote, o); - - Event e; - - String firstName = "FlyByNightTechnology"; - - int changeCount = 0; - - quote.setString("companyName", firstName); - assertEquals(++changeCount, o.getNotificationCount()); - e = o.getLastEvent(); - assertEquals(Event.SET, e.getEventType()); - assertEquals(null, e.getOldValue()); - assertFalse(e.wasSet()); - - quote.setString("companyName", "FBNT"); - e = o.getLastEvent(); - assertTrue(e.wasSet()); - - assertEquals(firstName, e.getOldValue()); - assertEquals(++changeCount, o.getNotificationCount()); - assertEquals("companyName", e.getProperty().getName()); - - SDOUtil.removeChangeListener(quote, o); - - quote.setString("companyName", "3rdValue"); - e = o.getLastEvent(); - - assertEquals(firstName, e.getOldValue()); - assertEquals(changeCount /* no ++ */, o.getNotificationCount()); - - SDOUtil.addChangeListener(quote, o); - - quote.setString("companyName", "3rdValue"); - assertEquals(++changeCount, o.getNotificationCount()); - e = o.getLastEvent(); - assertTrue(e.isTouch()); - assertTrue(e.wasSet()); - - quote.unset("companyName"); - assertEquals(++changeCount, o.getNotificationCount()); - e = o.getLastEvent(); - assertTrue(e.wasSet()); - - - quote.set("companyName", "4thValue"); - assertEquals(++changeCount, o.getNotificationCount()); - e = o.getLastEvent(); - assertFalse(e.wasSet()); - - assertEquals(Event.NO_INDEX, e.getPosition()); - - DataObject child = quote.createDataObject("quotes"); - assertEquals(++changeCount, o.getNotificationCount()); - e = o.getLastEvent(); - assertFalse(e.wasSet()); - assertEquals(0, e.getPosition()); - assertEquals(Event.ADD, e.getEventType()); - - DataObject child2 = quote.createDataObject("quotes"); - assertEquals(++changeCount, o.getNotificationCount()); - e = o.getLastEvent(); - assertTrue(e.wasSet()); // the quotes property was previously set to a non empty list - assertEquals(1, e.getPosition()); - - child2.setString("companyName", "subsidiary"); - - assertEquals(changeCount /* no ++ */, o.getNotificationCount()); // not monitoring the child - - quote.getList("quotes").clear(); - e = o.getLastEvent(); - assertEquals(++changeCount, o.getNotificationCount()); - assertEquals(Event.REMOVE_MANY, e.getEventType()); - - List newList = new ArrayList(); - - newList.add(hc.getDataFactory().create(quoteType)); - newList.add(hc.getDataFactory().create(quoteType)); - - quote.getList("quotes").addAll(newList); - e = o.getLastEvent(); - assertEquals(++changeCount, o.getNotificationCount()); - assertEquals(Event.ADD_MANY, e.getEventType()); - - - - - } - - - protected void setUp() throws Exception { - super.setUp(); - - hc = SDOUtil.createHelperContext(); - th = hc.getTypeHelper(); - - } - -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java deleted file mode 100644 index 3e5a410aa3..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * - * 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.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.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();) { - 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();) { - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java deleted file mode 100644 index eaec327007..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java deleted file mode 100644 index e02ace5d2a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * - * 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 = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\" xmlns:tns=\"testNS\">"+ - "<element name=\"open\" type=\"string\"/>"+ - "<complexType name=\"Sequenced\">"+ - "<sequence>"+ - "<element name=\"localA\" type=\"string\" maxOccurs=\"unbounded\"/>"+ - "<choice maxOccurs=\"unbounded\">"+ - "<element name=\"choiceX\" type=\"string\"/>"+ - "<element name=\"choiceY\" type=\"string\"/>"+ - "</choice>"+ - "<element name=\"localB\" type=\"string\"/>"+ - "<any namespace=\"##any\" maxOccurs=\"unbounded\"/>"+ - "</sequence>"+ - "<anyAttribute/>"+ - "</complexType>"+ - "</schema>"; - - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java deleted file mode 100644 index a8e00d5eb2..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * - * 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 = - "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " + - "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + - "xmlns:simple=\"http://www.example.com/simple\"> " + - "<xsd:element name=\"bytesTypeTest\" type=\"simple:BytesTypeTest\"/> " + - "<xsd:complexType name=\"BytesTypeTest\"> " + - "<xsd:sequence> " + - "<xsd:element name=\"base64Binary\" type=\"xsd:base64Binary\"/> " + - "<xsd:element name=\"hexBinary\" type=\"xsd:hexBinary\"/> " + - "</xsd:sequence> " + - "</xsd:complexType> " + - "</xsd:schema>"; - - - 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 = "<base64Binary>"; - String endTag = "</base64Binary>"; - 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 = "<hexBinary>"; - String endTag = "</hexBinary>"; - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java deleted file mode 100644 index 36f038d779..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java deleted file mode 100644 index 55aae9d396..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java deleted file mode 100644 index 8db9ba9d04..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * - * 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.Type; -import commonj.sdo.helper.DataFactory; -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 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(); - } - - public void testBytesEquality() { - // Dynamically create a type - HelperContext scope = HelperProvider.getDefaultContext(); - TypeHelper types = scope.getTypeHelper(); - Type BytesType = types.getType("commonj.sdo", "Bytes"); - DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo", "Type"); - customerType.set("uri", "http://example.com/simple"); - customerType.set("name", "Simple"); - DataObject BytesProperty = customerType.createDataObject("property"); - BytesProperty.set("name", "BytesVal"); - BytesProperty.set("type", BytesType); - types.define(customerType); - - // Create two instances - DataObject obj1 = DataFactory.INSTANCE.create("http://example.com/simple", "Simple"); - DataObject obj2 = DataFactory.INSTANCE.create("http://example.com/simple", "Simple"); - - obj1.setBytes("BytesVal", new byte[] {120, 80, -40}); - obj2.setBytes("BytesVal", new byte[] {120, 80, -40}); - - assertTrue( scope.getEqualityHelper().equal(obj1, obj2) ); - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java deleted file mode 100644 index fb729ea125..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java deleted file mode 100644 index a7ab3f954a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java +++ /dev/null @@ -1,285 +0,0 @@ -/** - * - * 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<length; i++) - { - Node node = nodeList.item(i); - nodes.add(node); - getAllNodes(node.getChildNodes(), nodes); - } // for - } - - private static boolean equalNamedNodeMap(NamedNodeMap mapA, NamedNodeMap mapB) { - if (mapA == null) { - if (mapB == null) { - return true; - } - return false; - } - if (mapA.getLength() != mapB.getLength()) { - return false; - } - for (int i = 0; i < mapA.getLength(); i++) { - Node trialNode = mapA.item(i); - if (trialNode == null) { - return false; - } - Node checkNode = mapB.getNamedItem(trialNode.getNodeName()); - if (checkNode == null) { - return false; - } - if (!equalNode(trialNode, checkNode)) { - return false; - } - } - return true; - } - - private static boolean equalNode(Node nodeA, Node nodeB) { - if (nodeA == null) { - if (nodeB == null) { - return true; - } - return false; - } - // following is intended to provide same function as 1.5 isEqualNode() - if (nodeA.getNodeType() != nodeB.getNodeType()) { - return false; - } - if (!equalString(nodeA.getNodeName(), nodeB.getNodeName())) { - return false; - } - if (!equalString(nodeA.getLocalName(), nodeB.getLocalName())) { - return false; - } - if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) { - return false; - } - if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) { - return false; - } - if (!equalString(nodeA.getPrefix(), nodeB.getPrefix())) { - return false; - } - if (!equalString(nodeA.getNodeValue(), nodeB.getNodeValue())) { - return false; - } - if (!equalNamedNodeMap(nodeA.getAttributes(), nodeB.getAttributes())) { - return false; - } - if (!equalNodeList(nodeA.getChildNodes(), nodeB.getChildNodes())) { - return false; - } - if (nodeA.getNodeType() == Node.DOCUMENT_TYPE_NODE) { - DocumentType documentTypeA = (DocumentType) nodeA; - DocumentType documentTypeB = (DocumentType) nodeB; - if (!equalString(documentTypeA.getPublicId(), documentTypeB.getPublicId())) { - return false; - } - if (!equalString(documentTypeA.getSystemId(), documentTypeB.getSystemId())) { - return false; - } - if (!equalString(documentTypeA.getInternalSubset(), documentTypeB.getInternalSubset())) { - return false; - } - if (!equalNamedNodeMap(documentTypeA.getEntities(), documentTypeB.getEntities())) { - return false; - } - if (!equalNamedNodeMap(documentTypeA.getNotations(), documentTypeB.getNotations())) { - return false; - } - } - return true; - } - - private static boolean equalNodeList(NodeList nodeListA, NodeList nodeListB) { - if (nodeListA == null) { - if (nodeListB == null) { - return true; - } - return false; - } - return equalNodes(nodeListA, nodeListB); - } - - private static boolean equalString(String stringA, String stringB) { - if (stringA == null) { - if (stringB == null) { - return true; - } - return false; - } - return stringA.equals(stringB); - } - - private static boolean equalNodes(NodeList sourceNodeList, NodeList targetNodeList) - { - ArrayList sourceNodes = new ArrayList(); - ArrayList targetNodes = new ArrayList(); - - getAllNodes(sourceNodeList, sourceNodes); - getAllNodes(targetNodeList, targetNodes); - - int sourceLength = sourceNodes.size(); - int targetLength = targetNodes.size(); - - if (sourceLength != targetLength) - { - return false; - } - - for (int i=0; i<sourceLength; i++) - { - Node sourceNode = (Node)sourceNodes.get(i); - Node targetNode = (Node)targetNodes.get(i); - - /* remove comment when migrated to Java 1.5 - if (!sourceNode.isEqualNode(targetNode)) - { - return false; - } - */ - // following is intended as 1.4 equivalent of isEqualNode() - if (!equalNode(sourceNode, targetNode)) - { - return false; - } - } // for - - return true; - } - - public static boolean equalXmlFiles(URL source, URL target) - { - try { - return equalXmlFiles(source.openStream(), target.openStream()); - } - catch (IOException e) - { - return false; - } - } - - public static boolean equalXmlFiles(InputStream sourceStream, URL target) - { - try { - return equalXmlFiles(sourceStream, target.openStream()); - } - catch (IOException e) - { - return false; - } - } - - public static boolean equalXmlFiles(URL source, InputStream targetStream) - { - try { - return equalXmlFiles(source.openStream(), targetStream); - } - catch (IOException e) - { - return false; - } - } - - public static boolean equalXmlFiles(InputStream sourceStream, InputStream targetStream) - { - DocumentBuilder builder; - Document sourceDocument; - Document targetDocument; - - try { - builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - sourceDocument = builder.parse(sourceStream); - targetDocument = builder.parse(targetStream); - } - catch (FactoryConfigurationError fce) { - return false; - } - catch (ParserConfigurationException ce) { - return false; - } - catch (SAXException se) - { - return false; - } - catch (IOException ie) - { - return false; - } - - sourceDocument.normalize(); - targetDocument.normalize(); - - /* remove comment when migrated to Java 1.5 - if (!sourceDocument.getXmlVersion().equals(targetDocument.getXmlVersion())) - { - return false; - } - - String sourceXmlEncoding = sourceDocument.getXmlEncoding(); - String targetXmlEncoding = targetDocument.getXmlEncoding(); - - if (sourceXmlEncoding != null && targetXmlEncoding != null && - sourceXmlEncoding.equalsIgnoreCase(targetXmlEncoding)) - { - // continue - } - else - { - return false; - } - */ - - NodeList sourceNodes = sourceDocument.getChildNodes(); - NodeList targetNodes = targetDocument.getChildNodes(); - - return equalNodes(sourceNodes, targetNodes); - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java deleted file mode 100644 index 80dce4aaeb..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java +++ /dev/null @@ -1,1007 +0,0 @@ -/** - * - * 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 java.io.InputStream; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Comparator; -import java.util.Date; -import java.util.TimeZone; - -import org.apache.tuscany.sdo.util.DataObjectUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.TypeHelper; -import commonj.sdo.helper.XSDHelper; - -public class TypeConversionTestCase extends TestCase -{ - // The following constants are used to get Types from XSDs - - private static final String TEST_MODEL = "/api_test.xsd"; - private static final String TEST_NAMESPACE = "http://www.example.com/api_test"; - - // The following constants describe the index for the fields in api_test.xsd. - - private static final int STRING_VAL_INDEX = 0; - private static final int BOOLEAN_VAL_INDEX = 1; - private static final int BYTE_VAL_INDEX = 3; - private static final int DECIMAL_VAL_INDEX = 5; - private static final int INT_VAL_INDEX = 7; - private static final int FLOAT_VAL_INDEX = 8; - private static final int DOUBLE_VAL_INDEX = 9; - private static final int DATE_VAL_INDEX = 10; - private static final int SHORT_VAL_INDEX = 11; - private static final int LONG_VAL_INDEX = 12; - private static final int BYTES_VAL_INDEX = 14; - private static final int INTEGER_VAL_INDEX = 15; - private static final int CHAR_VAL_INDEX = 16; - - // The following variables are Method arrays. Each array refers to a specific get<Type>, but within - // the array exist the get<Type>(index), get<Type>(property), and get<Type>(path). Rather than - // referring to each of the three in every circumstance, the more compact array appears. - private static ConversionType TO_BOOLEAN = new ConversionType("Boolean", boolean.class ); - private static ConversionType TO_BYTE = new ConversionType("Byte", byte.class ); - private static ConversionType TO_CHAR = new ConversionType("Char", char.class ); - private static ConversionType TO_DOUBLE = new ConversionType("Double", double.class ); - private static ConversionType TO_FLOAT = new ConversionType("Float", float.class ); - private static ConversionType TO_INT = new ConversionType("Int", int.class ); - private static ConversionType TO_LONG = new ConversionType("Long", long.class ); - private static ConversionType TO_SHORT = new ConversionType("Short", short.class ); - private static ConversionType TO_BYTES = new ConversionType("Bytes", byte[].class ); - private static ConversionType TO_BIGDECIMAL = new ConversionType("BigDecimal", java.math.BigDecimal.class ); - private static ConversionType TO_BIGINTEGER = new ConversionType("BigInteger", java.math.BigInteger.class ); - private static ConversionType TO_DATAOBJECT = new ConversionType("DataObject", commonj.sdo.DataObject.class ); - private static ConversionType TO_DATE = new ConversionType("Date", java.util.Date.class ); - private static ConversionType TO_STRING = new ConversionType("String", java.lang.String.class ); - private static ConversionType TO_LIST = new ConversionType("List", java.util.List.class ); - // There is no setXXXX methods for sequence... - private static ConversionType TO_SEQUENCE = new ConversionType("Sequence", null ); - - 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[] GET_INT_CLASS_ARRAY = {int.class}; - private static final Class[] GET_PROPERTY_CLASS_ARRAY = {Property.class}; - private static final Class[] GET_STRING_CLASS_ARRAY = {String.class}; - private static final Class[] SET_INT_CLASS_ARRAY = {int.class, Class.class}; - private static final Class[] SET_PROPERTY_CLASS_ARRAY = {Property.class, Class.class}; - private static final Class[] SET_STRING_CLASS_ARRAY = {String.class, Class.class}; - - Method get_index_method; - Method get_property_method; - Method get_path_method; - Method set_index_method; - Method set_property_method; - Method set_path_method; - - public ConversionType (String method_name, Class type ) - { - try - { - this.get_index_method = DataObject.class.getMethod("get"+method_name, GET_INT_CLASS_ARRAY); - this.get_property_method = DataObject.class.getMethod("get"+method_name, GET_PROPERTY_CLASS_ARRAY); - this.get_path_method = DataObject.class.getMethod("get"+method_name, GET_STRING_CLASS_ARRAY); - if( type != null ) - { - SET_INT_CLASS_ARRAY[1] = type; - this.set_index_method = DataObject.class.getMethod("set"+method_name, SET_INT_CLASS_ARRAY); - SET_PROPERTY_CLASS_ARRAY[1] = type; - this.set_property_method = DataObject.class.getMethod("set"+method_name, SET_PROPERTY_CLASS_ARRAY); - SET_STRING_CLASS_ARRAY[1] = type; - this.set_path_method = DataObject.class.getMethod("set"+method_name, SET_STRING_CLASS_ARRAY); - } - else - { - this.set_index_method = null; - this.set_property_method = null; - this.set_path_method = null; - } - } - catch (NoSuchMethodException e) - { - this.get_index_method = null; - this.get_property_method = null; - this.get_path_method = null; - this.set_index_method = null; - this.set_property_method = null; - this.set_path_method = null; - } - } - - public Method getIndexGetMethod() - { - return this.get_index_method; - } - - public Method getPropertyGetMethod() - { - return this.get_property_method; - } - - public Method getPathGetMethod() - { - return this.get_path_method; - } - public Method getIndexSetMethod() - { - return this.set_index_method; - } - - public Method getPropertySetMethod() - { - return this.set_property_method; - } - - public Method getPathSetMethod() - { - return this.set_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[] get_index_parm; - Object[] get_property_parm; - Object[] get_path_parm; - Object[] set_index_parm; - Object[] set_property_parm; - Object[] set_path_parm; - Object expected_value; - String from_type; - Class from_type_class; - - // 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.get_index_parm = new Object[] {new Integer(index)}; - this.get_property_parm = new Object[] {API_TEST_TYPE.getProperty(path)}; - this.get_path_parm = new Object[] {path}; - this.set_index_parm = new Object[] {new Integer(index), null}; - this.set_property_parm = new Object[] {API_TEST_TYPE.getProperty(path), null}; - this.set_path_parm = new Object[] {path, null}; - 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 - { - this.expected_value = initial_value; - this.from_type = type_name; - this.from_type_class = type; - - setDefaultValue(); - } - - private void setDefaultValue() throws Exception - { - Class[] classArray = {int.class, from_type_class}; - Object[] initValueArray = new Object[] {this.get_index_parm[0], expected_value}; - Method setter = DataObject.class.getMethod("set" + from_type, classArray); - setter.invoke(test_obj, initValueArray); - } - - // 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.getIndexGetMethod(), this.get_index_parm, to_type.getIndexSetMethod(), this.set_index_parm); - performConversion(to_type.getPathGetMethod(), this.get_path_parm, to_type.getPathSetMethod(), this.set_path_parm ); - performConversion(to_type.getPropertyGetMethod(), this.get_property_parm, to_type.getPropertySetMethod(), this.set_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.getIndexGetMethod(), this.get_index_parm, expected_exception); - path_err = executeExceptionCase(to_type.getPathGetMethod(), this.get_path_parm, expected_exception); - property_err = executeExceptionCase(to_type.getPropertyGetMethod(), this.get_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.getPathGetMethod().getName() + " when called " - + "for a " + this.from_type + " property.", consistency_err); - } - - private void performConversion (Method getMeth, Object[] getParm, Method setMeth, Object[] setParm ) throws Exception - { - // First use the set - try - { - // get the set value - setParm[1] = getMeth.invoke(test_obj, getParm);; - // now set it... - setMeth.invoke(test_obj, setParm); - } - catch (Exception e) - { - Throwable cause = e.getCause(); - if (cause == null) - { - System.err.println("An exception of type " + e.getClass() + " occurred while performing " + setMeth.getName() - + " on a " + this.from_type + " property."); - } - else - { - System.err.println("An exception of type " + cause.getClass() + " occurred while performing " + setMeth.getName() - + " on a " + this.from_type + " property."); - } - - throw e; - } - - try - { - - assertTrue("Conversion did not yield expected value for get" + getMeth.getName() + " on a " + this.from_type + " property.", - COMPARE_ANY.compare(getMeth.invoke(test_obj, getParm), 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 " + getMeth.getName() - + " on a " + this.from_type + " property."); - } - else - { - System.err.println("An exception of type " + cause.getClass() + " occurred while performing " + getMeth.getName() - + " on a " + this.from_type + " property."); - } - - throw e; - } - - // reset to default - setDefaultValue(); - } - - - - 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() == byte[].class && obj2.getClass() == String.class) || - (obj2.getClass() == byte[].class && obj1.getClass() == String.class) ) - { - String strVal; - byte [] byteVal; - - if( obj1.getClass() == String.class ) - { - strVal = (String)obj1; - byteVal = (byte [])obj2; - } - else - { - strVal = (String)obj2; - byteVal = (byte [])obj1; - } - - if( strVal.length()/2 != byteVal.length ) - return -1; - - for( int i=0; i<byteVal.length; i++ ) - { - if( byteVal[i] != (Byte.decode("0x"+strVal.substring(i*2,(i*2)+2))).byteValue() ) - return -1; - } - - return 0; - } - - 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); - - FromString.initialize(String.class, "String", "0A64"); - FromString.attemptConversion(TO_BYTES); - } - - 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); - FromBytes.attemptConversion(TO_STRING); - } - - 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); - } - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java deleted file mode 100644 index 60a484290f..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java deleted file mode 100644 index f718a3f330..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java deleted file mode 100644 index 1cf59757ef..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java deleted file mode 100644 index 7ec3cd48bb..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java +++ /dev/null @@ -1,314 +0,0 @@ -/** - * - * 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.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; -import commonj.sdo.impl.HelperProvider; - -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+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" +LINE_BREAK+ -MARGIN+ "<cs:stockQuote xmlns:cs=\"http://www.example.com/simpleCS\">" +LINE_BREAK+ -MARGIN+INDENT+ "<symbol>FBNT</symbol>" +LINE_BREAK+ -MARGIN+INDENT+ "<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+ -MARGIN+INDENT+ "<price>999.0</price>" +LINE_BREAK+ -MARGIN+INDENT+ "<volume>1000.0</volume>" +LINE_BREAK+ -MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<price>1500.0</price>" +LINE_BREAK+ -MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ -MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<price>2500.0</price>" +LINE_BREAK+ -MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ -MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<price>3000.0</price>" +LINE_BREAK+ -MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ -MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<price>4000.0</price>" +LINE_BREAK+ -MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ -MARGIN+INDENT+ "<changes create=\"#//quotes[3] #//quotes[4]\" delete=\"#//changes/stockQuote[1]/quotes[2]\" logging=\"false\" xmlns:sdo=\"commonj.sdo\">" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<cs:stockQuote sdo:ref=\"#/stockQuote\" sdo:unset=\"volume\">" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<symbol>fbnt</symbol>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<price>1000.0</price>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[1]\" />" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[2]\" />" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "</cs:stockQuote>" +LINE_BREAK+ -MARGIN+INDENT+ "</changes>" +LINE_BREAK+ -MARGIN+ "</cs:stockQuote>"); - } - - public void notestSaveMixedOutputStreamObject() throws IOException { - format("/mixedChangeSummary.xml", -MARGIN+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" +LINE_BREAK+ -MARGIN+ "<cs:stockQuote xmlns:cs=\"http://www.example.com/sequenceCS\"><changes create=\"#//quotes[3] #//quotes[4]\" delete=\"#//changes/stockQuote[1]/quotes[2]\" logging=\"false\" xmlns:sdo=\"commonj.sdo\">" +LINE_BREAK+ -INDENT+ "<cs:stockQuote sdo:ref=\"#/stockQuote\">" +LINE_BREAK+ -INDENT+INDENT+ "<symbol>fbnt</symbol>" +LINE_BREAK+ -INDENT+INDENT+ "<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+ -INDENT+INDENT+ "<price>1000.0</price>" +LINE_BREAK+ -INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[1]\" />" +LINE_BREAK+ -INDENT+INDENT+ "<quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes>" +LINE_BREAK+ -INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[2]\" />" +LINE_BREAK+ -INDENT+ "</cs:stockQuote>" +LINE_BREAK+ -"</changes><symbol>FBNT</symbol><companyName>FlyByNightTechnology</companyName><price>999.0</price><quotes><price>1500.0</price></quotes><quotes><price>2500.0</price></quotes><volume>1000.0</volume><quotes><price>3000.0</price></quotes><quotes><price>4000.0</price></quotes></cs:stockQuote>"); - } - - public void notestOpenMixedOutputStreamObject() throws IOException { - format("/openChangeSummary.xml", -MARGIN+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" +LINE_BREAK+ -MARGIN+ "<cs:openQuote xmlns:cs=\"http://www.example.com/sequenceCS\" xmlns:open=\"http://www.example.com/open\">" +LINE_BREAK+ -MARGIN+INDENT+ "<symbol>FBNT</symbol>" +LINE_BREAK+ -MARGIN+INDENT+ "<open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<symbol>1500.0</symbol>" +LINE_BREAK+ -MARGIN+INDENT+ "</open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+ "<open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<symbol>2500.0</symbol>" +LINE_BREAK+ -MARGIN+INDENT+ "</open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+ "<open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<symbol>3000.0</symbol>" +LINE_BREAK+ -MARGIN+INDENT+ "</open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+ "<open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<symbol>4000.0</symbol>" +LINE_BREAK+ -MARGIN+INDENT+ "</open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+ "<changes create=\"#//open:openStockQuote[3] #//open:openStockQuote[4]\" delete=\"#//changes/openQuote[1]/open:openStockQuote[2]\" logging=\"false\" xmlns:sdo=\"commonj.sdo\">" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "<cs:openQuote sdo:ref=\"#/openQuote\">" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<symbol>fbnt</symbol>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<open:openStockQuote sdo:ref=\"#//open:openStockQuote[1]\" />" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<open:openStockQuote><symbol>2000.0</symbol><open:openStockQuote><symbol>2000.99</symbol></open:openStockQuote></open:openStockQuote>" +LINE_BREAK+ -MARGIN+INDENT+INDENT+INDENT+ "<open:openStockQuote sdo:ref=\"#//open:openStockQuote[2]\" />" +LINE_BREAK+ -MARGIN+INDENT+INDENT+ "</cs:openQuote>" +LINE_BREAK+ -MARGIN+INDENT+ "</changes>" +LINE_BREAK+ -MARGIN+ "</cs:openQuote>"); - } - - private String quoteXML = - "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + - "<simple:stockQuote xmlns:simple=\"http://www.example.com/simple\">" + - "<symbol>fbnt</symbol>" + - "<companyName>FlyByNightTechnology</companyName>" + - "<price>1000.0</price>" + - "<open1>1000.0</open1>" + - "<high>1000.0</high>" + - "<low>1000.0</low>" + - "<volume>1000.0</volume>" + - "<change1>1000.0</change1>" + - "<quotes>" + - "<price>2000.0</price>" + - "</quotes>" + - "</simple:stockQuote>"; - - 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 = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + - "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + - "xmlns:simple=\"http://www.example.com/simple\" " + - "targetNamespace=\"http://www.example.com/simple\">" + -// "<xsd:element name=\"stockQuote\" type=\"simple:Quote\"/>" + - "<xsd:complexType name=\"Quote\">" + - "<xsd:sequence>" + - "<xsd:element name=\"symbol\" type=\"xsd:string\"/>" + - "</xsd:sequence>" + - "</xsd:complexType>" + - "</xsd:schema>"; - - /** - * 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()); - } - } - - public void testEncoding() throws IOException - { - TypeHelper types = hc.getTypeHelper(); - Type stringType = types.getType("commonj.sdo", "String"); - DataObject customerType = hc.getDataFactory().create("commonj.sdo", "Type"); - customerType.set("uri", "http://example.com/simple"); - customerType.set("name", "Simple"); - DataObject multiProperty = customerType.createDataObject("property"); - multiProperty.set("name", "name"); - multiProperty.set("type", stringType); - types.define(customerType); - DataObject obj = hc.getDataFactory().create("http://example.com/simple", - "Simple"); - obj.set("name", "John Smith"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - hc.getXMLHelper().save(obj, "http://www.example.com/company" , "company", baos); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toString().getBytes()); - XMLDocument xmlDoc = hc.getXMLHelper().load(bais); - if( !"UTF-8".equals(xmlDoc.getEncoding()) ) - { - fail("Encoding ('" + xmlDoc.getEncoding() +"' is not correct. UTF-8 is the expected encoding."); - } - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java deleted file mode 100644 index d58b070a90..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * - * 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( - "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+ - "<element name=\"root\">"+ - "<complexType>"+ - "<sequence>"+ - "<element name=\"unqualifiedElement\" type=\"string\"/>"+ - "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+ - "</sequence>"+ - "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+ - "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+ - "</complexType>"+ - "</element>"+ - "</schema>"); - - final String xml="<p:root xmlns:p=\"testNS\">"+ - "<p:unqualifiedElement/>"+ -"</p:root>"; - - /* - * 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( - "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+ - "<element name=\"root\">"+ - "<complexType>"+ - "<sequence>"+ - "<element name=\"unqualifiedElement\" type=\"string\"/>"+ - "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+ - "</sequence>"+ - "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+ - "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+ - "</complexType>"+ - "</element>"+ - "</schema>"); - - final String xml="<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\" qualifiedAttribute=\"q\">"+ - "<p:unqualifiedElement/>"+ - "<qualifiedElement/>"+ - "</p:root>"; - - /* - * 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( - "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+ - "<element name=\"root\">"+ - "<complexType>"+ - "<sequence>"+ - "<element name=\"unqualifiedElement\" type=\"string\"/>"+ - "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+ - "</sequence>"+ - "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+ - "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+ - "</complexType>"+ - "</element>"+ - "</schema>"); - - final String xml="<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\" qualifiedAttribute=\"q\">"+ - "<p:unqualifiedElement/>"+ - "<qualifiedElement/>"+ - "</p:root>"; - - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java deleted file mode 100644 index 27b750b0ff..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * - * 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+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +LINE_BREAK+ - MARGIN+ "<cs:stockQuote xmlns:cs=\"http://www.example.com/simpleCS\">" +LINE_BREAK+ - MARGIN+INDENT+ "<symbol>FBNT</symbol>" +LINE_BREAK+ - MARGIN+INDENT+ "<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+ - MARGIN+INDENT+ "<price>999.0</price>" +LINE_BREAK+ - MARGIN+INDENT+ "<volume>1000.0</volume>" +LINE_BREAK+ - MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ - MARGIN+INDENT+INDENT+ "<price>1500.0</price>" +LINE_BREAK+ - MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ - MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ - MARGIN+INDENT+INDENT+ "<price>2500.0</price>" +LINE_BREAK+ - MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ - MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ - MARGIN+INDENT+INDENT+ "<price>3000.0</price>" +LINE_BREAK+ - MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ - MARGIN+INDENT+ "<quotes>" +LINE_BREAK+ - MARGIN+INDENT+INDENT+ "<price>4000.0</price>" +LINE_BREAK+ - MARGIN+INDENT+ "</quotes>" +LINE_BREAK+ - MARGIN+INDENT+ "<changes create=\"#//quotes[3] #//quotes[4]\" delete=\"#//changes/stockQuote[1]/quotes[2]\" logging=\"false\" xmlns:sdo=\"commonj.sdo\">" +LINE_BREAK+ - MARGIN+INDENT+INDENT+ "<cs:stockQuote sdo:ref=\"#/stockQuote\" sdo:unset=\"volume\">" +LINE_BREAK+ - MARGIN+INDENT+INDENT+INDENT+ "<symbol>fbnt</symbol>" +LINE_BREAK+ - MARGIN+INDENT+INDENT+INDENT+ "<price>1000.0</price>" +LINE_BREAK+ - MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[1]\" />" +LINE_BREAK+ - MARGIN+INDENT+INDENT+INDENT+ "<quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes>" +LINE_BREAK+ - MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[2]\" />" +LINE_BREAK+ - MARGIN+INDENT+INDENT+ "</cs:stockQuote>" +LINE_BREAK+ - MARGIN+INDENT+ "</changes>" +LINE_BREAK+ - MARGIN+ "</cs:stockQuote>"; - - String formatted2 = - //MARGIN+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" +LINE_BREAK+ - MARGIN+ "<p0:stockQuote xmlns:p0=\"http://www.example.com/simple\">" +LINE_BREAK+ - MARGIN+INDENT+"<symbol>fbnt</symbol>" +LINE_BREAK+ - MARGIN+INDENT+"<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+ - MARGIN+INDENT+"<price>1000.0</price>" +LINE_BREAK+ - MARGIN+INDENT+"<open1>1000.0</open1>" +LINE_BREAK+ - MARGIN+INDENT+"<high>1000.0</high>" +LINE_BREAK+ - MARGIN+INDENT+"<low>1000.0</low>" +LINE_BREAK+ - MARGIN+INDENT+"<volume>1000.0</volume>" +LINE_BREAK+ - MARGIN+INDENT+"<change1>1000.0</change1>" +LINE_BREAK+ - MARGIN+"</p0:stockQuote>" +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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java deleted file mode 100644 index ef701059c4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * - * 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("<p0:stockQuote xmlns:p0=\"http://www.example.com/simple\" xmlns:p1=\"http://www.example.com/simple3\"><p0:symbol>fbnt</p0:symbol><p0:companyName>FlyByNightTechnology</p0:companyName><p0:price>1000.0</p0:price><p0:open1>1000.0</p0:open1><p0:high>1000.0</p0:high><p0:low>1000.0</p0:low><p0:volume>1000.0</p0:volume><p0:change1>1000.0</p0:change1><p0:quotes><p0:price>2000.0</p0:price></p0:quotes><p0:quotes3><p1:symbol3>IBM</p1:symbol3><p1:company3>IBM Corp.</p1:company3></p0:quotes3></p0:stockQuote>",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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java deleted file mode 100644 index d63d63b5fb..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * - * 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.InputStreamReader; -import java.io.StringReader; -import java.io.StringWriter; -import java.net.URL; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -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.SDOUtil; -import org.apache.tuscany.sdo.api.XMLStreamHelper; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; - -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; - - // = "<module name=\"m\" xmlns=\"http://foo\" xmlns:bar=\"http://bar\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" - // xsi:schemaLocation=\"http://bar foo-ext.xsd http://foo foo.xsd \"><component name=\"c\"><bar:implementation.mock - // myAttr=\"helloworld.HelloWorldImpl\" listAttr=\"1 2\">1<bar:myElement>Dummy</bar:myElement>2</bar:implementation.mock></component></module>"; - - 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("<symbol>fbnt</symbol>") != -1); - } - - // Test case for TUSCANY-1788 - public void testXSIType() throws Exception { - URL ipo = getClass().getResource("/ipo.xsd"); - hc.getXSDHelper().define(ipo.openStream(), ipo.toString()); - DataObject d = hc.getDataFactory().create("http://www.example.com/IPO", "PurchaseOrderType"); - DataObject billTo = hc.getDataFactory().create("http://www.example.com/IPO", "USAddress"); - billTo.setString("city", "San Jose"); - billTo.setString("state", "CA"); - d.setDataObject("billTo", billTo); - XMLDocument ipoDoc = hc.getXMLHelper().createDocument(d, "http://www.example.com/IPO", "purchaseOrder"); - final StringWriter writer = new StringWriter(); - final XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(writer); - streamHelper.save(ipoDoc, xmlWriter, null); - xmlWriter.close(); - String xml = writer.toString(); - assertTrue(xml.indexOf("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"") != -1); - assertTrue(xml.indexOf("xsi:type") != -1); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java deleted file mode 100644 index 8824ae7f13..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * - * 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("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">" + "<element name=\"root\">" - + "<complexType>" - + "<sequence>" - + "<element name=\"unqualifiedElement\" type=\"string\"/>" - + "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>" - + "</sequence>" - + "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>" - + "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>" - + "</complexType>" - + "</element>" - + "</schema>"); - - final String xml = - "<p:root xmlns:p=\"testNS\">" + "<unqualifiedElement/>" - + "<telem>my test data0</telem>" - + "<zap>my test data1</zap>" - + "</p:root>"; - - 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("<telem>my test data0</telem>") != -1); - assertTrue(baos.toString().indexOf("<zap>my test data1</zap>") != -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("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">" + "<element name=\"root\">" - + "<complexType>" - + "<sequence>" - + "<element name=\"unqualifiedElement\" type=\"string\"/>" - + "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>" - + "</sequence>" - + "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>" - + "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>" - + "</complexType>" - + "</element>" - + "</schema>"); - - final String xml = - "<p:root xmlns:p=\"testNS\">" + "<unqualifiedElement/>" - + "<telem>my test data</telem>" - + "<telem1>my test data</telem1>" - + "</p:root>"; - - 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java deleted file mode 100644 index 45f92a73b2..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java deleted file mode 100644 index b8d3402172..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java deleted file mode 100644 index f369b340ed..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * - * 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 = - "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " + - "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + - "xmlns:simple=\"http://www.example.com/simple\"> " + - "<xsd:element name=\"stockQuote\" type=\"simple:Quote\"/> " + - "<xsd:complexType name=\"Quote\"> " + - "<xsd:sequence> " + - "<xsd:element name=\"symbol\" type=\"xsd:string\"/> " + - "<xsd:element name=\"policy\" type=\"xsd:QName\"/> " + - "</xsd:sequence> " + - "</xsd:complexType> " + - "</xsd:schema>"; - - private final String xmlString = - "<?xml version=\"1.0\" encoding=\"ASCII\"?> " + - "<simple:stockQuote xmlns:simple=\"http://www.example.com/simple\"> " + - "<symbol>fbnt</symbol> " + - "<policy>simple:stockQuote</policy> " + - "</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 <prefix>: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("<policy>"); - int end = str.indexOf("</policy>"); - assertTrue(start != -1 && end != -1); - - String policyValue = str.substring(start + "<policy>".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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/ClassLoaderTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/ClassLoaderTestCase.java deleted file mode 100644 index 8fbd74ac0d..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/ClassLoaderTestCase.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * - * 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.osgi; - - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.HashSet; - -import org.apache.tuscany.sdo.test.AllTests; -import commonj.sdo.impl.HelperProvider; - -import junit.framework.Assert; -import junit.framework.TestCase; -import junit.framework.TestResult; -import junit.framework.TestSuite; - -/* - * This test runs the SDO implementation test suite in a multi-classloader environment - */ -public class ClassLoaderTestCase extends TestCase { - - private ClassLoader contextClassLoader; - - protected void setUp() throws Exception { - - contextClassLoader = Thread.currentThread().getContextClassLoader(); - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - Thread.currentThread().setContextClassLoader(contextClassLoader); - } - - // Load the test class using a separate test classloader which - // loads SDO API, LIB and IMPL using different classloaders - // Run the SDO test suite under this multi-classloader environment - // Third party libraries and test classes/resources are available - // on the thread context classloader when this test is run - public void test() throws Exception { - ClassLoader testClassLoader = createTestClassLoader(); - - Class testClass = testClassLoader.loadClass(this.getClass().getName()); - Method testMethod = testClass.getMethod("runSDOTest", null); - Object testObj = testClass.newInstance(); - testMethod.invoke(testObj, null); - - - } - - - public void runSDOTest() throws Exception { - - HelperProvider.setDefaultInstance(this.getClass().getClassLoader()); - - TestSuite allTests = AllTests.suite(); - TestResult testResult = new TestResult(); - allTests.run(testResult); - Assert.assertEquals(0, testResult.errorCount()); - } - - - // Get all the URLs for a classloader, remove these from dependentJars - private URL[] getClassLoaderURLs( - URL[] classPathEntries, - HashSet dependentJars, - String[] jarList) - throws IOException { - - String pathSeparator = "/"; - HashSet classPathEntrySet; - - classPathEntrySet = new HashSet(); - - for (int i = 0; i < classPathEntries.length; i++) { - - URL classPathEntry = classPathEntries[i]; - String classPathEntryStr = classPathEntry.getPath(); - if (jarList != null) { - for (int k = 0; k < jarList.length; k++) { - String jarName = "tuscany-" + jarList[k]; - String alternateJarName = "tuscany-sdo-" + jarList[k]; - String folderName = pathSeparator + jarList[k] + pathSeparator; - if (classPathEntryStr.indexOf(jarName) >= 0 || - classPathEntryStr.indexOf(alternateJarName) >=0 || - classPathEntryStr.indexOf(folderName) >=0) { - - classPathEntrySet.add(classPathEntry); - dependentJars.remove(classPathEntry); - } - } - } - } - return (URL [])classPathEntrySet.toArray(new URL[classPathEntrySet.size()]); - } - - - // Create the test classloader. It uses separate classloaders to load SDO API, SDO LIB, - // SDO IMPL and 3rd part libraries - private ClassLoader createTestClassLoader() throws Exception { - - String[] sdoApiJars = {"sdo-api"}; - String[] sdoLibJars = {"lib"}; - String[] sdoImplJars = {"impl"}; - - URL[] sdoApiUrls; - URL[] sdoLibUrls; - URL[] sdoImplUrls; - URL[] dependencyUrls; - - if (!(this.getClass().getClassLoader() instanceof URLClassLoader)) - return this.getClass().getClassLoader(); - - HashSet dependentJars = new HashSet(); - URL[] classPathEntries = ((URLClassLoader)this.getClass().getClassLoader()).getURLs(); - for (int i = 0; i < classPathEntries.length; i++) { - dependentJars.add(classPathEntries[i]); - } - sdoApiUrls = getClassLoaderURLs(classPathEntries, dependentJars, sdoApiJars); - sdoLibUrls = getClassLoaderURLs(classPathEntries, dependentJars, sdoLibJars); - sdoImplUrls = getClassLoaderURLs(classPathEntries, dependentJars, sdoImplJars); - dependencyUrls = (URL [])dependentJars.toArray(new URL[dependentJars.size()]); - - ClassLoader dependencyLoader = new URLClassLoader(dependencyUrls, null); - ClassLoader sdoApiLoader = new URLClassLoader(sdoApiUrls, dependencyLoader); - ClassLoader sdoLibClassLoader = new URLClassLoader(sdoLibUrls, sdoApiLoader); - ClassLoader sdoImplClassLoader = new URLClassLoader(sdoImplUrls, sdoLibClassLoader); - - - TestClassLoader testClassLoader = new TestClassLoader( - new ClassLoader[] {sdoApiLoader, sdoLibClassLoader, sdoImplClassLoader, dependencyLoader} - ); - - - // Test classes and 3rd party libraries should be on the context classloader - URL testUrl = new File("./target/test-classes").toURL(); - ClassLoader contextClassLoader = new URLClassLoader(new URL[]{testUrl}, dependencyLoader); - Thread.currentThread().setContextClassLoader(contextClassLoader); - - return testClassLoader; - } - - - - private class TestClassLoader extends ClassLoader { - - ClassLoader[] parentLoaders; - - private TestClassLoader(ClassLoader[] parentLoaders) { - this.parentLoaders = parentLoaders; - } - - public Class loadClass(String className) throws ClassNotFoundException { - - Class clazz = findLoadedClass(className); - if (clazz != null) - return clazz; - - for (int i = 0; i < parentLoaders.length; i++) { - try { - return parentLoaders[i].loadClass(className); - } catch (Exception e) { - // speculative load using parent class loader failed, but that's OK - } - } - return super.loadClass(className); - } - - - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/OSGiTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/OSGiTestCase.java deleted file mode 100644 index 5a67fc41c5..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/OSGiTestCase.java +++ /dev/null @@ -1,354 +0,0 @@ -/** - * - * 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.osgi; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FilenameFilter; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; - -import org.apache.felix.framework.Felix; -import org.apache.felix.main.Main; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -import junit.framework.TestCase; - -/* - * This test runs the SDO implementation test suite under a Felix OSGi runtime - */ -public class OSGiTestCase extends TestCase { - - private Felix felix; - private BundleContext bundleContext; - private ClassLoader contextClassLoader; - - protected void setUp() throws Exception { - - contextClassLoader = Thread.currentThread().getContextClassLoader(); - - super.setUp(); - - // Start a Felix OSGi runtime - File profileDir = new File(".felix"); - if (profileDir.isDirectory()) - deleteDirectory(profileDir); - else - profileDir.delete(); - profileDir.mkdir(); - - Properties props = Main.loadConfigProperties(); - props.put("felix.cache.profiledir", profileDir.getAbsolutePath()); - props.put("felix.embedded.execution", "true"); - props.put("org.osgi.framework.system.packages", - "org.osgi.framework; version=1.3.0," - + "org.osgi.service.packageadmin; version=1.2.0, " - + "org.osgi.service.startlevel; version=1.0.0, " - + "org.osgi.service.url; version=1.0.0, " + "javax.xml, " - + "javax.xml.parsers, " + "javax.xml.namespace, " - + "org.xml.sax, " + "org.xml.sax.helpers, " + "org.xml.sax.ext, " - + "org.w3c.dom, " + "org.w3c.dom.events, " + "javax.xml.stream, " - + "javax.xml.transform, " + "javax.xml.transform.dom, " - + "javax.xml.transform.stream, " + "org.objectweb.asm, " - + "junit.framework"); - - List activators = new ArrayList(); - Felix felix = new Felix(props, activators); - felix.start(); - bundleContext = felix.getBundleContext(); - } - - protected void tearDown() throws Exception { - - super.tearDown(); - Thread.currentThread().setContextClassLoader(contextClassLoader); - - if (felix != null) { - felix.stop(); - felix = null; - } - } - - // Install SDO spec, SDO lib, SDO impl, and its EMF dependencies - // Create a test bundle containing all the SDO tests, and run the entire - // test suite inside an OSGi container - public void test() throws Exception { - - ArrayList bundles = new ArrayList(); - FilenameFilter jarFileFilter = new JarFileFilter(); - - File apiDir = new File("../sdo-api/target"); - File[] apiJars = apiDir.listFiles(jarFileFilter); - for (int i = 0; i < apiJars.length; i++) { - Bundle bundle = bundleContext - .installBundle(apiJars[i].toURL().toString()); - bundles.add(bundle); - } - - File libDir = new File("../lib/target"); - File[] libJars = libDir.listFiles(jarFileFilter); - for (int i = 0; i < libJars.length; i++) { - Bundle bundle = bundleContext - .installBundle(libJars[i].toURL().toString()); - bundles.add(bundle); - } - - if (!(contextClassLoader instanceof URLClassLoader)) - return; - - URL[] classPathURLs = ((URLClassLoader) contextClassLoader).getURLs(); - for (int i = 0; i < classPathURLs.length; i++) { - String url = classPathURLs[i].toString(); - if (url.indexOf("eclipse") > 0 && url.endsWith(".jar")) { - Bundle bundle = installEclipseBundle(classPathURLs[i]); - if (bundle != null) - bundles.add(bundle); - } - } - - // When this test is run during the build, sdo.impl.jar would not yet have - // been created - // Create this bundle - use the manifest file provided in the test - // directory, which works - // with Felix. - Bundle implBundle = installBundle("file:sdo.impl", - "../impl/target/test-classes/osgi/sdo.impl.mf", - new String[] { "../impl/target/classes" }); - bundles.add(implBundle); - - // Start all the installed bundles - for (int i = 0; i < bundles.size(); i++) { - Bundle bundle = (Bundle) bundles.get(i); - try { - bundle.start(); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("Could not start bundle " + bundle); - // don't stop on first failure, so we document all failures - // any failure will be re-triggered by the testBundle.start() call below - } - } - - // Install the test bundle - it contains all the test classes. The bundle - // activator for - // this class runs the entire test suite - Bundle testBundle = installBundle("file:sdo.osgi.test", - "../impl/target/test-classes/osgi/sdo.osgi.test.mf", - new String[] { "../impl/target/test-classes" }); - - TestClassLoader testClassLoader = new TestClassLoader(testBundle, - contextClassLoader); - Thread.currentThread().setContextClassLoader(testClassLoader); - - // The test suite is run inside an OSGi container by this call. - testBundle.start(); - } - - // Delete any old Felix configuration files left over from previous runs - private static void deleteDirectory(File dir) { - - File[] files = dir.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory()) - deleteDirectory(files[i]); - else - files[i].delete(); - } - dir.delete(); - - } - - // Create and install a bundle with the specified manifest file - // The bundle contains all files from the list of directories specified - public Bundle installBundle(String bundleLocation, String manifestFileName, - String[] dirNames) throws Exception { - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - File manifestFile = new File(manifestFileName); - Manifest manifest = new Manifest(); - manifest.read(new FileInputStream(manifestFile)); - - JarOutputStream jarOut = new JarOutputStream(out, manifest); - - for (int i = 0; i < dirNames.length; i++) { - File dir = new File(dirNames[i]); - addFilesToJar(dir, dirNames[i], jarOut); - } - - jarOut.close(); - out.close(); - - ByteArrayInputStream inStream = new ByteArrayInputStream(out.toByteArray()); - return bundleContext.installBundle(bundleLocation, inStream); - - } - - // Add all the files from a build directory into a jar file - // This method is used to create bundles on the fly - private void addFilesToJar(File dir, String rootDirName, - JarOutputStream jarOut) throws Exception { - - if (dir.getName().equals(".svn")) - return; - - File[] files = dir.listFiles(); - - for (int i = 0; i < files.length; i++) { - - if (files[i].isDirectory()) { - addFilesToJar(files[i], rootDirName, jarOut); - continue; - } - if (files[i].getName().endsWith("MANIFEST.MF")) - continue; - - String entryName = files[i].getPath().substring(rootDirName.length() + 1); - entryName = entryName.replaceAll("\\\\", "/"); - ZipEntry ze = new ZipEntry(entryName); - - jarOut.putNextEntry(ze); - FileInputStream file = new FileInputStream(files[i]); - byte[] fileContents = new byte[file.available()]; - file.read(fileContents); - jarOut.write(fileContents); - } - } - - // Install a bundle corresponding to an jar file from Eclipse (eg. EMF jars) - // These bundle manifest entries use Require-Bundle of - // eclipse core runtime. The Plugin class from the Eclipse runtime - // is loaded by the bundle activator of some of these bundles. - // Since this test is run under Felix, remove the dependency on - // Eclipse runtime by removing the Require-Bundle and - // Bundle-Activator entries from the manifest - private Bundle installEclipseBundle(URL jarURL) throws Exception { - - JarInputStream jarInput = new JarInputStream(jarURL.openStream()); - - Manifest manifest = jarInput.getManifest(); - if (manifest == null) { - manifest = new Manifest(); - ZipEntry entry; - while ((entry = jarInput.getNextEntry()) != null) { - if (entry.getName().equals("META-INF/MANIFEST.MF")) { - byte bytes[] = new byte[(int) entry.getSize()]; - jarInput.read(bytes); - manifest.read(new ByteArrayInputStream(bytes)); - } - } - jarInput.close(); - jarInput = new JarInputStream(jarURL.openStream()); - } - if (manifest == null - || manifest.getMainAttributes() == null - || !manifest.getMainAttributes().containsKey( - new Attributes.Name("Bundle-SymbolicName"))) { - - return null; - } - manifest.getMainAttributes().remove(new Attributes.Name("Require-Bundle")); - manifest.getMainAttributes() - .remove(new Attributes.Name("Bundle-Activator")); - manifest.getMainAttributes().put( - new Attributes.Name("DynamicImport-Package"), "*"); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - JarOutputStream jarOut = new JarOutputStream(out, manifest); - ZipEntry entry; - byte bytes[] = new byte[1024]; - while ((entry = jarInput.getNextEntry()) != null) { - if (!entry.getName().equals("META-INF/MANIFEST.MF")) { - jarOut.putNextEntry((JarEntry) entry); - int len; - while ((len = jarInput.read(bytes)) != -1) { - jarOut.write(bytes, 0, len); - } - jarOut.closeEntry(); - } - jarInput.closeEntry(); - } - jarOut.close(); - out.close(); - jarInput.close(); - - ByteArrayInputStream byteStream = new ByteArrayInputStream(out - .toByteArray()); - - return bundleContext.installBundle(jarURL.toString(), byteStream); - - } - - // Filter used to list jar files from a directory - private class JarFileFilter implements FilenameFilter { - - public boolean accept(File dir, String name) { - if (name.endsWith(".jar") && !name.endsWith("javadoc.jar")) - return true; - else - return false; - } - - } - - // Test classloader - used as context classloader - private static class TestClassLoader extends ClassLoader { - - Bundle testBundle; - - private TestClassLoader(Bundle testBundle, ClassLoader parentClassLoader) { - super(parentClassLoader); - this.testBundle = testBundle; - } - - public Class loadClass(String className) throws ClassNotFoundException { - Class clazz = findLoadedClass(className); - if (clazz != null) - return clazz; - - try { - return testBundle.loadClass(className); - } catch (Exception e) { - } - return super.loadClass(className); - } - - public URL getResource(String resName) { - URL resource = testBundle.getResource(resName); - if (resource == null) - resource = super.getResource(resName); - return resource; - } - - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/TestBundleActivator.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/TestBundleActivator.java deleted file mode 100644 index 4458a13959..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/test/osgi/TestBundleActivator.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.tuscany.sdo.test.osgi; -/** - * - * 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. - */ -import java.util.Enumeration; - -import junit.framework.Assert; -import junit.framework.Test; -import junit.framework.TestFailure; -import junit.framework.TestResult; - -import org.apache.tuscany.sdo.AllTests; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - - -/* - * Bundle activator for running the SDO test suite under OSGi - * The SDO test suite is run inside an OSGi container when the bundle is started. - */ -public class TestBundleActivator implements BundleActivator { - - public void start(BundleContext bundleContext) throws Exception { - runSDOTests(); - } - - public void stop(BundleContext bundleContext) throws Exception { - - } - - - public void runSDOTests() throws Exception { - - Test allTests = AllTests.suite(); - TestResult testResult = new TestResult(); - allTests.run(testResult); - System.out.println("Runs " + testResult.runCount() + ", Errors: " - + testResult.errorCount()); - - Enumeration e = testResult.errors(); - while (e.hasMoreElements()) { - TestFailure f = (TestFailure) e.nextElement(); - System.out.println(f); - System.out.println(f.exceptionMessage()); - } - - Assert.assertEquals(0, testResult.errorCount()); - - } -} diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/SchemaLocationTestCase.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/SchemaLocationTestCase.xml deleted file mode 100644 index e13f45a877..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/SchemaLocationTestCase.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<sl:purchaseReport - xmlns:sl="http://www.example.com/xmlDocumentSchemaLocation" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.example.com/xmlDocumentSchemaLocation - XMLDocumentSchemaLocation.xsd - http://www.example.com/open - open.xsd" - xsi:noNamespaceSchemaLocation="XMLDocumentNoNamespaceSchemaLocation.xsd" - periodEnding="2007-12-31"> - <sl:schemaLocationElement>some string</sl:schemaLocationElement> - <aNoNamespaceSchemaLocationElement date="2006-04-01"> - <anElement>another string</anElement> - </aNoNamespaceSchemaLocationElement> -</sl:purchaseReport> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/SequenceChangeSummary.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/SequenceChangeSummary.xsd deleted file mode 100644 index dd3c2bc2dc..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/SequenceChangeSummary.xsd +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Copyright (c) 2005-2006 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. - --> -<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:mixed="http://www.example.com/mixed" xmlns:open="http://www.example.com/open" targetNamespace="http://www.example.com/sequenceCS" xmlns:cs="http://www.example.com/sequenceCS"> - - <import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/> - - <import namespace="http://www.example.com/mixed" schemaLocation="mixed.xsd"/> - <import namespace="http://www.example.com/open" schemaLocation="open.xsd"/> - - <complexType name="RootQuote"> - <complexContent> - <extension base="mixed:MixedQuote"> - <sequence> - <element name="changes" type="sdo:ChangeSummaryType"/> - </sequence> - </extension> - </complexContent> - </complexType> - - <element name="stockQuote" type="cs:RootQuote"/> - - <element name="openQuote"> - <complexType> - <complexContent> - <extension base="open:OpenQuote"> - <sequence> - <element name="changes" type="sdo:ChangeSummaryType"/> - </sequence> - </extension> - </complexContent> - </complexType> - </element> - -</schema>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/SubstitutionValues.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/SubstitutionValues.xsd deleted file mode 100644 index e977e6e631..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/SubstitutionValues.xsd +++ /dev/null @@ -1,31 +0,0 @@ -<schema xmlns="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://www.apache.org/tuscany/SubstitutionValues" - xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues"> - <!-- - 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. - --> - <element name="testObject" type="sv:TestObject"/> - <element name="groupHead" type="string"/> - <complexType name="TestObject"> - <sequence> - <element ref="sv:groupHead"/> - <element name="nonGroupHead" type="string"/> - </sequence> - </complexType> - <element name="groupMember" type="string" substitutionGroup="sv:groupHead"/> -</schema>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/TypePropertyMetadataInfo.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/TypePropertyMetadataInfo.xsd deleted file mode 100644 index 7a78772733..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/TypePropertyMetadataInfo.xsd +++ /dev/null @@ -1,97 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<schema xmlns="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://www.example.com/metadata/retrievaltest" - xmlns:metadata="http://www.example.com/metadata/retrievaltest"> - -<annotation> - <appinfo source="http://www.example.com/metadata/annotation"> - <p1:annotationSet xmlns:p1="http://www.example.com/metadata/annotation" name="test"/> - </appinfo> -</annotation> - -<complexType name="Example"> - <annotation> - <appinfo source="http://www.example.com/metadata/annotation"> - <p1:example xmlns:p1="http://www.example.com/metadata/annotation"> - <p1:picture>forest.jpg</p1:picture> - </p1:example> - </appinfo> - </annotation> - - <sequence> - <element name="number" type="integer" minOccurs="0" maxOccurs="1"> - <annotation> - <appinfo source="http://www.example.com/metadata/annotation"> - <p1:AttributeTypeMetadata xmlns:p1="http://www.example.com/metadata/annotation"> - <p1:getter>getNumber</p1:getter> - <p1:setter>setNumber</p1:setter> - </p1:AttributeTypeMetadata> - </appinfo> - </annotation> - </element> - - <element name="Exampletype" type="string"> - <annotation> - <appinfo source="http://www.example.com/metadata/annotation"> - <p1:AttributeTypeMetadata xmlns:p1="http://www.example.com/metadata/annotation"> - <p1:getter>getPhonetype</p1:getter> - <p1:setter>setPhonetype</p1:setter> - </p1:AttributeTypeMetadata> - </appinfo> - </annotation> - </element> - </sequence> -</complexType> - -<simpleType name="ExampleNumber"> - <annotation> - <appinfo source="http://www.example.com/metadata/annotation"> - This is the metadata for defining the ExampleNumber type. - </appinfo> - </annotation> - <restriction base="integer"> - <minInclusive value="1"/> - <maxInclusive value="29035"/> - </restriction> -</simpleType> - -<simpleType name="PhoneNumber"> - <annotation> - <appinfo source="http://www.example.com/metadata/annotation"> - This is the metadata for defining the PhoneNumber type. - </appinfo> - </annotation> - <restriction base="string"> - <length value="8"/> - <pattern value="\d{3}-\d{4}"/> - <pattern value="\d{6}-\d{8}"/> - </restriction> -</simpleType> - -<simpleType name="ExampleRating"> - <restriction base="string"> - <enumeration value=""/> - <enumeration value="Good"/> - <enumeration value="Bad"/> - </restriction> -</simpleType> - -</schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd deleted file mode 100644 index c2beb7708d..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - - <xsd:element name="aNoNamespaceSchemaLocationElement"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="anElement" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="date" type="xsd:date"/> - </xsd:complexType> - </xsd:element> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentSchemaLocation.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentSchemaLocation.xsd deleted file mode 100644 index 0561eb555b..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentSchemaLocation.xsd +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://www.example.com/xmlDocumentSchemaLocation" - xmlns:sl="http://www.example.com/xmlDocumentSchemaLocation"> - - <xsd:element name="schemaLocationElement" type="xsd:string" /> - - <xsd:element name="purchaseReport"> - <xsd:complexType> - <xsd:sequence> - <xsd:any minOccurs="1" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="periodEnding" type="xsd:date"/> - </xsd:complexType> - </xsd:element> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentTestCase.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentTestCase.xml deleted file mode 100644 index de22090908..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLDocumentTestCase.xml +++ /dev/null @@ -1,32 +0,0 @@ -<!-- - * 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. ---> -<sl:purchaseReport - xmlns:sl="http://www.example.com/xmlDocumentSchemaLocation" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.example.com/xmlDocumentSchemaLocation - /XMLDocumentSchemaLocation.xsd - http://www.example.com/open - /open.xsd" - xsi:noNamespaceSchemaLocation="/XMLDocumentNoNamespaceSchemaLocation.xsd" - periodEnding="2007-12-31"> - <sl:schemaLocationElement>some string</sl:schemaLocationElement> - <aNoNamespaceSchemaLocationElement date="2006-04-01"> - <anElement>another string</anElement> - </aNoNamespaceSchemaLocationElement> -</sl:purchaseReport> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLStreamHelper.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLStreamHelper.xsd deleted file mode 100644 index 492f61b1d2..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/XMLStreamHelper.xsd +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License - --> -<xsd:schema xmlns:simple3="http://www.example.com/simple3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xshtd="http://www.example.com/simple" elementFormDefault="qualified" targetNamespace="http://www.example.com/simple"> - - <xsd:import namespace="http://www.example.com/simple3" schemaLocation="simple3.xsd"/> - - <xsd:element name="stockQuote" type="xshtd:Quote"/> - - <xsd:complexType name="Quote"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:element name="companyName" type="xsd:string"/> - <xsd:element name="price" type="xsd:decimal"/> - <xsd:element name="open1" type="xsd:decimal"/> - <xsd:element name="high" type="xsd:decimal"/> - <xsd:element name="low" type="xsd:decimal"/> - <xsd:element name="volume" type="xsd:double"/> - <xsd:element name="change1" type="xsd:double"/> - <xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes" type="xshtd:Quote"/> - <xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes3" type="simple3:Quote3"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/anytype.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/anytype.xsd deleted file mode 100644 index db10376360..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/anytype.xsd +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!-- - * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License. - -->
-<xsd:schema xmlns:sdot="http://www.example.com/anytype" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/anytype">
-
- <xsd:element name="globalElement">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="anyTypeElement" type="xsd:anyType"/>
- <xsd:element name="personElement" type="sdot:Person"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:complexType name="Person">
- <xsd:sequence>
- <xsd:element name="firstName" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-</xsd:schema>
diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/api_test.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/api_test.xsd deleted file mode 100644 index 5238c72605..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/api_test.xsd +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!-- - Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License. - -->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:simple="http://www.example.com/api_test" targetNamespace="http://www.example.com/api_test">
- <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/>
- <xsd:element name="apiTestElem" type="simple:APITest"/>
-
- <xsd:complexType mixed="true" name="APITest">
- <xsd:sequence>
- <xsd:element name="stringVal" type="sdo:String"/>
- <xsd:element name="booleanVal" type="sdo:Boolean"/>
- <xsd:element name="booleanVal2" type="sdo:Boolean"/>
- <xsd:element name="byteVal" type="sdo:Byte"/>
- <xsd:element name="stringVal2" type="sdo:String"/>
- <xsd:element name="decimalVal" type="sdo:Decimal"/>
- <xsd:element name="decimalVal2" type="sdo:Decimal"/>
- <xsd:element name="intVal" type="sdo:Int"/>
- <xsd:element name="floatVal" type="sdo:Float"/>
- <xsd:element name="doubleVal" type="sdo:Double"/>
- <xsd:element name="dateVal" type="sdo:Date"/>
- <xsd:element name="shortVal" type="sdo:Short"/>
- <xsd:element name="longVal" type="sdo:Long"/>
- <xsd:element maxOccurs="unbounded" minOccurs="0" name="children" type="simple:APITest"/>
- <xsd:element name="bytesVal" type="sdo:Bytes"/>
- <xsd:element name="integerVal" type="sdo:Integer"/>
- <xsd:element name="charVal" type="sdo:Character"/>
- <xsd:element name="xsdDate" type="xsd:date"/>
- </xsd:sequence>
- </xsd:complexType>
-</xsd:schema>
diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/bank.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/bank.xsd deleted file mode 100644 index a0cb7970b0..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/bank.xsd +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!-- - Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License. - -->
-<xsd:schema targetNamespace="http://www.example.com/bank"
- xmlns:bank="http://www.example.com/bank"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:sdoXML="commonj.sdo/xml">
-
- <xsd:element name="bank" type="bank:bankType"/>
-
- <xsd:complexType name="bankType">
- <xsd:sequence>
- <xsd:element name="Branch" type="bank:branchType" maxOccurs="unbounded" />
- <xsd:element name="Service" type="bank:serviceType" maxOccurs="unbounded" />
- <xsd:element name="Customer" type="bank:customerType" maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="branchType">
- <xsd:sequence>
- <xsd:element name="Address" type="bank:addressType"/>
- <xsd:element name="Directions" type="xsd:string" maxOccurs="unbounded" />
- <xsd:element name="Account" type="bank:accountType" maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="ID" type="xsd:ID"/>
- </xsd:complexType>
-
- <xsd:complexType name="serviceType">
- <xsd:attribute name="ID" type="xsd:ID"/>
- <xsd:attribute name="Name" type="xsd:string"/>
- <xsd:attribute name="Fee" type="xsd:decimal"/>
- </xsd:complexType>
-
- <xsd:complexType name="accountType">
- <xsd:attribute name="ID" type="xsd:ID"/>
- <xsd:attribute name="Service" type="xsd:IDREF" sdoXML:propertyType="bank:serviceType" />
- <xsd:attribute name="Balance" type="xsd:decimal" />
- </xsd:complexType>
-
- <xsd:complexType name="customerType">
- <xsd:sequence>
- <xsd:element name="First" type="xsd:string" />
- <xsd:element name="Last" type="xsd:string" />
- <xsd:element name="Address" type="bank:addressType"/>
- <xsd:element name="HomeBranch" type="xsd:IDREF" sdoXML:propertyType="bank:branchType" />
- <xsd:element name="Account" type="xsd:IDREF" sdoXML:propertyType="bank:accountType" maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="ID" type="xsd:ID"/>
- <xsd:attribute name="Related" type="xsd:IDREFS" sdoXML:propertyType="bank:customerType" />
- </xsd:complexType>
-
- <xsd:complexType name="addressType">
- <xsd:sequence>
- <xsd:element name="Street" type="xsd:string"/>
- <xsd:element name="City" type="xsd:string"/>
- <xsd:element name="State" type="xsd:string"/>
- <xsd:element name="Zip" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-
- </xsd:schema>
diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/bounds.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/bounds.xsd deleted file mode 100644 index 4d92d6e1fe..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/bounds.xsd +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - xmlns:bounds="http://www.example.com/bounds" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://www.example.com/bounds"> - - <xsd:element name="price" type="xsd:decimal"/> - - <xsd:complexType name="OpenQuote"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string" maxOccurs="2" minOccurs="0" /> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="OpenQuote2"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string" maxOccurs="unbounded" /> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="OpenQuote3"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/company.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/company.xsd deleted file mode 100644 index 18e99352be..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/company.xsd +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - <!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> - <xsd:schema xmlns:company="company.xsd" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="company.xsd"> - <xsd:element name="company" type="company:CompanyType"/> - <xsd:complexType name="CompanyType"> - <xsd:sequence> - <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="employeeOfTheMonth" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType name="DepartmentType"> - <xsd:sequence> - <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="location" type="xsd:string"/> - <xsd:attribute name="number" type="xsd:int"/> - </xsd:complexType> - <xsd:complexType name="EmployeeType"> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="SN" type="xsd:ID"/> - <xsd:attribute name="manager" type="xsd:boolean"/> - </xsd:complexType> - </xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/containmenttest.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/containmenttest.xsd deleted file mode 100644 index e576bc9b41..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/containmenttest.xsd +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:contain="http://www.example.com/ContainmentTest" targetNamespace="http://www.example.com/ContainmentTest"> - - <xsd:element name="containTestInstance" type="contain:ContainmentTest"/> - - <xsd:complexType mixed="true" name="ContainmentTest"> - <xsd:sequence> - <xsd:element name="Name" type="xsd:string"/> - <xsd:element name="Contain" type="contain:ContainmentTest"/> - <xsd:element maxOccurs="unbounded" minOccurs="0" name="ContainMany" type="contain:ContainmentTest"/> - </xsd:sequence> - </xsd:complexType> -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/customer1.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/customer1.xml deleted file mode 100644 index 5a29e30a3c..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/customer1.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<customer:Customer - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:customer="http://example.com/customer" - xsi:type="customer:Customer" - custNum="1" - firstName="John" - lastName="Adams"/>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/customer2.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/customer2.xml deleted file mode 100644 index e9ebb92677..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/customer2.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<customer:Customer - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:customer="http://example.com/customer" - xsi:type="customer:Customer" - custNum="2" - firstName="Jeremy" - lastName="Pavick"/>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/datatype.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/datatype.xsd deleted file mode 100644 index 05f55e0502..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/datatype.xsd +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:datatype="http://www.example.com/datatype" xmlns:sdoJava="commonj.sdo/java" targetNamespace="http://www.example.com/datatype"> - - <xsd:simpleType name="SimpleSDOType"> - <xsd:restriction base="xsd:string"/> - </xsd:simpleType> - - <xsd:simpleType name="SimpleSDOTypeInstanceClass" sdoJava:instanceClass="java.lang.Integer"> - <xsd:restriction base="xsd:string"/> - </xsd:simpleType> - - <xsd:simpleType name="SimpleSDOTypeExtendedInstanceClass" sdoJava:extendedInstanceClass="java.lang.String"> - <xsd:restriction base="xsd:string"/> - </xsd:simpleType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/dotNames.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/dotNames.xsd deleted file mode 100644 index a788b7b4f4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/dotNames.xsd +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - --> -<xsd:schema xmlns:dn="http://www.example.com/dotNames" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/dotNames"> - - <xsd:element name="dotNameElement" type="dn:DotNameType"/> - - <xsd:complexType name="DotNameType"> - <xsd:sequence> - <xsd:element maxOccurs="unbounded" minOccurs="0" name="property.2.1" type="xsd:string"/> - <xsd:element maxOccurs="unbounded" minOccurs="0" name="foo.bar" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/dupelement.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/dupelement.xsd deleted file mode 100644 index da2f6920d4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/dupelement.xsd +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - targetNamespace="http://www.example.com/dupelement" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:simple="http://www.example.com/dupelement" - xmlns:sdoXML="commonj.sdo/xml"> - - <xsd:element name="stockQuote" type="simple:Quote"/> - - <xsd:complexType name="Quote"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:element name="companyName" type="xsd:string"/> - <xsd:element name="companyName" type="xsd:int" sdoXML:aliasName="companyNameInInt"/> - <xsd:element name="quotes" type="simple:Quote" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - - <xsd:attribute name="symbol" type="xsd:int" sdoXML:aliasName="symbolInInt"/> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/expectedExceptions.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/expectedExceptions.xsd deleted file mode 100644 index cd12447cd9..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/expectedExceptions.xsd +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:sdo="commonj.sdo" - xmlns:sdoXML="commonj.sdo/xml" - xmlns:expect="http://example.com/ExpectedException" - targetNamespace="http://example.com/ExpectedException"> - - <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/> - <xsd:import namespace="commonj.sdo/xml" schemaLocation="sdoModel.xsd"/> - - <xsd:element name="expectedExceptionsElem" type="expect:ExpectedExceptionType"/> - - <xsd:complexType name="ExpectedExceptionType"> - <xsd:sequence> - <xsd:element name="stringVal" type="xsd:string"/> - <xsd:element name="booleanVal" type="xsd:boolean"/> - <xsd:element name="byteVal" type="xsd:byte"/> - <xsd:element name="decimalVal" type="xsd:decimal"/> - <xsd:element name="intVal" type="xsd:int"/> - <xsd:element name="floatVal" type="xsd:float"/> - <xsd:element name="doubleVal" type="xsd:double"/> - <xsd:element name="dateVal" type="xsd:dateTime"/> - <xsd:element name="shortVal" type="xsd:short"/> - <xsd:element name="longVal" type="xsd:long"/> - <xsd:element maxOccurs="unbounded" minOccurs="0" name="listVal" type="xsd:string"/> - <xsd:element name="bytesVal" type="xsd:hexBinary"/> - <xsd:element name="integerVal" type="xsd:integer"/> - <xsd:element name="charVal" type="expect:char"/> - <xsd:element name="readOnlyVal" sdoXML:readOnly="true" type="xsd:string"/> - <xsd:element name="readOnlyListVal" sdoXML:readOnly="true" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:simpleType name="char"> - <xsd:restriction base="xsd:string"> - <xsd:length value="1"/> - </xsd:restriction> - </xsd:simpleType> - - <xsd:element name="sequencedReadOnlyElem" type="expect:SequenceReadOnlyType"/> - - <xsd:complexType mixed="true" name="SequenceReadOnlyType"> - <xsd:sequence> - <xsd:element name="readOnlyVal" sdoXML:readOnly="true" type="xsd:string"/> - <xsd:element name="readOnlyListVal" sdoXML:readOnly = "true" type="xsd:string"/> - <xsd:element name="uniqueName" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo-ext.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo-ext.xml deleted file mode 100644 index f8c9bc4702..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo-ext.xml +++ /dev/null @@ -1,27 +0,0 @@ -<!-- - * 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. ---> -<module name="m" xmlns="http://foo" xmlns:bar="http://bar" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://bar foo-ext.xsd http://foo foo.xsd "> - <component name="c"> - <bar:implementation.mock myAttr="helloworld.HelloWorldImpl" - listAttr="1 2">1<bar:myElement>Dummy</bar:myElement>2 - </bar:implementation.mock> - </component> -</module>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo-ext.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo-ext.xsd deleted file mode 100644 index 4cdfd1bcd6..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo-ext.xsd +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<schema xmlns="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://bar" - elementFormDefault="qualified" - xmlns:foo="http://foo" xmlns:bar="http://bar"> - - <import namespace="http://foo" - schemaLocation="foo.xsd" /> - - <element name="implementation.mock" type="bar:MockImplementation" - substitutionGroup="foo:implementation" /> - <complexType name="MockImplementation" mixed="true"> - <complexContent> - <extension base="foo:Implementation"> - <sequence> - <element name="myElement" type="string"/> - <any namespace="##other" processContents="lax" - minOccurs="0" maxOccurs="unbounded" /> - </sequence> - <attribute name="myAttr" type="NCName" use="required" /> - <attribute name="listAttr" type="NMTOKENS" use="optional" /> - <anyAttribute namespace="##any" processContents="lax" /> - </extension> - </complexContent> - </complexType> -</schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo.xsd deleted file mode 100644 index f50002ec3d..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/foo.xsd +++ /dev/null @@ -1,232 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<schema xmlns="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://foo" - elementFormDefault="qualified" xmlns:foo="http://foo"> - - <element name="componentType" type="foo:ComponentType"/> - <complexType name="ComponentType"> - <sequence> - <element minOccurs="0" maxOccurs="unbounded" name="service" type="foo:Service"/> - <element minOccurs="0" maxOccurs="unbounded" name="reference" type="foo:Reference"/> - <element minOccurs="0" maxOccurs="unbounded" name="property" type="foo:Property"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <complexType name="Service"> - <sequence> - <element minOccurs="1" maxOccurs="1" ref="foo:interface"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <element name="interface" type="foo:Interface"/> - <complexType name="Interface"/> - - <complexType name="Reference"> - <sequence> - <element minOccurs="1" maxOccurs="1" ref="foo:interface"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <attribute name="multiplicity" type="foo:Multiplicity" use="optional" default="1..1"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <complexType name="Property"> - <sequence> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <attribute name="type" type="QName" use="required"/> - <attribute name="many" type="boolean" default="false" use="optional"/> - <attribute name="required" type="boolean" default="false" use="optional"/> - <attribute name="default" type="string" use="optional"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - - <element name="moduleFragment" type="foo:ModuleFragment"/> - <complexType name="ModuleFragment"> - <sequence> - <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="foo:EntryPoint"/> - <element minOccurs="0" maxOccurs="unbounded" name="component" type="foo:Component"/> - <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="foo:ExternalService"/> - <element minOccurs="0" maxOccurs="unbounded" name="wire" type="foo:ModuleWire"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <element name="module" type="foo:Module"/> - <complexType name="Module"> - <complexContent> - <extension base="foo:ModuleFragment"/> - </complexContent> - </complexType> - - <complexType name="EntryPoint"> - <sequence> - <element minOccurs="0" maxOccurs="1" ref="foo:interface"/> - <element minOccurs="1" maxOccurs="unbounded" ref="foo:binding"/> - <element minOccurs="1" maxOccurs="unbounded" name="reference" type="anyURI"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <attribute name="multiplicity" type="foo:Multiplicity" use="optional" default="1..1"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - <!-- a multiplicity 1..1 or 0..n sample - <reference>StockQuoteComponent</reference> - type must be URI - a multiplicity 1..n or 0..n sample - <reference>StockQuoteComponent1</reference> - type must be URI - <reference>StockQuoteComponent2</reference> - --> - - <element name="binding" type="foo:Binding"/> - <complexType name="Binding"> - <attribute name="uri" type="anyURI" use="optional"/> - </complexType> - - <complexType name="Component"> - <sequence> - <element minOccurs="1" maxOccurs="1" ref="foo:implementation"/> - <element minOccurs="0" maxOccurs="1" name="properties" type="foo:PropertyValues"/> - <element minOccurs="0" maxOccurs="1" name="references" type="foo:ReferenceValues"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - <!-- a multiplicity 1..1 or 0..1 sample - <references> - <v:stockQuote>StockQuoteComponent</v:stockquote> - type must be URI - </references> - a multiplicity 1..n or 0..n sample - <references> - <v:stockQuote>StockQuoteComponent1</v:stockQuote> - type must be URI - <v:stockQuote>StockQuoteComponent2</v:stockQuote> - </references> - --> - - <element name="implementation" type="foo:Implementation"/> - <complexType name="Implementation"/> - - <complexType name="PropertyValues"> - <sequence> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <complexType name="ReferenceValues"> - <sequence> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - - <complexType name="ExternalService"> - <sequence> - <element minOccurs="1" maxOccurs="1" ref="foo:interface"/> - <element minOccurs="0" maxOccurs="unbounded" ref="foo:binding"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <attribute name="overridable" type="foo:OverrideOptions" default="may" use="optional"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - - <complexType name="ModuleWire"> - <sequence> - <element minOccurs="1" maxOccurs="1" ref="foo:source.uri"/> - <element minOccurs="1" maxOccurs="1" ref="foo:target.uri"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <element name="source"/> - <element name="target"/> - - <element name="source.uri" type="anyURI" substitutionGroup="foo:source"/> - <element name="target.uri" type="anyURI" substitutionGroup="foo:target"/> - - <element name="subsystem" type="foo:Subsystem"/> - <complexType name="Subsystem"> - <sequence> - <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="foo:EntryPoint"/> - <element minOccurs="0" maxOccurs="unbounded" name="moduleComponent" type="foo:ModuleComponent"/> - <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="foo:ExternalService"/> - <element minOccurs="0" maxOccurs="unbounded" name="wire" type="foo:SystemWire"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <attribute name="uri" type="anyURI" use="optional"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <complexType name="ModuleComponent"> - <sequence> - <element minOccurs="0" maxOccurs="1" name="properties" type="foo:PropertyValues"/> - <element minOccurs="0" maxOccurs="1" name="references" type="foo:ReferenceValues"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="name" type="NCName" use="required"/> - <attribute name="module" type="NCName" use="required"/> - <attribute name="uri" type="anyURI" use="optional"/> - <anyAttribute namespace="##any" processContents="lax"/> - </complexType> - - <complexType name="SystemWire"> - <sequence> - <element minOccurs="1" maxOccurs="1" ref="foo:source"/> - <element minOccurs="1" maxOccurs="1" ref="foo:target"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - </complexType> - - <element name="source.epr" substitutionGroup="foo:source"/> - <element name="target.epr" substitutionGroup="foo:target"/> - - <simpleType name="Multiplicity"> - <restriction base="string"> - <enumeration value="0..1"/> - <enumeration value="1..1"/> - <enumeration value="0..n"/> - <enumeration value="1..n"/> - </restriction> - </simpleType> - - <simpleType name="OverrideOptions"> - <restriction base="string"> - <enumeration value="no"/> - <enumeration value="may"/> - <enumeration value="must"/> - </restriction> - </simpleType> - -</schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/ipo.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/ipo.xsd deleted file mode 100644 index 241ec15d36..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/ipo.xsd +++ /dev/null @@ -1,136 +0,0 @@ -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<schema targetNamespace="http://www.example.com/IPO" - xmlns="http://www.w3.org/2001/XMLSchema" - xmlns:ipo="http://www.example.com/IPO"> - - <annotation> - <documentation xml:lang="en"> - International Purchase order schema for Example.com - Copyright 2000 Example.com. All rights reserved. - </documentation> - </annotation> - - - <element name="purchaseOrder" type="ipo:PurchaseOrderType" /> - - <element name="comment" type="string" /> - - <complexType name="PurchaseOrderType"> - <sequence> - <element name="shipTo" type="ipo:Address" /> - <element name="billTo" type="ipo:Address" /> - <element ref="ipo:comment" minOccurs="0" /> - <element name="items" type="ipo:Items" /> - </sequence> - <attribute name="orderDate" type="date" /> - </complexType> - - <complexType name="Items"> - <sequence> - <element name="item" minOccurs="0" maxOccurs="unbounded"> - <complexType> - <sequence> - <element name="productName" type="string" /> - <element name="quantity"> - <simpleType> - <restriction base="positiveInteger"> - <maxExclusive value="100" /> - </restriction> - </simpleType> - </element> - <element name="USPrice" type="decimal" /> - <element ref="ipo:comment" minOccurs="0" /> - <element name="shipDate" type="date" - minOccurs="0" /> - </sequence> - <attribute name="partNum" type="ipo:SKU" - use="required" /> - </complexType> - </element> - </sequence> - </complexType> - - <simpleType name="SKU"> - <restriction base="string"> - <pattern value="\d{3}-[A-Z]{2}" /> - </restriction> - </simpleType> - - <complexType name="Address"> - <sequence> - <element name="name" type="string" /> - <element name="street" type="string" /> - <element name="city" type="string" /> - </sequence> - </complexType> - - <complexType name="USAddress"> - <complexContent> - <extension base="ipo:Address"> - <sequence> - <element name="state" type="ipo:USState" /> - <element name="zip" type="positiveInteger" /> - </sequence> - </extension> - </complexContent> - </complexType> - - <complexType name="UKAddress"> - <complexContent> - <extension base="ipo:Address"> - <sequence> - <element name="postcode" type="ipo:UKPostcode" /> - </sequence> - <attribute name="exportCode" type="positiveInteger" - fixed="1" /> - </extension> - </complexContent> - </complexType> - - <!-- other Address derivations for more countries --> - - <simpleType name="USState"> - <restriction base="string"> - <enumeration value="AK" /> - <enumeration value="AL" /> - <enumeration value="AR" /> - <enumeration value="CA" /> - <enumeration value="PA" /> - <!-- and so on ... --> - </restriction> - </simpleType> - - <simpleType name="Postcode"> - <restriction base="string"> - <length value="7" fixed="true" /> - </restriction> - </simpleType> - - - <simpleType name="UKPostcode"> - <restriction base="ipo:Postcode"> - <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" /> - </restriction> - </simpleType> - - - -</schema> - diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed.xml deleted file mode 100644 index 42ff3a3a5b..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<mixed:mixedStockQuote xmlns:mixed="http://www.example.com/mixed"> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - some text - <quotes><price>2000.0</price></quotes> - more text - <price>1000.0</price> -</mixed:mixedStockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed.xsd deleted file mode 100644 index deee92e9c1..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed.xsd +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - targetNamespace="http://www.example.com/mixed" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:mixed="http://www.example.com/mixed"> - - <xsd:element name="mixedStockQuote" type="mixed:MixedQuote"/> - - <xsd:complexType name="MixedQuote" mixed="true"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:element name="companyName" type="xsd:string"/> - <xsd:element name="price" type="xsd:decimal"/> - <xsd:element name="open1" type="xsd:decimal"/> - <xsd:element name="high" type="xsd:decimal"/> - <xsd:element name="low" type="xsd:decimal"/> - <xsd:element name="volume" type="xsd:double"/> - <xsd:element name="change1" type="xsd:double"/> - <xsd:element name="quotes" type="mixed:MixedQuote" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed2.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed2.xml deleted file mode 100644 index d95d179478..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixed2.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<mixed:mixedStockQuote - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:mixed="http://www.example.com/mixed" - xsi:type="mixed:MixedQuote"> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - some text - <quotes><price>2000.0</price></quotes> - more text - <price>1000.0</price> -</mixed:mixedStockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedChangeSummary.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedChangeSummary.xml deleted file mode 100644 index 49dbb89f38..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedChangeSummary.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<cs:stockQuote xmlns:cs="http://www.example.com/sequenceCS"><changes create="#//quotes[3] #//quotes[4]" delete="#//changes/stockQuote[1]/quotes[2]" logging="false" xmlns:sdo="commonj.sdo"> - <cs:stockQuote sdo:ref="#/stockQuote"> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>1000.0</price> - <quotes sdo:ref="#//quotes[1]" /> - <quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes> - <quotes sdo:ref="#//quotes[2]" /> - </cs:stockQuote> -</changes><symbol>FBNT</symbol><companyName>FlyByNightTechnology</companyName><price>999.0</price><quotes><price>1500.0</price></quotes><quotes><price>2500.0</price></quotes><volume>1000.0</volume><quotes><price>3000.0</price></quotes><quotes><price>4000.0</price></quotes></cs:stockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedChangeSummaryUndone.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedChangeSummaryUndone.xml deleted file mode 100644 index d8097ace8b..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedChangeSummaryUndone.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<cs:stockQuote xmlns:cs="http://www.example.com/sequenceCS"><changes logging="false" /><symbol>fbnt</symbol><companyName>FlyByNightTechnology</companyName><price>1000.0</price><quotes><price>1500.0</price></quotes><quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes><quotes><price>2500.0</price></quotes></cs:stockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedopen.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedopen.xml deleted file mode 100644 index 21a62ef2d0..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/mixedopen.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<mixed:mixedOpenStockQuote - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:mixed="http://www.example.com/mixed" - xmlns:open="http://www.example.com/open" - xsi:type="mixed:MixedOpenQuote"> - <open:symbol>fbnt</open:symbol> - <companyName>FlyByNightTechnology</companyName> - some text - <quotes><price>2000.0</price></quotes> - more text - <price>1000.0</price> -</mixed:mixedOpenStockQuote> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/names.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/names.xsd deleted file mode 100644 index 9096b2d62f..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/names.xsd +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - targetNamespace="http://www.example.com/names" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:names="http://www.example.com/names"> - - <xsd:element name="class" type="names:class"/> - <xsd:element name="test.element" type="names:test.element" /> - <xsd:element name="void" type="names:void" /> - - <xsd:complexType name="class" /> - <xsd:complexType name="test.element" /> - <xsd:complexType name="void" /> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/open.xml deleted file mode 100644 index d4a5b92e0c..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<open:openStockQuote xmlns:open="http://www.example.com/open"> - <symbol>s1</symbol> - <open:company> - <name>FlyByNightTechnology</name> - </open:company> - <open:price>1000.0</open:price> -</open:openStockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/open.xsd deleted file mode 100644 index 803c0a9cee..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open.xsd +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - xmlns:open="http://www.example.com/open" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://www.example.com/open"> - - <xsd:element name="openStockQuote" type="open:OpenQuote"/> - - <xsd:element name="price" type="xsd:decimal"/> - - <xsd:element name="company"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="name" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - - <xsd:complexType name="OpenQuote"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:any maxOccurs="unbounded" namespace="##any"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="OpenQuote2"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:any maxOccurs="1" namespace="##any"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open1any.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/open1any.xsd deleted file mode 100644 index 00efaef5e0..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open1any.xsd +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - xmlns:simple="http://www.example.com/open1any" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://www.example.com/open1any"> - - <xsd:element name="openStockQuote" type="simple:OpenQuote"/> - - <xsd:element name="price" type="xsd:decimal"/> - - <xsd:element name="company"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="name" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - - <xsd:complexType name="OpenQuote"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:any namespace="##any"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open2.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/open2.xml deleted file mode 100644 index ab992ccf74..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/open2.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<open:openStockQuote - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:open="http://www.example.com/open" - xsi:type="open:OpenQuote"> - <open:symbol>s1</open:symbol> - <open:company name="FlyByNightTechnology"/> - <open:price>1000.0</open:price> -</open:openStockQuote> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/openChangeSummary.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/openChangeSummary.xml deleted file mode 100644 index 4ef2dc5948..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/openChangeSummary.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<cs:openQuote xmlns:cs="http://www.example.com/sequenceCS" xmlns:open="http://www.example.com/open"> - <symbol>FBNT</symbol> - <open:openStockQuote> - <symbol>1500.0</symbol> - </open:openStockQuote> - <open:openStockQuote> - <symbol>2500.0</symbol> - </open:openStockQuote> - <open:openStockQuote> - <symbol>3000.0</symbol> - </open:openStockQuote> - <open:openStockQuote> - <symbol>4000.0</symbol> - </open:openStockQuote> - <changes create="#//open:openStockQuote[3] #//open:openStockQuote[4]" delete="#//changes/openQuote[1]/open:openStockQuote[2]" logging="false" xmlns:sdo="commonj.sdo"> - <cs:openQuote sdo:ref="#/openQuote"> - <symbol>fbnt</symbol> - <open:openStockQuote sdo:ref="#//open:openStockQuote[1]" /> - <open:openStockQuote><symbol>2000.0</symbol><open:openStockQuote><symbol>2000.99</symbol></open:openStockQuote></open:openStockQuote> - <open:openStockQuote sdo:ref="#//open:openStockQuote[2]" /> - </cs:openQuote> - </changes> -</cs:openQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/openChangeSummaryUndone.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/openChangeSummaryUndone.xml deleted file mode 100644 index 9883a3824a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/openChangeSummaryUndone.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<cs:openQuote xmlns:cs="http://www.example.com/sequenceCS" xmlns:open="http://www.example.com/open"> - <symbol>fbnt</symbol> - <open:openStockQuote> - <symbol>1500.0</symbol> - </open:openStockQuote> - <open:openStockQuote> - <symbol>2000.0</symbol> - <open:openStockQuote> - <symbol>2000.99</symbol> - </open:openStockQuote> - </open:openStockQuote> - <open:openStockQuote> - <symbol>2500.0</symbol> - </open:openStockQuote> - <changes logging="false" /> -</cs:openQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/openContentProperty.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/openContentProperty.xml deleted file mode 100644 index 68f4c116eb..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/openContentProperty.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<open:openStockQuote xmlns:open="http://www.example.com/open"> - <symbol>s1</symbol> - <open:company> - <name>FlyByNightTechnology</name> - </open:company> - <open:price>1000.0</open:price> - <open:highPrice>1100.0</open:highPrice> - <open:mutualFundQuote> - <symbol>mutual-1</symbol> - </open:mutualFundQuote> -</open:openStockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/osgi/sdo.impl.mf b/branches/sdo-1.1.1-incubating/impl/src/test/resources/osgi/sdo.impl.mf deleted file mode 100644 index dfc58b624a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/osgi/sdo.impl.mf +++ /dev/null @@ -1,44 +0,0 @@ -Manifest-Version: 1.0
-Extension-Name: tuscany-sdo-impl
-Specification-Title: Tuscany SDO Implementation
-Specification-Vendor: Apache Software Foundation
-Implementation-Vendor: Apache Software Foundation
-Implementation-Vendor-Id: org.apache
-Implementation-Title: tuscany-sdo-impl
-Implementation-Version: incubating-M3
-Bundle-ManifestVersion: 2
-Bundle-Name: Tuscany SDO Implementation
-Bundle-SymbolicName: org.apache.tuscany.sdo.impl
-Bundle-Version: 1.0.0
-Bundle-Vendor: Apache Software Foundation
-Require-Bundle: org.eclipse.emf.common,
- org.eclipse.emf.ecore,
- org.eclipse.emf.ecore.change,
- org.eclipse.emf.ecore.xmi,
- org.eclipse.xsd,
- org.apache.tuscany.sdo.lib;visibility:=reexport,
- org.apache.tuscany.sdo.spec;visibility:=reexport
-Import-Package: org.osgi.framework,
- org.xml.sax,
- org.xml.sax.helpers,
- org.xml.sax.ext,
- org.w3c.dom,
- org.w3c.dom.events,
- javax.xml,
- javax.xml.parsers,
- javax.xml.stream,
- javax.xml.transform,
- javax.xml.transform.dom,
- javax.xml.transform.stream,
- javax.xml.namespace,
- org.objectweb.asm
-Export-Package:
- org.apache.tuscany.sdo,
- org.apache.tuscany.sdo.helper,
- org.apache.tuscany.sdo.impl,
- org.apache.tuscany.sdo.util,
- org.apache.tuscany.sdo.codegen,
- org.apache.tuscany.sdo.model,
- org.apache.tuscany.sdo.model.impl,
- org.apache.tuscany.sdo.model.internal
-Bundle-Activator: org.apache.tuscany.sdo.osgi.SdoBundleActivator
diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/osgi/sdo.osgi.test.mf b/branches/sdo-1.1.1-incubating/impl/src/test/resources/osgi/sdo.osgi.test.mf deleted file mode 100644 index d63e3244d5..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/osgi/sdo.osgi.test.mf +++ /dev/null @@ -1,40 +0,0 @@ -Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Tuscany SDO OSGi Tests
-Bundle-SymbolicName: org.apache.tuscany.sdo.osgi.test
-Bundle-Version: 1.0.0
-Bundle-Vendor: Apache Software Foundation
-Import-Package: org.osgi.framework,
- junit.framework,
- javax.xml,
- javax.xml.parsers,
- org.xml.sax,
- org.xml.sax.helpers,
- org.xml.sax.ext,
- org.w3c.dom,
- org.w3c.dom.events,
- javax.xml.stream,
- javax.xml.transform,
- javax.xml.transform.dom,
- javax.xml.transform.stream,
- javax.xml.namespace,
- org.eclipse.emf.common,
- org.eclipse.emf.common.archive,
- org.eclipse.emf.common.command,
- org.eclipse.emf.common.notify,
- org.eclipse.emf.common.util,
- org.eclipse.emf.ecore,
- org.eclipse.emf.ecore.impl,
- org.eclipse.emf.ecore.plugin,
- org.eclipse.emf.ecore.resource,
- org.eclipse.emf.ecore.util,
- org.eclipse.emf.ecore.xml.namespace,
- org.eclipse.emf.ecore.xml.namespace.util,
- org.eclipse.emf.ecore.xml.type,
- org.eclipse.emf.ecore.xml.type.util,
- org.eclipse.xsd
-Export-Package: org.apache.tuscany.sdo.osgi
-Require-Bundle: org.apache.tuscany.sdo.lib;visibility:=reexport,
- org.apache.tuscany.sdo.impl;visibility:=reexport,
- org.apache.tuscany.sdo.spec;visibility:=reexport
-Bundle-Activator: org.apache.tuscany.sdo.test.osgi.TestBundleActivator
diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/po.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/po.xsd deleted file mode 100644 index d158dcf448..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/po.xsd +++ /dev/null @@ -1,80 +0,0 @@ -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.example.com/PO" targetNamespace="http://www.example.com/PO"> - - <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> - <xsd:element name="comment" type="xsd:string"/> - - <xsd:complexType name="PurchaseOrderType"> - <xsd:sequence> - <xsd:element name="shipTo" type="USAddress"/> - <xsd:element name="billTo" type="USAddress"/> - <xsd:element ref="comment" minOccurs="0"/> - <xsd:element name="items" type="Items"/> - - </xsd:sequence> - <xsd:attribute name="orderDate" type="xsd:date"/> - </xsd:complexType> - - <xsd:complexType name="USAddress"> - <xsd:sequence> - <xsd:element name="name" type="xsd:string"/> - - <xsd:element name="street" type="xsd:string"/> - <xsd:element name="city" type="xsd:string"/> - <xsd:element name="state" type="xsd:string"/> - <xsd:element name="zip" type="xsd:decimal"/> - </xsd:sequence> - <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/> - - </xsd:complexType> - - <xsd:complexType name="Items"> - <xsd:sequence> - <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> - <xsd:complexType> - <xsd:sequence> - - <xsd:element name="productName" type="xsd:string"/> - <xsd:element name="price" type="xsd:decimal"/> - <xsd:element name="quantity"> - <xsd:simpleType> - <xsd:restriction base="xsd:positiveInteger"> - <xsd:maxExclusive value="100"/> - </xsd:restriction> - - </xsd:simpleType> - </xsd:element> - <xsd:element ref="comment" minOccurs="0"/> - <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> - </xsd:sequence> - - <xsd:attribute name="partNum" type="SKU" use="required"/> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - </xsd:complexType> - <xsd:simpleType name="SKU"> - - <xsd:restriction base="xsd:string"> - <xsd:pattern value="\d{3}-[A-Z]{2}"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/prefix.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/prefix.xsd deleted file mode 100644 index af3d3283f5..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/prefix.xsd +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Copyright (c) 2005-2006 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. - --> -<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:as="http://soaassureservice.soabench.ibm.com" targetNamespace="http://soaassureservice.soabench.ibm.com"> - <element name="requestInfo" type="string"/> - <complexType name="CreateClaim"> - <sequence> - <element ref="as:requestInfo"/> - </sequence> - </complexType> -</schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/quote.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/quote.xml deleted file mode 100644 index d7b5969e23..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/quote.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<simple:stockQuote xmlns:simple="http://www.example.com/simple"> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>1000.0</price> - <open1>1000.0</open1> - <high>1000.0</high> - <low>1000.0</low> - <volume>1000.0</volume> - <change1>1000.0</change1> - <quotes> - <price>2000.0</price> - </quotes> -</simple:stockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/quoteInSOAP.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/quoteInSOAP.xml deleted file mode 100644 index 348b61047e..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/quoteInSOAP.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:simple="http://www.example.com/simple"> - <soapenv:Header/> - <soapenv:Body> - <simple:stockQuote> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>1000.0</price> - <open1>1000.0</open1> - <high>1000.0</high> - <low>1000.0</low> - <volume>1000.0</volume> - <change1>1000.0</change1> - <quotes> - <price>2000.0</price> - </quotes> - </simple:stockQuote> - </soapenv:Body> -</soapenv:Envelope>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdoModel.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdoModel.xsd deleted file mode 100644 index 6b596c5b36..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdoModel.xsd +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - --> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo"> - - <!-- Dummy XSD definition of special SDO ChangeSummaryType --> - <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary"> - <xsd:restriction base="xsd:string"/> - </xsd:simpleType> - - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdoannotations.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdoannotations.xsd deleted file mode 100644 index acdde2896a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdoannotations.xsd +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - targetNamespace="http://www.example.com/sdoannotations" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:sdoa="http://www.example.com/sdoannotations" - xmlns:sdo="commonj.sdo/xml" - xmlns:sdoj="commonj.sdo/java"> - - <!-- simple element with no annotations --> - <xsd:element name="foo0" type="xsd:string" /> - - <!-- simple element with sdo:name --> - <xsd:element name="foo1" type="xsd:string" sdo:name="foo2" /> - - <!-- simple element with sdo:type --> - <xsd:element - name="foo3" type="xsd:int" - sdo:dataType="xsd:string" - sdo:aliasName="foo4" - sdo:readOnly="true" /> - - <xsd:element - name="foo5" type="sdoa:foo6" /> - - <!-- complex type with no annotations --> - <xsd:complexType name="foo6"> - <xsd:sequence> - <xsd:element name="bar1" type="xsd:int" /> - </xsd:sequence> - <xsd:attribute name="bar2" type="xsd:int" /> - </xsd:complexType> - - <xsd:element - name="foo7" type="sdoa:foo8" /> - - <xsd:complexType name="foo8" sdo:name="foo9" sdoj:instanceClass="org.apache.tuscany.sdo.test.XSDHelperTestCase"> - <xsd:sequence> - <xsd:element name="bar3" type="xsd:int" sdo:string="true" /> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdotypes.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdotypes.xsd deleted file mode 100644 index 09c05bb671..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/sdotypes.xsd +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - targetNamespace="http://www.example.com/sdotypes" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:sdot="http://www.example.com/sdotypes"> - - <xsd:element name="foo0" type="xsd:anySimpleType"/> - <xsd:element name="foo2" type="xsd:anyURI"/> - <xsd:element name="foo3" type="xsd:base64Binary"/> - <xsd:element name="foo4" type="xsd:boolean"/> - <xsd:element name="foo5" type="xsd:byte"/> - <xsd:element name="foo6" type="xsd:date"/> - <xsd:element name="foo7" type="xsd:dateTime"/> - <xsd:element name="foo8" type="xsd:decimal"/> - <xsd:element name="foo9" type="xsd:double"/> - <xsd:element name="foo10" type="xsd:duration"/> - <xsd:element name="foo11" type="xsd:ENTITIES"/> - <xsd:element name="foo12" type="xsd:ENTITY"/> - <xsd:element name="foo13" type="xsd:float"/> - <xsd:element name="foo14" type="xsd:gDay"/> - <xsd:element name="foo15" type="xsd:gMonth"/> - <xsd:element name="foo16" type="xsd:gMonthDay"/> - <xsd:element name="foo17" type="xsd:gYear"/> - <xsd:element name="foo18" type="xsd:gYearMonth"/> - <xsd:element name="foo19" type="xsd:hexBinary"/> - <xsd:element name="foo20" type="xsd:ID"/> - <xsd:element name="foo21" type="xsd:IDREF"/> - <xsd:element name="foo22" type="xsd:IDREFS"/> - <xsd:element name="foo23" type="xsd:int"/> - <xsd:element name="foo24" type="xsd:integer"/> - <xsd:element name="foo25" type="xsd:language"/> - <xsd:element name="foo26" type="xsd:long"/> - <xsd:element name="foo27" type="xsd:Name"/> - <xsd:element name="foo28" type="xsd:NCName"/> - <xsd:element name="foo29" type="xsd:negativeInteger"/> - <xsd:element name="foo30" type="xsd:NMTOKEN"/> - <xsd:element name="foo31" type="xsd:NMTOKENS"/> - <xsd:element name="foo32" type="xsd:nonNegativeInteger"/> - <xsd:element name="foo33" type="xsd:nonPositiveInteger"/> - <xsd:element name="foo34" type="xsd:normalizedString"/> - <xsd:element name="foo35" type="xsd:NOTATION"/> - <xsd:element name="foo36" type="xsd:positiveInteger"/> - <xsd:element name="foo37" type="xsd:QName"/> - <xsd:element name="foo38" type="xsd:short"/> - <xsd:element name="foo39" type="xsd:string"/> - <xsd:element name="foo40" type="xsd:time"/> - <xsd:element name="foo41" type="xsd:token"/> - <xsd:element name="foo42" type="xsd:unsignedByte"/> - <xsd:element name="foo43" type="xsd:unsignedInt"/> - <xsd:element name="foo44" type="xsd:unsignedLong"/> - <xsd:element name="foo45" type="xsd:unsignedShort"/> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/shallowquote.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/shallowquote.xml deleted file mode 100644 index a56f2fe2b7..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/shallowquote.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<simple:stockQuote xmlns:simple="http://www.example.com/simple"> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>1000.0</price> - <open1>1000.0</open1> - <high>1000.0</high> - <low>1000.0</low> - <volume>1000.0</volume> - <change1>1000.0</change1> -</simple:stockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/shallowquote1.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/shallowquote1.xml deleted file mode 100644 index a9bb2bf330..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/shallowquote1.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * 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. ---> -<simple:stockQuote xmlns:simple="http://www.example.com/simple"> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>1000.0</price> - <open1>1000.0</open1> - <high>1000.0</high> - <low>1000.0</low> - <volume>1000.0</volume> - <change1>1000.0</change1> - </simple:stockQuote> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple.xsd deleted file mode 100644 index 661259e57a..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple.xsd +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - targetNamespace="http://www.example.com/simple" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:simple="http://www.example.com/simple"> - - <xsd:element name="stockQuote" type="simple:Quote"/> - - <xsd:complexType name="Quote"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:element name="companyName" type="xsd:string"/> - <xsd:element name="price" type="xsd:decimal"/> - <xsd:element name="open1" type="xsd:decimal"/> - <xsd:element name="high" type="xsd:decimal"/> - <xsd:element name="low" type="xsd:decimal"/> - <xsd:element name="volume" type="xsd:double"/> - <xsd:element name="change1" type="xsd:double"/> - <xsd:element name="quotes" type="simple:Quote" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple2.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple2.xsd deleted file mode 100644 index 53bace49b5..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple2.xsd +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema xmlns:simple="http://www.example.com/simple" xmlns:simple2="http://www.example.com/simple2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simple2"> - - <xsd:import namespace="http://www.example.com/simple"/> - - <xsd:element name="stockQuote" type="simple2:Quote2"/> - - <xsd:complexType name="Quote2"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:element name="companyName" type="xsd:string"/> - <xsd:element name="price" type="xsd:decimal"/> - <xsd:element name="open1" type="xsd:decimal"/> - <xsd:element name="high" type="xsd:decimal"/> - <xsd:element name="low" type="xsd:decimal"/> - <xsd:element name="volume" type="xsd:double"/> - <xsd:element name="change1" type="xsd:double"/> - <!-- temporarily removing this until we find a way to do this test without causing eclipse to light up - due to missing import --> - <!-- <xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes" type="simple:Quote"/> --> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple3.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple3.xsd deleted file mode 100644 index 6ff14a85d2..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simple3.xsd +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<xsd:schema - targetNamespace="http://www.example.com/simple3" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:simple3="http://www.example.com/simple3" -elementFormDefault="qualified"> -<!-- <xsd:element name="stockQuote" type="simple3:Quote3"/>--> - - <xsd:complexType name="Quote3"> - <xsd:sequence> - <xsd:element name="symbol3" type="xsd:string"/> - <xsd:element name="company3" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummary.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummary.xml deleted file mode 100644 index 2f29fc00f0..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummary.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS"> - <symbol>FBNT</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>999.0</price> - <volume>1000.0</volume> - <quotes> - <price>1500.0</price> - </quotes> - <quotes> - <price>2500.0</price> - </quotes> - <quotes> - <price>3000.0</price> - </quotes> - <quotes> - <price>4000.0</price> - </quotes> - <changes create="#//quotes[3] #//quotes[4]" delete="#//changes/stockQuote[1]/quotes[2]" logging="false" xmlns:sdo="commonj.sdo"> - <cs:stockQuote sdo:ref="#/stockQuote" sdo:unset="volume"> - <symbol>fbnt</symbol> - <price>1000.0</price> - <quotes sdo:ref="#//quotes[1]" /> - <quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes> - <quotes sdo:ref="#//quotes[2]" /> - </cs:stockQuote> - </changes> -</cs:stockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummary.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummary.xsd deleted file mode 100644 index 1df0f69196..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummary.xsd +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Copyright (c) 2005-2006 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. - --> -<xsd:schema xmlns:sdo="commonj.sdo" xmlns:cs="http://www.example.com/simpleCS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://www.example.com/simpleCS"> - - - <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/> - - <xsd:complexType name="RootQuote"> - <xsd:complexContent> - <xsd:extension base="cs:Quote"> - <xsd:sequence> - <xsd:element name="changes" type="sdo:ChangeSummaryType"/> - </xsd:sequence> - </xsd:extension> - </xsd:complexContent> - - </xsd:complexType> - - <xsd:element name="stockQuote" type="cs:RootQuote"/> - - <xsd:complexType name="Quote"> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:element name="companyName" type="xsd:string"/> - <xsd:element name="price" type="xsd:decimal"/> - <xsd:element name="open1" type="xsd:decimal"/> - <xsd:element name="high" type="xsd:decimal"/> - <xsd:element name="low" type="xsd:decimal"/> - <xsd:element name="volume" type="xsd:double"/> - <xsd:element name="change1" type="xsd:double"/> - <xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes" type="cs:Quote"/> - </xsd:sequence> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummaryUndone.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummaryUndone.xml deleted file mode 100644 index a9c675b6c3..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simpleWithChangeSummaryUndone.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS"> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>1000.0</price> - <quotes> - <price>1500.0</price> - </quotes> - <quotes> - <price>2000.0</price> - <quotes> - <price>2000.99</price> - </quotes> - </quotes> - <quotes> - <price>2500.0</price> - </quotes> - <changes logging="false" /> -</cs:stockQuote>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simplechangesummary.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/simplechangesummary.xml deleted file mode 100644 index 134e2f7de5..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/simplechangesummary.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo" - xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:simple="http://www.example.com/simple"> - <changeSummary xmlns="" - logging="false"> - <objectChanges key="#//@eRootObject"> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="symbol" set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="companyName" set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="price" set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="open1" set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="high" set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="low" set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="volume" dataValue="0.0" - set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="change1" dataValue="0.0" - set="false"/> - <value xsi:type="sdo_1:ChangeSummarySetting" featureName="quotes" set="false"/> - </objectChanges> - </changeSummary> - <simple:Quote> - <symbol>fbnt</symbol> - <companyName>FlyByNightTechnology</companyName> - <price>1000.0</price> - <open1>1000.0</open1> - <high>1000.0</high> - <low>1000.0</low> - <volume>1000.0</volume> - <change1>1000.0</change1> - <quotes> - <price>2000.0</price> - </quotes> - </simple:Quote> -</sdo:datagraph> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/substitutionValues1.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/substitutionValues1.xml deleted file mode 100644 index c534eb9370..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/substitutionValues1.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * 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. ---> -<sv:testObject xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues"> - <sv:groupMember>gm</sv:groupMember> - <sv:nonGroupHead>ngh</sv:nonGroupHead> -</sv:testObject> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/substitutionValues2.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/substitutionValues2.xml deleted file mode 100644 index d90d0f3a0c..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/substitutionValues2.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * 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. ---> -<sv:testObject xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues"> - <sv:groupHead>gh</sv:groupHead> - <sv:nonGroupHead>ngh</sv:nonGroupHead> -</sv:testObject> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/xpath.xml b/branches/sdo-1.1.1-incubating/impl/src/test/resources/xpath.xml deleted file mode 100644 index 3b3e2ffbb4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/xpath.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<xpath:drive xmlns:xpath="http://www.example.com/xpath" id="0"> - <Folder creation_date="1999-10-20" creator="Hasan" type="FolderType"> - <FolderName>Folder00000000000</FolderName> - <description>marries inflamed apprehended beseeming bustle</description> - <SecurityObject name="secure1"> - <Allows> - <Allow> - <User>Brian</User> - <Permissions>rw</Permissions> - </Allow> - <Allow> - <User>Fuhwei</User> - <Permissions>r</Permissions> - </Allow> - </Allows> - <Denies> - <Deny> - <User>Hasan</User> - </Deny> - <Deny> - <User>Frank</User> - </Deny> - </Denies> - </SecurityObject> - </Folder> - <Folder creation_date="2000-03-23" creator="Kapil" type="FileType"> - <FolderName>Folder00000000011</FolderName> - <description>Mumbling Jumblin Pink Panther goofs it up</description> - <SecurityObject name="secure2"> - <Allows> - <Allow> - <User>Imad</User> - <Permissions>x</Permissions> - </Allow> - <Allow> - <User>Robbie</User> - <Permissions>rwx</Permissions> - </Allow> - </Allows> - <Denies> - <Deny> - <User>Yang</User> - </Deny> - <Deny> - <User>Art</User> - </Deny> - </Denies> - </SecurityObject> - </Folder> -</xpath:drive>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/xpath.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/xpath.xsd deleted file mode 100644 index 0b817d425d..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/xpath.xsd +++ /dev/null @@ -1,75 +0,0 @@ -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.example.com/xpath" targetNamespace="http://www.example.com/xpath"> - <!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> - <xsd:element name="drive" type="DriveType"/> - - <xsd:complexType name="DriveType"> - <xsd:sequence> - <xsd:element name="Folder" type="FolderType" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="id" type="xsd:int"/> - </xsd:complexType> - - <xsd:complexType name="FolderType"> - <xsd:sequence> - <xsd:element name="FolderName" type="xsd:string"/> - <xsd:element name="description" type="xsd:string"/> - <xsd:element name="SecurityObject" type="SecurityObjectType"/> - </xsd:sequence> - <xsd:attribute name="creation_date" type="xsd:date" minOccurs="0"/> - <xsd:attribute name="creator" type="xsd:string" minOccurs="0"/> - <xsd:attribute name="type" type="xsd:string" minOccurs="0"/> - - </xsd:complexType> - - <xsd:complexType name="AllowsObjectType"> - <xsd:sequence> - <xsd:element name="Allow" minOccurs="0" maxOccurs="unbounded"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="User" type="xsd:string"/> - <xsd:element name="Permissions" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="DeniesObjectType"> - <xsd:sequence> - <xsd:element name="Deny" minOccurs="0" maxOccurs="unbounded"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="User" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="SecurityObjectType"> - <xsd:sequence> - <xsd:element name="Allows" type="AllowsObjectType"/> - <xsd:element name="Denies" type="DeniesObjectType"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - </xsd:complexType> - -</xsd:schema> diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/resources/xsdCorners.xsd b/branches/sdo-1.1.1-incubating/impl/src/test/resources/xsdCorners.xsd deleted file mode 100644 index b62bfcae56..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/resources/xsdCorners.xsd +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - -->
- <!-- a schema for housing examples of tricky corner cases in XSD to SDO conversion
- 1) namespace prefix creation as in TUSCANY-711
- .....
- -->
-<xsd:schema xmlns:s1="http://www.example.com/simple-1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simple-1">
-
- <xsd:element name="a" type="s1:A"/>
-
- <xsd:complexType name="A">
- <xsd:sequence>
- <xsd:element name="a1" type="xsd:string"/>
- <xsd:element name="a2" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-</xsd:schema>
|